Soil Moisture Sensor ==================== .. figure:: /_static/products/ledong-module/static/images/soil_moisture_sensor.png :width: 55% :align: center Overview -------------------- Can be used to detect soil moisture. When the soil lacks water, the sensor output value decreases; otherwise, it increases. Technical Specifications ------------------------ Operating voltage: VCC 3.3V -5V Mounting: 2 screw holes Data type: Analog sampling value Pin Definition ------------------- ======= ==================== Pin Definition ======= ==================== GND Ground VCC Power AO A nalog sampling value NC Not connected ======= ==================== Example Code ------------------- **The AO port outputs an analog value. Insert the probe into the soil, then use the main controller's AD converter to read the AO pin. The greater the soil moisture, the greater the AO output.** **The mPython Board OLED display shows the soil moisture measurement value. When the measured value is less than 2000, the mPython Board RGB LED lights up.** .. code-block:: python from mpython import * from bluebit import SoilHumiditySensor soilHumidity_0 = SoilHumiditySensor(0) import time while True: oled.fill(0) oled.DispChar(str(str('Soil moisture: ') + str(soilHumidity_0.get_raw_val())), 0, 0, 1) oled.show() if soilHumidity_0.get_raw_val() < 2000: rgb.fill((int(255), int(0), int(0))) rgb.write() time.sleep_ms(1) time.sleep(1) else: rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) .. figure:: /_static/products/ledong-module/static/examples/soil_moisture.png :width: 100% :align: center