Moisture Control Unit - MCU
by CodeChamp in Circuits > Microcontrollers
3367 Views, 40 Favorites, 0 Comments
Moisture Control Unit - MCU
Hey, Makers!
In this Instructables, you will see how to Interface Moisture sensor to your NodeMCU. And check the moisture value and the same to be displayed on the LCD.
We'll use Liquid Clear Crystal to display the moisture value. This 16x2 LCD is very popular and broadly used in electronics projects as they are good for displaying information like sensor data from your project, and also they are very cheap.
All You Need
Here is the list of components required to get started with the Instructable,
Hardware Components
- NodeMCU
- Moisture sensor
- 16x2 LCD
- Breadboard
- Jumper Wires
- Micro USB Cable
Software Components
- Arduino IDE (installed with esp8266)
Description
This Moisture Sensor can be used for detecting the moisture of soil or judge if there is water around the sensor, let the plant in your garden able to reach out for human’s help when they are Dry.
This sensor is very easy to use, you can just simply insert in into the soil and read the data.
#1 Circuit Conection
The wiring connections are made as follows:
Connect the two pins of the moisture sensor to the two pins on the Amplifier circuit using jumper wires.
Connect the Vcc from the Amplifier to the 3.3V pin on the NodeMCU.
Connect the GND pin to the ground (GND) pin on the NodeMCU.
Connect the Analog pin to the A0 pin on the NodeMCU.
Connect NodeMCU to PC via a USB cable.
After your completed with wiring connections, then insert the sensor into the soil or place it in anywhere you want
**In this Instructable I have used water for the Demonstration
#2 Circuit Connection
Connecting LCD to I2C and then interfacing it to NodeMCU is very simple.
The LCD’s registers from D0 to D7 and Vcc, GND, RS, R/W pins will be connected to I2C.
GND pin of I2C is connected Ground pin (GND) of the NodeMCU.
VCC pin of I2C is connected Vin pin of the NodeMCU. (Because we need to supply 5v to LCD)
SDA pin of I2C is connected D4 of the NodeMCU.
SCL pin of I2C is connected D3 pin of the NodeMCU.
Before you get started with coding you need Arduino IDE.To download Arduino IDE and for NodeMCU setup, you can check my previous Instructable.
Overall Circuit
You need one paper cup with water to check if the circuit works.
CODE
The first thing we need to do is to insert the Liquid Crystal Library.
To include Library file :
Sketch > Include Library > Manage Libraries > LiquidCrystal_I2C LCD
Download the "LCD_MCU_Moisture.ino" file and open it up in the Arduino IDE.
Then Create a new sketch and paste the code below in the Arduino IDE and hit Upload You can tinker with the code to make it more useful or just use it as it is.
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F, 16, 2);
int sense_Pin = 0; // Soil Sensor input at Analog PIN A0int value= 0;
void setup() {lcd.begin(16,2); lcd.init(); lcd.backlight();
}
void loop() {lcd.setCursor(0, 0); lcd.print("MOISTURE : "); value= analogRead(sense_Pin); value= value/10; lcd.print(value); lcd.print("%"); if(value < 50) { lcd.setCursor(0, 1); lcd.print("The soil is WET"); } else { lcd.setCursor(0, 1); lcd.print("The soil is dry"); } delay(1000); }
Downloads
Preparing the Arduino IDE
After downloading the Arduino IDE navigate to
- File tab and then click on Preferences.
- In the additional Boards, Manager URLs add the following link (http://arduino.esp8266.com/stable/package_esp8266com_index.json)
- Click OK and then navigate to
- Tools - Boards - Boards Manager
In the search field type esp8266 > click the esp8266 by ESP8266 Community - Click Install Now you have setup the Arduino IDE to work along with the NodeMCU.
Save * Compile * Upload
- Goto Tools
- Board > NodeMCU 1.0 (ESP - 12E Module)
- Port ( Choose the right Port )
**Make sure you have your NodeMCU model selected and the correct serial port ticked (see pics). Then just click the Upload button**
Ready To GO
OUTPUT
That's all makers!
I hope you found this instructable most useful. You can contact me by leaving a comment. If you like this instructable probably you might like my next ones.
Thank You.