This is second part (here is the first part) of the project "Device for monitoring household water pipes" and represents the user interface as well as monitoring and control from the local network (through the Smart Home system internet made with Node-red) and remotely via the Datacake IoT platform.
I named this project "AquaSense" to give it a personality and exemplify the fact that it is a monitoring system ("Sense") of a water sensor ("Aqua").
Important: The language in which the information is displayed in UI is Romanian, even though the explanations of the menus in this project are in English.
We also provided an option to set the language, but it is not fully implemented.
We did this because this system is served by several people and it is important that they understand what is displayed.
1. IntroductionThe UI module is built around the ESP32-CYD. This is an interesting module with an ESP32 Wroom-32 and an 2.8 LCD with rezistive touchscreen.
Communication with the Main board that controll the valve and monitor the water leaks sensor is done via a serial protocol, RS485 l and is based on a question and answer. As we presented in the previous project, the UI module is the Master (the one that initiates the communication and asks) and the Main board is the slave (the one that responds to the received questions but never initiates the communication).
The messages exchanged between the UI and the main board are presented below and are slightly different from those in the previous project (because we didn't have the UI ready yet!):
Therefore, each command from the UI, to start/stop the solenoid valve, cancel alarms, start the relay is also accompanied by a status command. On the Main board, a mechanism is implemented to continuously check the solenoid valve station, the water sensor and the relays; this mechanism runs every 10 seconds, so that when the UI sends a command, it may happen that the response confirming the command arrives with a maximum delay of 10 seconds before being displayed.
Additionally, if the solenoid valves are off and the start command and then the status command are sent, the first response is Fault, because the previous state was off and the current sensor did not register consumption from that solenoid valve; only after the 10 seconds is the correct status updated in the UI. This is normal behavior for this system implemented in this way.
Important: for proper functioning of the communication between the UI module and the main board, it is necessary that the Main board be updated with the firmware in the attachment, as it presents some modifications for the implementation of the coercion and communication between the modules.
2. UI screensFor this project, the UI is created using two main components:
- the LVGL library for Arduino IDE Vx.2 and ESP32;
- the EEZ Studio application, with which I created the screens and arranged the buttons, text boxes and everything else needed.
The main function of the UI module is to operate the water solenoid valves; in addition, it also allows the display of various water system states, such as: on, off, fault or alarm. This information is presented on the main screen.
In addition to the main screen, the UI module contains two more screens, named as follows: "Settings" and "MQTT".
Let's detail the information in the 3 screens:
A. Main screen:
To measure local temperature and humidity we used a DHT11 sensor. We have provided software protection in case this sensor fails and no longer responds to specific commands in order not to block the normal functioning of the program; in this case, instead of the normal value displayed for temperature and humidity, the symbol "--" will be displayed.
There are two buttons for operating the two hot and cold water solenoid valves; each button has a status indicator (in the UI, in the form of an LED), a text that displays the status and a field that displays the electric current consumption (to verify that the valve is functional, i.e. it consumes current). Possible states for solenoid valves: On, Off and Fault.
On the main screen we also find an indicator of the general status of the system, which will display the following situations: On, Off, Alarm, Fault.
Also displayed on the main screen is the total power consumption from the main board and UI module's network transformer; the value is calculated based on the transformer output voltage set in the "Settings" screen.
OBS: A special feature of this system is the possibility of activating 2 relays, with a coil powered at 12Vdc, to activate/deactivate some loads. In my case, I needed to power the washing machine and the air conditioner from the same 220V outlet in a location, but since the electrical network is quite old and does not support both loads simultaneously, I had to set these 2 relays to exclude each other (i.e. relay1 = ON then relay2 - OFF and vice versa but never both ON). In addition, this functionality can be deactivated from the "Settings" menu.
B. Settings screen:
In the "Settings" screen, we have the system settings, except for the communication part. From here you can do the following:
- set the RTC (which is actually not a real RTC, but rather a counter made to look like an RTC),
- enable or disable the relay section on the main screen,
- rename the relays to better reflect their functionality, reset the alarm state or turn off both solenoid valves,
- set the output voltage, in alternating current, of the transformer used to power the entire system,
- set the display language (this functionality is not yet implemented but is in the works...).
Here we also have 2 more buttons, one to return to the main screen and another to go to the connectivity settings screen for MQTT.
C. MQTT screen:
In the MQTt connectivity settings screen we have the following options:
- connect or disconnect from the WIFI network;
- set WIFI parameters: SSID and password;
- set the IP address of the MQTT broker;
- set the device name within the MQTT network;
In addition, we have a button to test the MQTT connection, also used to reconnect in case the MQTT broker has stopped and the system has not reconnected automatically.
And last but not least, we have a button to return to the main screen.
3. UI module featuresIn addition to the functionalities presented on each screen, this system can also do the following:
- setting the RTC can also be done from the MQTT broker (Node-red for example);
- the system sends an "online" status to the mqtt broker every 5 seconds;
- the system deactivates the backlight and touchscreen after 30 seconds (programmable value in the code);
- the system returns to the main screen after 15 seconds (programmable value in the code);
- the system displays a special screen at boot, which presents the name, software version and a message to connect to WiFi and MQTT,
- the system verify connection to MQTT broker at every one minute ot try to automatically reconnect in case on loss MQTT connection; this is done only if WIFI is set to ON and connected to local router.
4. Local and remote monitoring and commandsBecause this project is considered part of IoT systems, an internet connection and external access are required for its control and monitoring.
The connection to the local network is made through the ESP32 module mounted on the ESP32CYD board; for monitoring, we used the Node-Red platform, with which we have also worked on other projects.
For Internet communication, however, we used the secure Datacake platform, through the MQTT protocol implemented by this same platform.
For the Node-red setup, see this project, section 4.
For Datacake setup, see this project , section Datacake.
Screenshots from NodeRed:
Screenshots form Datacake, desktop and mobile application:
OBS: I cannot attach the dashboard structure from NodeRed because it is combined with Datacake and contains sensitive information that should not be accessed by the general public.
5. This is what the installed system looks likeThis system is intended to be installed in two places: the kitchen and the bathroom, because here we have separate hot/cold water supply installations.
Below is the system installed in the kitchen:
Here is the system installed in the bathroom:
For this module I did not make a specific PCB because most of the components are already on the ESP32CYD board. So I connected the temperature sensor, IR sensor and RS495 module with the ESP32CYD board by wires, as in the table below:
This is how I arranged the components in the plastic case:
Below are two videos demonstrating the operation of this system. The first video shows how the UI operates and how to connect to WIFI and the MQTT broker.
The second one presents the interface created in NodeRed as well as the monitoring mode of each installed system (note the status: online and the "flashing" of the widget):
8. Modification on Main board:I noticed that the current sensor used reads a certain "value" of the current if the load is not connected; thus, I modified the filtering of the 3.3V, 5V and 12V power supply using a 100nF capacitor in parallel with a 220uF one, in parallel with the existing one; in this way, the false reading, without load, was reduced from ~20mA to 2-3 mA, which is acceptable.
9. Next steps- to develop the language change between Romanian and English;
- to develop the Zigbee connection between main board and Zigbee network;
- any other idee...












Comments