Micro:Bit Soil Tester

Author: Max   Date Posted:13 November 2017 

Micro:Bit Soil Tester main image Micro:Bit Soil Tester image

The Micro:bit is a very versatile, multi-use tool. It is small and does not look flashy, however, it has so many uses that the only limit is your imagination! It can be used to create and play games, to care for a garden, to interact with a mobile device, and so much more. Micro:bits contain 2 buttons labelled A and B, a 5x5 red LED matrix, 3 pins labelled 0, 1 and 2, and 2 pins used for grounding, and power output. The makers of Micro:Bit have a website wherein one can find Python and JavaScript Block Coding tools and Cool project ideas and coding challenges. The possibilities are truly endless!

 


To make the Soil Moisture Testing project, you will need:

  • 1 micro:bit with battery pack and batteries
  • 2 long nails
  • 2 crocodile clips

Firstly, code the Micro:Bit with the following:
 

Secondly attach one alligator clip to the 1 pin and the other to the 0 pin.
Then, attach the nails to the other ends of the crocodile clips and push these into the soil.
Lastly, just power it up with the battery pack.
Done!

Explanation:

In the soil, the nutrients carried by water act as a conductor. This shows that, if there is a higher level of water, the soil will be able to conduct more electricity. So, if we were to put an electrical current into the soil, and read the current that is picked up at another point in the soil, we can measure the resistance and, therefore, the moisture within the soil.
 

This code tells the Micro:bit to output power, of value 1023, through pin 1. Then, it says to record the 'reading' value as whatever value is being read by pin 0. It then concludes by telling the Micro:Bit to output power of value 0 through pin 1, which is nothing.

This section of code simply tells the Micro:Bit to display a bar graph, on the LED matrix, of the value of 'reading' ,which was set in the previous section of code (with the highest possible value displayed being 1023)


This commands the Micro:Bit to wait 5000 ms before proceeding with the "forever" section of code. This brings the power consumption down by preventing the Micro:Bit from constantly running.
 

This tells the Micro:bit (upon starting up) to set the LED brightness to the value 64. This section of code brings the power consumption down by brining down the power used by the LEDs.

This last section of code tells the Micro:Bit to display the value of 'reading' whenever the button A is pressed.
 

EXTRA:

This code can be extended to not only measure soil moisture but also then water the plants in the soil, or even send the data to a mobile device.