Close

Testing the Soil Moisture Sensor

A project log for lowcost full automated watering robot

None of your plants will ever die again! At least not due to lack of water... ;)

xamiaxxamiax 03/14/2016 at 20:020 Comments

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