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 hydroponics and to build the simple wicking planter used in this project, visit https://makershare.com/projects/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.The SparkFun weather:bit
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.Coding the micro:bit
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.
You will need to add the weather:bit package from the Extensions menu. Simply search for weather:bit and install.
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.
To give a visual display on the micro:bit of the overall health of the system, I set it to show the "happy face" icon if all conditions of "check" we met and a warning face if they weren't. You can, of course, set as many levels as you want using whatever display makes sense for you.
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 download the complete code at https://makecode.microbit.org/_Fu25KLcujY15
Sadly the conditions in my library makerspace weren't so great for my lettuce. Maybe it's time to build a mini greenhouse!
(UPDATE: I have published a version of the code that simple scrolls through the reading and then shows the conditions symbol. Download the code at https://makecode.microbit.org/_K6W6R5U8399D
And if you are looking for lots of fun, hands-on maker projects for your club, camp, school or library, please check out my book The Big Book of Maker Camp Projects (McGraw-Hill/TAB)