To test if the soil moisture sensor is working correctly, I hooked up a simple digital tube display. The sensor is connected to an analog pin. So if there is high moisture, the read value is high (a few hundred). If it were totally dry it would show 0.
#include <Arduino.h>
// Display stuff
#include <TM1637Display.h>
#define CLK 12
#define DIO 11
TM1637Display display(CLK, DIO);
int sensorPin = A0;
void setup()
{
}
void loop()
{
int sensorValue;
sensorValue = analogRead(sensorPin);
display.setBrightness(0x0f);
display.showNumberDec(sensorValue, false, 4, 0);
delay(1000);
}
Seems like the sensor works like a charm!
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.