Soil Moisture Sensor Hygrometer Module V1.2 capacitive for Arduino Microcontroller

It is December 17th and the Christmas elves from AZ-Delivery had so far packed many big and small surprises behind the little doors. Also behind door number seventeen today there is a little something that can help watering flowers, especially in winter. A poinsettia in particular only needs water when the soil is slightly dry, otherwise it will break quickly. With this little gardening knowledge, you can continue straight away.

What's behind the door?

Behind the door there is the soil moisture sensor hygrometer module V1.2 capacitive, see illustration 1.

Illustration 1: Soil moisture sensor hygrometer module V1.2 capacitive

In direct comparison to the Soil Moisture Sensor Hygrometer Soil Moisture Module, see Figure 2, the size and the type of connection are visibly different.

Illustration 2: Comparison of the soil moisture sensors

Not only the size and connection differ, but also how the sensors communicate with micro controllers. The Soil Moisture Sensor Hygrometer Module V1.2 capacitive only returns an analog signal, whereas the Soil Moisture Sensor Hygrometer Soil Moisture Module returns an analog and digital signal. In most cases, however, only the analog signal is of interest. Since the contacts of the Soil Moisture Sensor Hygrometer Soil Moisture Module are freely accessible, the contacts can quickly corrode. With the Soil Moisture Sensor Hygrometer Module V1.2 capacitive, as the name suggests, the soil moisture is measured capacitively.

The preparation

So that we can use the soil moisture sensor hygrometer module V1.2 capacitively, you need a corresponding micro controller. For the little experiment shown here, the Nano V3.0 with Atmega328 CH340 is completely sufficient. Important at this point: the soil moisture sensor hygrometer module V1.2 capacitive needs a 5V power supply and also delivers an analog signal between 0-5V! Use e.g. an ESP32, then you have to build a voltage divider in front of the analog input, otherwise you can destroy your microcontroller.

A 16x2 LCD display with I2C connection is required for the display.

Monitor soil moisture

As a small and quick example, the sensor should output the analog signal on a 16x2 LCD display with an I2C adapter. The structure and the source code are done very quickly.

The wiring is  according toTable 1:

Pin code

MicroController (Nano V3.0)

Soil moisture sensor

Display

GND

GND

GND

GND

5V

5V

VCC

VCC

Analog signal

A0

AOUT

 

SDA

A4

 

SDA

SCL

A5

 

SCL

table 1: Connection to microcontroller

The source code is as simple as it is done quickly, see Code 1.

//-----------------------------------------------------
// Soil moisture sensor sample
// Author: Joern Weise
// License: GNU GPl 3.0
// Created: Dec 10, 2020
// Update: Dec 10, 2020
//-----------------------------------------------------
#include
#include

#define UPDATETIME 5000
#define NEEDTOWATERING 700
LiquidCrystal_I2C lcd (0x27,16,2); // set the LCD address to 0x27 for a 16 chars and 2 line display
unsigned long iLastUpate = 0;
int iLastAnalogRead = 0;
// the setup routine runs once when you press reset:

void setup () {
// initialize serial communication at 9600 bits per second:
Serial.begin (115200);
Serial.println ("Starting setup");
Serial.println ("Init display");
lcd.init (); // initialize the lcd
Serial.println ("Backlight on");
lcd.backlight (); // backlight on
Serial.println ("Write text");
lcd.home (); // set cursor to 0,0

// Write some text
lcd.print ("Soil moisture");
lcd.setCursor (0, 1);
lcd.print ("sensor monitor");
Serial.println ("Setup done");
delay (5000);
  }

// the loop routine runs over and over again forever:
void loop () {

if (millis () - iLastUpate> UPDATETIME) {
int sensorValue = analogRead (A0);
if (iLastAnalogRead! = sensorValue) {
lcd.clear ();
lcd.home ();
lcd.print ("Value:" + String (sensorValue));
lcd.setCursor (0, 1);
if (sensorValue> = NEEDTOWATERING)
lcd.print ("Need some water");
else
lcd.print ("No water needed");
Serial.println ("New value:" + String (sensorValue));
iLastAnalogRead = sensorValue;
    }
iLastUpate = millis ();
  }
}

code 1: Code monitor soil moisture

 

So you always have an eye on when you need to water your poinsettia or other plant again, see Figure 3. Don't forget to add the define NEEDTO WATERING set so that your plants do not die of thirst!

 Illustration 3: Finished circuit


You can find more projects for AZ-Delivery from me at https://github.com/M3taKn1ght/Blog-Repo.

 

Specials

1 comment

Horst Schwemmer

Horst Schwemmer

kann ich das Hygrometer Modul V1.2 auch über den bereits vorhandenen MCP3800 an einem Raspberry 3 betreiben?
Danke schon mal im Voraus
Horst Schwemmer

Leave a comment

All comments are moderated before being published

Recommended blog posts

  1. Install ESP32 now from the board manager
  2. Lüftersteuerung Raspberry Pi
  3. Arduino IDE - Programmieren für Einsteiger - Teil 1
  4. ESP32 - das Multitalent
  5. OTA - Over the Air - ESP programming via WLAN