#3_04 Home Hidroneumatic Controlled by ESP8266 + MQTT + Web App
Posted by Superadmin on November 29 2018 05:14:06

Home Hidroneumatic Controlled by ESP8266 + MQTT + Web App

Overview

Motivated by the constant lack of water supply in my city I have been forced to install a water tank that feeds a hidroneumatic so as to have water with enough pressure for the whole house.

Additional needs to install a pump for the rapid filling of the main tank at times when the water arrives with very little pressure. This project allows controlling:

All activities executed with help of :

Block Diagram

In the block diagram picture we can see the four main components of this project:

1.-Clients

2.- Web Server and MQTT Broker running at Raspberry PI v3

 

3.- Control server running at ESP8266

4.- Devices like pumps, valves, light, sensors and LCD display controlled by ESP8266 + MCP23008

Install all software needed and connect all devices

Step 1 - Configure Raspberry PI v3

Make sure Raspberry PI was updated

sudo apt-get update

sudo apt-get upgrade

Check your ip address with the command

ifconfig

See ip address at eth0 or wlan0

Install Apache Web Server

Install Mosquitto MQTT Broker Server

cd /

wget http://repo.mosquitto.org/debian/mosquitto-repo.gpg.key

sudo apt-key add mosquitto-repo.gpg.key

cd /etc/apt/sources.list.d/

sudo wget

  or

sudo wget

sudo apt-get update

sudo apt-get install mosquitto

sudo nano /etc/mosquitto/mosquitto.conf

  # add this two lines for websocket support

  listener 1884

  protocol websockets

systemctl start mosquitto

systemctl enable mosquitto

Step 2 - Configure your device and project at Cayenne Cloud.

Step 3 - Programming ESP8266 and connect it to Cayenne Cloud

Step 4 - Create your device widgets at Cayenne Cloud Dashboard

Press Button controller widget for create a new button to activate Hidroneumatic.

Press Button controller widget for create a new button to activate Pump that fill tank with water.

Press 2 State display widget for create a new status indicator that tank is fill from water street.

Press Button controller widget for create a new button Deactivate all devices.

Press Button controller widget for create a new button Room light to turn on/off pumps room light.

Press 2 State display widget for create a new motion detector for pumps room.

Step 5 - Create a Project "Hidroneumatic Control"

At this point you will create a Cayenne project "Hidroneumatic Control" to do that press Add new.. and Project option.

Now drag and drop all created widgets from left bar to project dashboard to create a new Cayenne browser project to control our devices.

Step 6 - Install Cayenne mobile client from Apple Store or Android Store

After installs your Cayenne mobile app login and select Projects and Hidroneumatic Control and go to dashboard and you will see all widgets.



Step 7 - Software is ok now proceed with Hardware, the control board

Software details

This project uses two files:

hidro.html : is a responsive web application client written in Bootstrap, Jquery and using a Paho Javascript Client, an MQTT browser-based client library written in Javascript that uses WebSockets to connect to an MQTT Broker.

Must be installed at Apache Web Server together with script folder.

It is a Publisher and Subscriber to MQTT Broker topic "HidroControl" it send and receive messages.

Each button On/Off send a message to MQTT Broker and change on to off and off to no status.

If tank is empty or begin fill and is full you will receive the status at Tank Status label.

If a movement is detected by a PIR sensor the pumps room light turn on and you will receive the status at Room Light label.

If you want remote connect to LCD you only have to click at LCD Status and you receive the last two lines messages that is displayed at LCD.

HidroNeumaticControl.ino is a firmware to ESP8266.

Have a state machine to control all devices, depends from message receive from MQTT Broker calls each function.

It is a Publisher and Subscriber to MQTT Broker topic "HidroControl" to send and receive messages.

It implements a Cayenne to MQTT Broker bridge.

It implements a I2C communication with LCD display and MCP23008.

Turn on/off pumps room light when PIR sensor detects movement.

Hardware details

The brain of control board is a ESP8266, I use an Adafruit HUZZAH implementation but you can use any other for example Sparkfun ESP8266 Thing.

MCP23008 is an 8-Bit I/O Expander and controls the other devices and sensors.

Use 12v / 30A power supply because all solenoids valves, and a Dc to DC converter to generate 5v needs for all circuit.

Pumps room lightwater pump and hidroneumatic pump using 110v controlled by each relay, be attention when connects them.

You can test the control board and MQTT Broker connection loading in the web browser the web app client, press some buttons and see all messages send and all status at LCD display, check that all relays are activated like the next table.

Schematics

Schematic Control Board

 



Code

Hidroneumatic Control

Download as zip