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.
REQUIRED HARDWARE
To make the soil moisture sensor, you’ll need the following:
Arduino Library for the driver 4.2, Ynvisible_Driver_4.2-1.0.0 (download here)
CONNECTING THE COMPONENTS
Follow these simple steps to build your own soil moisture sensor:
Connect the Arduino to the breadboard
Connect the Ynvisible driver to the breadboard by using the 4 pin 90° IDC adapter
Connect the bar display to the driver (The leftmost display electrode must be connected to the leftmost electrode in the connector).
Connect the DFROBOT Capacitive Soil Moisture Sensor V1.0 to the breadboard by using the 3 pin 90° IDC adapter
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
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 Arduino IDE
Click "Sketch"/"Include Library"/"Add .ZIP Library..." in the main menu
Go to your downloads folder and choose Ynvisible_Driver_4.2-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:
#include<Ynvisible_Driver_4.2-1.0.0.h>int i2c_address =43;//The i2c address of driver board 4.1int 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 sensorint barValue =0;// Output value for the bar display sensor
YNV_ECD ECD(i2c_address, number_of_segments);//Initialize ECD Objectvoidsetup(){}voidloop(){
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}
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.