top of page
ArudAndMoistureSensorHeaderImage.png

Article covers measuring moisture contents in soil using Arduino-Uno & Moisture sensor.

Disclaimer

1. This article does not cover the calibration of moisture sensors.

2. This does not cover the working principles of flow meter.

Working sample

Before we proceed further, let us take a look at what our end result would look like.

Items needed

- Arduino Uno.

- Soil moisture sensor.

Pre-requisites

This post assumes you already have,

1.     Arduino Editor installed on your laptop.​

2.    Your laptop connected to Arduino using the USB cable.

3.    Basic familiarity with Arduino programming using C++.

Technical details

How moisture sensors work?

This post does not go deeper into the working details of moisture sensors. There are numerous materials available on the internet.

Moisture sensor used in this examples accepts 5V as input .

Technical details
This is how the final setup looks like:
IMG_6443.jpg
How-to steps

Step 1: Connecting Arduino to moisture sensor

IMG_6445.jpg
IMG_6444.jpg
Step 2: Arduino C++ code

There are no libraries needed.

C++ code

#define SensorAnalogPin A2
float sensorOutputValue = 0;

​

void setup() {
        Serial.begin(9600);
}

​

void loop() {

      //Through analog pin A2, take 100 measurements of sensor value to increase accuracy of reading 

      for (int counter = 0; counter <= 100; counter++) {
           sensorOutputValue = sensorOutputValue + analogRead(SensorAnalogPin);
           delay(10);
       }

       sensorOutputValue = sensorOutputValue / 100.0;
       Serial.println(sensorOutputValue);
       delay(1000);

}

Step 3: Testing the bidirectional message communication

Now the setup should be ready to test the moisture sensor. Please refer the last section of accompanying video in this page to see the working demo.

Closing note

Hope this post gives you the basic details for measuring the moisture contents using Arduino and resistive moisture sensor. Wishing you all the very best for your IoT projects.

bottom of page