
Soil moisture measurement is one of the foundations smart irrigation systems are built on. This project can be implemented using a NodeMCU board with a built-in ESP8266 chip and Wi-Fi capability, displaying the result on an LCD screen connected via the I2C protocol to reduce the number of wires needed.
Components needed
A NodeMCU (ESP8266) board, a soil moisture sensor (providing both analog and digital output), and a 16x2 LCD screen fitted with an I2C backpack module (reducing the pins needed from 16 down to just 4).
Wiring it up
The moisture sensor's analog output connects to analog pin A0 on the NodeMCU board, while the LCD screen (via its I2C module) connects to the D3 and D4 data pins dedicated to I2C on the board, in addition to the power and ground pins.
How it works
The code reads the analog value from the moisture sensor, then converts it into an approximate percentage by dividing by a fixed factor. A simple threshold of 50% is applied: if the reading is below this threshold, a "wet soil" status is shown, and if it exceeds it, a "dry soil" status is shown, with the display refreshing this reading roughly once per second.
You can find NodeMCU boards, soil moisture sensors, and LCD screens with I2C modules at Juthour Tech.
اترك تعليقا