Approved content

The content below is provided by a partner.

sparkfun/pxt-gator-soil 1.1.2 GitHub

gator:soil Soil Moisture Sensor

Community Discord

The gator:soil, which can be used to read the moisture of soil can be purchased here.

SparkFun gator:soil

SparkFun gator:soil (15272)

To use this extension, go to https://makecode.microbit.org, click Extension and search for gator-soil. The extension is located here

Basic usage

//Grabs moisture from the sensor connected to pin P1, powering it using pin P0 to avoid corrosion on the moisture sensing leads.
gatorSoil.moisture(AnalogPin.P0, gatorSoilType.soilMoisture, DigitalPin.P1)

Use ||Get moisture on pin P0 in adcVal using power pin P1|| to read the moisture value either as a value between 0 and 1 or the straight ADC value.

Example: Moisture Sensor

//Read moisture value and write to screen every 60 seconds
serial.redirectToUSB()
basic.forever(function () {
    serial.writeLine("Moisture: " + gatorSoil.moisture(AnalogPin.P0, gatorSoilType.soilMoisture, DigitalPin.P1))
    basic.pause(1000)
})

Supported targets

License

MIT

gatorSoil=github:sparkfun/pxt-gator-soil
gatorSoil=github:sparkfun/pxt-gator-soil#v1.1.2