Hackster is hosting Hackster Holidays, Ep. 5: Livestream & Giveaway Drawing. Watch previous episodes or stream live on Friday!Stream Hackster Holidays, Ep. 5 on Friday!
miltonfernandes
Published © GPL3+

How To Create Your Very Own Soil Moisture Sensor

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

BeginnerFull instructions provided1,983
How To Create Your Very Own Soil Moisture Sensor

Things used in this project

Hardware components

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

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Soil Moisture Sensor Schematics

Code

Soil Moisture Sensor Firmware Code

Arduino
#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
 
}

Credits

miltonfernandes

miltonfernandes

0 projects • 0 followers

Comments