Soil Moisture Sensor for micro:bit
Step by Step Instructions
- Connect the two pins on the YL-69 probe to the connectors at the top of the YL-38 module board.
It doesn’t matter which way you make these connections.
- Connect GND (0V) on the micro:bit to GND on the YL-38
- Connect PIN 2 on the micro:bit to Vcc on the YL-38
- Connect PIN 3 on the micro:bit to A0 on the YL-38
PIN 2 is used to turn on the circuit so that a reading can be taken.
PIN 3 is used to read the analogue signal from the sensor. This is a voltage that is high when the moisture content is low and lower when the moisture content is high.
- Using your preferred editor, type or copy/paste the code and flash to the micro:bit.
- In our example we have used both a breakout board for the micro:bit and a prototyping breadboard to make the connections. In theory you could connect the sensor directly to the micro:bit using crocodile clips but this is likely to be unreliable in practice.
- Add code to query the last reading taken when button A on the micro:bit is pressed.
- Store the last 5 readings and present these as a bar chart using the LEDs on the micro:bit when button B is pressed.