Interface do sensor de umidade do solo de água de chuva com módulo WiFi Nodemcu Esp8266-12E

Rainwater Soil Moisture Sensor Interface with Nodemcu Esp8266-12E WiFi Module

This is a simple tutorial on how to interface rainwater or soil moisture level sensor with nodemcu esp8266-12e WiFi module. Monitoring your garden's status via WiFi earns the title of smart garden design. We will monitor the composition of rainfall and soil moisture levels. The user can see the status of their garden now on their desktop or mobile phone. Simple and popular humidity level sensor is used in the project.
Water Moisture Level Sensor

Water Moisture Level Sensor
The sensor consists of two legs. Sensor works with power supply from 3.3 volts to 5 volts. A conductive material, usually nickel or copper, is glued to each leg. An electrical energy is supplied through the legs. One leg is connected to + of the power supply and the other leg is connected to – of the supply. Both legs are separated from each other. Under normal conditions, no charge flows through the legs because the circuit is open. As soon as we insert the legs into the ground, the moisture in the ground decreases the resistance between the legs and depending on the moisture level voltage flows between the complete circuit. If the moisture composition is high, the resistance between the legs will be low and more voltage will pass through the legs. If the humidity level is low, little voltage will flow through the legs.
Another module provided with the legs is the voltage control circuit. It houses a variable resistance and an lm393 operational amplifier.
It has four pins. Two power pins and two sensor output pins. The sensor output pins are

  • A0 – Analog output pin. Outputs analog voltage that corresponds to soil moisture level or water rain detection. For what purpose is the sensor used.
  • D0 -Digital output signal. We define the limit value by the variable resistor present on the sensor control board. Now when the humidity level increases or decreases, the digital pin threshold value becomes high.

I will use the two output pins in the project. Typically, many tutorials on the internet only use one output pin and leave the other empty. From A0 I will measure the soil moisture level. A threshold value is defined and D0 is used to generate alert whenever the sensor value reaches the threshold.

Project circuit diagram

The Nodemcu works on 3.3 volts and the soil moisture rainwater leak sensor also works on 3.3 to 5 volts. Therefore, we can power the same circuit using the same power source. The water leak sensor can also be powered with Nodemcu output power. Analog channel 0 of the nodemcu is connected to the A0 output of the rainwater sensor. Nodemcu digital pin #13 is connected to the D0 output of the soil moisture level sensor.
Rainwater Soil Moisture Sensor with Nodemcu WiFi Module

Rainwater Soil Moisture Sensor with Nodemcu WiFi Module
Coming to the code. Let's remember the functionality of the project. Whenever a user types a certain IP into their desktop or mobile browser, a page will be displayed that contains the status of the humidity level or rainwater detection. Both the nodemcu and the cell phone/desktop on which you want to see the status must be connected to the same WiFi network. If someone is on another network, the page will not be displayed. Nodemcu is working as a server. It is serving a web page, so the server and client must be on the same network to communicate correctly. First, enter the SSID and password of the network you want your nodemcu to be connected to.

const char* ssid = “Your SSID”;
const char* password = “Your Wifi password”;

Next, the analog channel and digital pins of the nodemcu are defined, which are used to read the output data from the rainwater sensor. In the configuration function the WiFi is turned on and an IP is requested to be assigned by the router to which we are connecting our nodemcu. When the full IP is assigned successfully, the nodemcu starts its server and displays the server address on the Arduino IDE's serial monitor. In the loop function I am waiting for the client's request when a request arrives I calculate the analog value, convert it to a percentage, check if the limit has been reached and pass this value to the page. Nodemcu sends the page back to the client and closes the connection.
In the code, the visible title and button are due to the html code present in the nodemcu arduino ide code.
Just do the circuit above and download the code on nodemcu. After downloading the code, open the Arduino IDE serial monitor with baud rate of 115200 bps. You will see that nodemcu is connecting to your router, starting its server and after the server starts it will display an IP on the screen. This address or IP is the page on which nodemccu displays the soil moisture level status. The IP will look like this. You need to enter this IP into the browser of your cell phone, desktop, laptop or notebook to see the moisture status of the garden soil.
Photograph

The end result will be something like below
Nodemcu Water Rain and Soil Moisture Sensor over WiFi Monitoring

Nodemcu Water Rain and Soil Moisture Sensor over WiFi Monitoring
Whenever the “Update humidity level” button is pressed, the instantaneous sensor values ​​will be displayed on the web page.
Limitations

The copper and nickel conductance of the soil sensor will disappear soon, approximately in 3 months. Everything in the soil is eaten by soil bacteria or undergoes a chemical reaction with the soil contents. The same goes for the ground sensor legs. They lose their conductance very easily and within a few months. It may be necessary to replace the sensor every 3 months. Another limitation is that the user needs to refresh the page (press the update humidity level button) every time they need to see the updated value. The page can be updated automatically using node js instead of related HTML.
Future work
You can extend the above project by activating a water valve whenever the soil moisture level is low. This way you can automatically water your garden plants. The only thing that needs to be modified is to drive a relay with nodemcu to which you can connect a valve. A demo project of interface and relay control via WiFi with nodemcu is below. You use the relay project code with this tutorial and can build a smart garden project.

Conducting relay over WiFi using Nodemcu

Download the project code. The folder contains the .ino file of the Arduino ide project. Please provide us with your feedback on the project. Write your queries and comments in the comments section below.
Code/Files

Conteúdo Relacionado

A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
ESP32-CAM is a compact camera module that combines the...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.