You can use MakeCode block programming with the micro:bit and the Soil Moisture Sensor. You'll create blocks that read the output from the sensor and show a happy face or a sad face on the LED matrix depending on the moisture level in the soil.
- micro:bit 3V to sensor 3V (red wire)
- micro:bit GND to sensor GND (black wire)
- micro:bit 0 to sensor OUT (white wire)
In the code setup, the text "Hello Soil Sensor!" scrolls across the LED matrix display. Then in the loop, the analog moisture value is read every 5 seconds. If the moisture level is greater than 200, the LED matrix shows a happy face. Otherwise, it shows a sad face, letting you know that the soil is dry.
Once you're happy with the code, you can create a MakeCode project by clicking the floppy disk save icon. Name your project and then click Create.
Clicking Create downloads the code as a compiled HEX file to your computer. You can also upload the code using web USB. Click the Pair Now button to begin.
Connect your micro:bit to your computer with a known good data micro-B USB cable. Once you're connected, click Pair.
A window will pop-out showing the available USB devices. Select the BBC micro:bit and click Connect.
Page last edited July 09, 2025
Text editor powered by tinymce.