-
1Connections
- Connect the two pins from the Sensor to the two pins on the Amplifier circuit via hook up wires.
- Connect the Vcc from the Amplifier to the 3.3V pin on the Arduino and the Gnd pin to the Gnd pin on the Arduino.
- Now connect the Analog Data Pin to the A0 pin on the Arduino.
-
2Code
#define SensorPin A0
float sensorValue = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
for (int i = 0; i <= 100; i++)
{
sensorValue = sensorValue + analogRead(SensorPin);
delay(1);
}
sensorValue = sensorValue/100.0;
Serial.println(sensorValue);
delay(30);
}
Write the above code on the Arduino software and verify/debug it. For each soil moisture measurement, we took an average of 100 sensor data to make the data more stable and accurate. You can modify the code as per your requirements. After verifying the code, upload it on the Arduino board.
You can check the working of the sensor when you dip the sensor leads in a water filled soil and in a dry one. You can keep these values as reference for future use. Also, please note that the sensor may get oxidized in the soil after 10-12 months and lose its accuracy. Thus, you will have to replace the sensor every year.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.