Micro:Bit Soil Tester
Author: Max Date Posted:13 November 2017
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.
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.
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.