icon

How To Create Your Very Own Soil Moisture Sensor

Dying houseplants are a thing of the past with this soil moisture sensor hack.

projectImage

Things used in this project

 

Hardware components

HARDWARE LIST
1 Arduino Nano R3
1 Ynvisible Segmented Display Kit
1 DFRobot Gravity: Analog Capacitive Soil Moisture Sensor- Corrosion Resistant

Software apps and online services

Arduino IDE

Story

 

Dying houseplants are a thing of the past with this soil moisture sensor hack.

 

In this guide, we’ll show you how to create a very simple moisture sensor for measuring soil moisture content. This can be used to monitor real-time volumetric water content in your houseplant soil so you know when to water it to keep it at the optimum moisture level.

 

This soil moisture sensor uses the Ynvisble Display Kit and Arduino Nano.

 

Read on to learn how to do it yourself.

CONNECTING THE COMPONENTS

 

Follow these simple steps to build your own soil moisture sensor:

 

1. Connect the Arduino to the breadboard

 

2. Connect the Ynvisible driver to the breadboard by using the 4 pin 90° IDC adapter

 

3. Connect the bar display to the driver (Theleftmost display electrode must be connected to the leftmost electrode inthe connector).

 

4. Connect the DFROBOT Capacitive Soil Moisture Sensor V1.0 to the breadboard by using the 3 pin 90° IDC adapter

 

5. Connections that need to be made using jumper wires:

 

-5V from Arduino to VCC on the driver and to + on the moisture sensor

 

-GND from Arduino to GND on the driver and to – on the moisture sensor

 

-SDA from the driver to pin A4 on the Arduino

 

-SCL from the driver to pin A5 to the Arduino

 

-Pin A from the sensor to pin A2 on the Arduino

 

-Connect the Power supply + to the Arduino VI pin and the – to the GND

projectImage
projectImage

PROGRAMMING THE ARDUINO

 

Follow these steps to program the Arduino for your soil moisture sensor:

 

ADD THE LIBRARY TO THE ARDUINO IDE

 

-Install and open ArduinoIDE

 

-Download Arduino Library for the driver 4.1, Ynvisible-ECD-Arduino-Library-1.0.0 (download here)

 

-Click "Sketch"/"Include Library"/"Add.ZIP Library..." in the main menu

 

-Go to your downloads folder and choose Ynvisible-ECD-Arduino-Library-1.0.0.zip

 

UPLOAD THE CODE TO ARDUINO

 

-Connect the Arduino to your computer with a USB cable

 

-Create a new file in the Arduino IDE

 

-Replace the code in the editor with the code below

 

-Click "upload" (the right arrow on the upper left in the Arduino IDE)

 

-Congratulations you now have a functional moisture sensor. You can now add your soil sensor to your plant to begin monitoring the water content of the soil - and how happy it is!

 

FEEL FREE TO CHANGE THINGS UP

Now you have your own soil moisture sensor, you have everything at your fingertips to start exploring the code and making changes to the hardware to turn your ideas into prototypes.

 

You could try switching up the display from the Ynvisible Display kit and change the moisture sensor to a light sensor, for example. The sky is your limit.

 

Check out Ynvisible University for more inspiration and how-tos.

Schematics

Soil Moisture Sensor Schematics

projectImage

Code

Soil Moisture Sensor Firmware Code

CODE
#include <Ynvisible_Driver_4.2-1.0.0.h>


int i2c_address = 43;         //The i2c address of driver board 4.1
int number_of_segments = 7;  //Number of segments on display (1-15)


const int analogInPin = A2;   // Analog input pin 
int sensorValue = 0;          // Value read from the moisture sensor
int barValue = 0;             // Output value for the bar display sensor


YNV_ECD ECD(i2c_address, number_of_segments); //Initialize ECD Object

 
void setup() {
}

void loop() {
  sensorValue = analogRead(analogInPin); // Read the value from the moisture sensor
  barValue = map(sensorValue, 350, 850, 7, 0); // Mapping the value from the moisture sensor on a range from 0 to 7

 
  ECD.setBar(barValue); //Set the display with the output value mapped from 0 to 7  
  delay(3000); //3 seconds delay between each update
 
}

The article was first published in hackster, August 23, 2021

cr: https://www.hackster.io/miltonfernandes/how-to-create-your-very-own-soil-moisture-sensor-ab8960

author: miltonfernandes

License
All Rights
Reserved
licensBg
0