Science Oxford Logo

Adding a moisture sensor

Pins 0, 1 and 2 on the micro:bit can be used to sense when a connection has been made.

By putting things connected to those pins into a conductive material, you can measure how much current is passing through it.

This property can be used to sense how much moisture is in something.


You will need:
  1. Connect one end of one clip to the pin labelled GND.
  2. Connect the other end to one of your metal implements.
  3. Connect one end of the other clip to the pin labelled 0.
  4. Connect the other end to your second metal implement.
  5. Push your two metal implements into the soil, so they are not touching each other.
photo of connections

Work out what value your micro:bit is reading right now, then think about what problems you could solve by monitoring moisture levels!

Building your program

on button pressed vs if button pressed

These two blocks of code are equivalent.

The one on the left is good for quick testing.

The one on the right is more useful to us, because you can use it to build more complex programs.

analog read pin means that you will get a number between 0 and 1023.

What can you use this for?

As well as your Inputs, the blocks you need for this are in the Logic menu, and the Advanced-->Pins menu.

As well as the Conditionals in the Logic menu, you can combine Comparison and Boolean blocks to make a really interesting program!

What problems could you solve using a moisture sensor?