Introduction: IoT Water Control and Monitor Using NodeMCU & Cayenne

I'll try to create IoT water control and can be monitoring using Cayenne.

The valve will close when water reached top level of the sensor.

This project is to ensure that water reservoir always in full condition, because in my location the water supply only flow when midnight, but if midnight we are not need water.

Step 1: Bill of Materials

Hardware Required :

1. NodeMCU ESP-12E

2. Liquid Level Sensor (calibrate first to get top level value and bottom level)

If you need more deep sensor, you can cut the top strip of sensor and take some wire to two side of sensor

3. 1 CH Relay Module

4. 12V Solenoid Valve

5. 12V 2A Power Supply

6. Jumper Cable

Software Required :

1. Arduino IDE

2. Cayenne for iOS/Android/Web Browser

Step 2: Connecting NodeMCU to Liquid Sensor, Relay Module, and Valve

NodeMCU_______Sensor__________Relay

VIN_____________ Not connected____VCC (+)

3.3V____________ +_______________Not connected

GND____________-________________GND

A0______________S_______________Not connected

D5______________Not connected____ Not connected

Relay___________Solenoid__________Power Supply

NO_____________Not connected______+

Center PIN_______+________________ Not connected

Not connected____- ________________ -

Step 3: Upload Code to NodeMCU

In this step we will program the NodeMCU with Arduino IDE.

You need to open WATER_CONTROL.ino, edit your Cayenne token, SSID, password, edit top level and bottom value and then connect your NodeMCU with USB Cable to your computer and upload the code to NodeMCU.

Now your NodeMCU is online.

Step 4: Setting Up Cayenne

Do this step on Cayenne :

  • Add Valve Switch widget from Cayenne Dashboard, and select Virtual Pin 1.
  • Add Analog Sensor widget from Cayenne Dashboard, and name it to Water Level, select Virtual Pin 10, Unit Percentage
  • Add triggers and set if water level above 100 % then valve switch turn off.
  • Add triggers and set if water level below 100% then valve switch turn on.