Use the mico:bit in combination with SparkFun sensors to monitor the health of your hydroponics planter.

After making upcycled hydroponic planters with my makers, I wanted to play with ways to monitor their status. I used the weather:bit by Sparkfun and a micro:bit to check air temperature, growth media temperature, humidity and growth media moisture level. The goal is to create the best possible conditions for the germination of my seeds and the health of the plants.

For more information about hydroponic and to build the simple wicking planter used in this project, check out my Upcycled Hydroponics Planter at
http://www.kaleidoscopeenrichment.com/upcycled-hydroponics-planter/ .

If you’ve ever done any gardening, you know how important temperature and moisture can be to get good germination of your seed and maintain the health of your plants. That’s even more important when working with hydroponics, where too little or too much water can quickly kill your plants. 

Over the winter I played with the SparkFun micro:climate kit, which uses the BBC micro:bit and their own weather:bit to measure temperature, humidity, barometric pressure, wind speed, rain accumulation and more. Because the ground was frozen I never had the chance to try the soil sensors — one for soil temperature and another for soil moisture levels. I thought my hydroponics planters would be the perfect opportunity to try them out.

I connected the sensors to the weather:bit as described in the experiment guide. It was easy to do. Then I added the weather:bit extensions to MakeCode.

From there it was just a bit of coding. If you have never used MS MakeCode, give it a try. It’s a free visual language that allows you to code and simulate various microcontrollers, like the micro:bit. MakeCode makes hands-on computer easy for everyone.

On start we begin weather monitoring. Then were create the variables “item” and “check”. Set them both to 0. Item will track what data you want to read on the micro:bit LED screen — air temperature, humidity, soil temperature or soil moisture. Create variables for each of those as well. Then use the “on button pushed” block to change the “item” variable by 1 to scroll through the data the mico:bit collects. Set button B to reset “item.”

Then we create a Forever loop in which the weather:bit collected data every two seconds. You have to divide the collected temperature data by 100 to get the correct temperature in Celcius. To get the relative humidity, divide by 1024.

The check variable is used to see what of the weather measurements are within an acceptable range for the best growth. You’ll need to research what the best conditions are for your plants. In my case, I’m growing lettuce. For each measurement that is within range, “check” is changed by 1. If all is well, the total value should be 4. Anything less will change the display on the mico:bit. Then it waits two seconds, sets “check” back to 0 and checks the conditions again.

Lastly, we need to code the display. The “item” variable is used to decide what information scrolls across the screen. Each click of the A button increases “item” by 1 and moves to the next data. A string shows what the data label is and then the variable itself is displayed as a number. When “item” is 0, it displays the results of our data checks.

Save and download the code and flash it to the micro:bit. Place the soil moisture sensor and the temperature probe into the growth media of the hydroponics planter. If all your plant’s needs are being met, the micro:bit will smile. If not, you’ll see an alarmed face. Press the “A” button to switch between air temperature, humidity, soil temperature, and soil moisture.

You can view or download the complete code below or on MS MakeCode at: http://www.bittysoftware.com/tutorials/bitty_data_logger_makecode.html 

Sadly the conditions in my library makerspace weren’t so great for my lettuce. Maybe it’s time to build a mini greenhouse!

Share this post!


  1. Nadium - Reply

    Will you plz tell me what kind of water should I use for a hydroponics system? There are different kinds of growing methods to use for aquaponics. Which one is best?

Leave Comment

Your email address will not be published. Required fields are marked *