Moisture Control Unit - MCU

by CodeChamp in Circuits > Microcontrollers

3225 Views, 40 Favorites, 0 Comments

Moisture Control Unit - MCU

8.png

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

2.png
6.png
5.png
0.png
1.png
7.png
4.png
3.png
4.jpg

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

00.jpg
10.jpg

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

Wiring.jpg
012.jpg
0012.jpg
12.jpg
13.jpg
IMG_20170828_001518.jpg
IMG_20170828_001536.jpg
IMG_20170828_002333.jpg
IMG_20170828_002403.jpg
IMG_20170828_002433.jpg
IMG_20170828_002505.jpg

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

5.png
I2C-LCD-Module-Board-Arduino-AVR-PIC.jpg
LCD1 copy.jpg
14.jpg
15.jpg
IMG_20170828_002750.jpg
IMG_20170828_002832.jpg
IMG_20170828_002926.jpg
IMG_20170828_002942.jpg
IMG_20170828_003019.jpg
IMG_20170828_003045.jpg

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.

"Interfacing Servo Motor with NodeMCU"

Overall Circuit

IMG_20170828_003417.jpg
IMG_20170828_003457.jpg
8.jpg
9.jpg

You need one paper cup with water to check if the circuit works.

CODE

Code1.PNG
Code2.PNG

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 A0

int 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); }

Preparing the Arduino IDE

Setup.PNG
Setup1.PNG

After downloading the Arduino IDE navigate to

  1. File tab and then click on Preferences.
  2. In the additional Boards, Manager URLs add the following link (http://arduino.esp8266.com/stable/package_esp8266com_index.json)
  3. Click OK and then navigate to
  4. 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

Compile.PNG
save.PNG
Upload.PNG

  1. Goto Tools
  2. Board > NodeMCU 1.0 (ESP - 12E Module)
  3. 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

01.jpg
03.jpg
02.jpg

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.