Soil Moisture Sensor – How to use with Arduino

A soil moisture sensor, as the name implies, allows measuring the moisture level of soil. This can be particularly helpful if you want to accurately determine when plants need to be watered or assess how fast water is draining at a specific location.

Sensor Components

The Soil Moisture Sensor has two main components:

  • Soil probe.
  • Sensor circuit board.

The soil probe is what will make contact with the soil to assess the water level, while the sensor circuit board will process the soil probe’s signal and output it through the analog output pin. The circuit board will also generate a digital output which generates a HIGH or LOW depending on the potentiometer setting.

Soil moisture sensor components

Soil Moisture Sensor Length

The probe has an overall measuring range of 1.6 inches (~41mm).

Soil moisture sensor length

Click to enlarge

Sensor Pins

VCC – Connected to Arduino UNO 5V output.
GND – Connected to Arduino GND.
DO – Digital Output
AO – Analog Output
Connection pins from probe to sensor circuit board

Soil moisture sensor pins

Connection to Arduino

The sensor can be used through use of the analog output or the digital output. Both options shown below:

Analog Output Option

Soil moisture sensor connections (analog output option)

Click to enlarge

Digital Output Option

Soil moisture sensor connections (digital output option)

Click to enlarge

Arduino Code – Analog Output Option

Arduino Code – Digital Output Option

Run Arduino Code – Testing Soil Moisture Sensor

All you need to do now is run the code that was provided above, in either configuration, and open the Serial Monitor.

Result for Analog Output Option

Click to enlarge

Result for Digital Output Option

Click to enlarge

Alternate Connection Method to Extend Soil Moisture Sensor Life

One thing to note is, if you plan on using this sensor for an extended period of time, note that the probe will corrode over time. One way to slow the corrosion rate is to only power the sensor when you need to take readings. To do this, you will need to connect the sensor by powering VCC with a digital output from the Arduino UNO. In this case, simply set the pin as an output, and set it to HIGH whenever you need to take readings. Once done, set the IO pin to LOW, which will set VCC in the sensor to zero, turning the sensor off. Something to consider when doing this is, can the IO pin supply the required current to the sensor? Below we will confirm this for the Arduino UNO.

Click to enlarge

Sensor working current

The setup about requires powering the sensor through an IO port. The Arduino UNO’s maximum current per IO pin of 20mA. Luckily this sensor doesn’t pull that much current. After setting up a multimeter, the current flowing through VCC was measured to be 4.08mA, so there should be no issues powering the sensor through an Arduino UNO IO port.

Components used in this example

*As an Amazon & Ebay Associate I earn from qualifying purchases.

ComponentLink
Arduino UNOhttps://amzn.to/3uYVAMC
https://ebay.us/veZdKX
Soil Moisture Sensorhttps://amzn.to/3dqsAYp
https://ebay.us/w4O3zI
Amprobe AM-510 Multimeterhttps://amzn.to/32mV4Mf
https://ebay.us/uwo7sC
Amprobe TL35B Test Leads with Alligator Clipshttps://amzn.to/3dp5m4M
https://ebay.us/OM4r4B

Leave a Reply

Your email address will not be published. Required fields are marked *