15. Soil Moisture Sensor¶

15.1. Introduction¶
Soil moisture sensor uses capacitive sensing to detect the moisture level of the soil. Whenever there is water across two areas of the capacitor, the sensor can detect moisture level. The moisture reading is from 0 to 100%.
15.2. The principle¶
Soil moisture sensor has an exposed capacitor on it. Capacitor consists of a positive plate and a negative plate. When we insert the sensor into the soil, the soil becomes the dielectric medium.

Capacitor can store electrical energy in an electric field by accumulating electric charges on two plates. The ability of the capacitor to store charges is known as capacitance.
As water with higher permittivity than air, it polarizes more than air in an electric field. When the soil is wet, the capacitance rises.

By measuring the changes in capacitance, the soil moisture level can be obtained.
15.3. Specification¶
Supply voltage: 5V
Interface: Analog
Raw value return: 0-1023
Makecode Extension return: 0-100%
15.4. Pinout Diagram¶
| Pin | Function |
|---|---|
| G | Ground |
| V | Voltage Supply |
| S | Output |
15.5. Outlook and Dimension¶
Size: 35mm X 70mm
15.6. Quick to Start/Sample¶
Connect the soil moisture sensor to development board (using wire)

Open Makecode, using the https://github.com/SMARTHON/pxt-smartplant PXT

Initial the OLED screen and show the reading of the soil moisture level

The value will be in range of 0 to 100
15.8. FAQ¶
Q: Why does the sensor still have low reading after I watered the plant?
A: Sensor in contact with the soil can take more accurate soil moisture reading. Please check if the exposed capacitor is covered by soil.
Q: Can I use the sensor to detect moisture levels of other mediums?
A: The sensor is designed to detect moisture level in soil only. It is not applicable in other cases.

