Devices & Components
Arduino Nano
Ynvisible Segmented Display Kit
Gravity: Analog Capacitive Soil Moisture Sensor- Corrosion Resistant
Software & Tools
Arduino IDE
Project description
Code
Soil Moisture Sensor Firmware Code
arduino
1#include <Ynvisible_Driver_4.2-1.0.0.h> 2 3 4int i2c_address = 43; //The i2c address of driver board 4.1 5int number_of_segments = 7; //Number of segments on display (1-15) 6 7 8const int analogInPin = A2; // Analog input pin 9int sensorValue = 0; // Value read from the moisture sensor 10int barValue = 0; // Output value for the bar display sensor 11 12 13YNV_ECD ECD(i2c_address, number_of_segments); //Initialize ECD Object 14 15 16void setup() { 17} 18 19void loop() { 20 sensorValue = analogRead(analogInPin); // Read the value from the moisture sensor 21 barValue = map(sensorValue, 350, 850, 7, 0); // Mapping the value from the moisture sensor on a range from 0 to 7 22 23 24 ECD.setBar(barValue); //Set the display with the output value mapped from 0 to 7 25 delay(3000); //3 seconds delay between each update 26 27}
Soil Moisture Sensor Firmware Code
arduino
1#include <Ynvisible_Driver_4.2-1.0.0.h> 2 3 4int i2c_address = 43; 5 //The i2c address of driver board 4.1 6int number_of_segments = 7; //Number 7 of segments on display (1-15) 8 9 10const int analogInPin = A2; // Analog 11 input pin 12int sensorValue = 0; // Value read from the moisture sensor 13int 14 barValue = 0; // Output value for the bar display sensor 15 16 17YNV_ECD 18 ECD(i2c_address, number_of_segments); //Initialize ECD Object 19 20 21void setup() 22 { 23} 24 25void loop() { 26 sensorValue = analogRead(analogInPin); // Read 27 the value from the moisture sensor 28 barValue = map(sensorValue, 350, 850, 7, 29 0); // Mapping the value from the moisture sensor on a range from 0 to 7 30 31 32 33 ECD.setBar(barValue); //Set the display with the output value mapped from 34 0 to 7 35 delay(3000); //3 seconds delay between each update 36 37}
Downloadable files
Soil Moisture Sensor Schematics
Soil Moisture Sensor Schematics

Comments
Only logged in users can leave comments