Soil Moisture Sensor for micro:bit

by | Aug 23, 2017 | 0 comments

This project uses a moisture sensor to create a simple device to warn when soil becomes too dry.

Language: MicroPython

Concepts: displaying images; using digital & analogue pins

Requires:

  • BBC micro:bit
  • YL-38 YL-69 moisture sensor
  • Connecting wires

Optional:

  • Prototyping breadboard

Step by Step Instructions

Step 1

  • Connect the two pins on the YL-69 probe to the connectors at the top of the YL-38 module board.

Notes

It doesn’t matter which way you make these connections.

Step 2

  • 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

 

Notes

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.

Step 3

  • Using your preferred editor, type or copy/paste the code and flash to the micro:bit.

 

Notes

  • 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.

 

Further Development

  • 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.

0 Comments

Submit a Comment