Soil Moisture Sensor Readings

The AnalogReadSerial sketch can be used to test soil moisture sensor readings.

Note: Make sure the soil moisture sensor power pin is connected to a 5v (for the arduino version) or 3.3v (for the ESP WiFi version) pin during this test, and not to a digital output pin.

Connect the USB cable to the arduino or ESP WiFi board and also to the host computer:

TODO: Add WiFi board photo

TODO: Make AnalogReadSerial compatible with WiFi board

Upload and monitor the AnalogReadSerial sketch:

  • sh upload-analogreadserial-sketch.sh [InputPin] [Port]
  • sh upload-analogreadserial-sketch.sh A0 ttyUSB0

The output should look something like this:

Note: Press CTRL+C to exit back to the terminal.

If you get values similar to that then your soil moisture sensor appears to be working.

The potential range of the output is:

  • 0 to 1023 for the arduino compatible
  • 0 to 1024 for the ESP WiFi board

The higher the value the higher the resistance (ie. the more dry it is) and the lower the value the less resistance (ie. the more wet it is).

The value when fluctuates slightly between because of slight changes in resistance in the wiring. These slight fluctuations will always be there and can be ignored and/or averaged out.

Actual values may vary depending on the soil moisture sensor and the wiring, so don't expect values to match exactly as shown above, they just need to be close.

Note: Some types of soil moisture sensors are reversed so will show 0 as dry and 1023 (with the arduino compatible) or 1024 (with the ESP WiFi board) as wet.

Submerge the soil moisture sensor into a glass of water, damp soil, or a damp cloth:

The output should change to look something like this:

If your values are similar when the soil moisture sensor is submerged/damp then it appears your soil moisture sensor is working.

The lower resistance (ie. higher conductivity) results in a lower number, depending on how much moisture and/or how deeply the soil moisture sensor is submerged into water.

It doesn't matter if your values aren't exactly the same as long as there is a significant difference between the values when dry versus when wet (ie. at least 100).

The fluctuations are expected and can be ignored or averaged.