Raspberry Pi Greenhouse Temperature Sensor Project

marni brewster
Zera Farm
Published in
5 min readAug 8, 2018
“Where are the worms?”

I became a farmer last year. This year, winter decided to stick around until May. In an attempt to start some vegetable and flower seeds before June, I purchased a small greenhouse on Amazon. Knowing that we wouldn’t be able to heat it, I wanted to see if any of my experiments using alternative heating methods would work.

NERD ALERT: An example of something my dad does in his free time: an arduino water level for home construction projects.

GETTING STARTED WITH ARDUINO/RASPBERRY PI

I took an electronics course during my time as an undergraduate Physics student. I had also played around with circuits as a girl, thanks to my parents. My dad is a scientist and my mom was a maker. They did everything themselves. My dad hacked the windshield wipers of our stick shift Toyota Tercel with an intermittent feature. My mom made her own down jackets and wetsuits.

As an adult, I’ve played with Arduino and Raspberry Pi for pleasure projects. Most recently, I have had our Pi set up as a RetroPie so that we can play my favorite Nintendo games.

If you’re interested in getting started, there are SO MANY tutorials, books, and courses online and in print. My local library has a slew of books, but for beginners check the kid’s section of the library for Arduino, Raspberry Pi, or anything about Makers. Check the Meetup app for Makers meetups, robotics meetups, or other similar meetups near you where beginners are welcome to watch and learn as circuits and Internet of Things devices are created and hacked. Find out if there are maker spaces in your town. Involve your kids, if you have them! (Ask the meetup organizers if kids are welcome).

EQUIPMENT

The actual circuit was very simple.

I ordered a temperature sensor from Amazon, grabbed my Raspberry Pi, and got to work scouring Google for tips on how to get the right operating system set up on the pi. I had traded some handmade puppets for a Kano kit from a friend a few years ago, so I knew my older Pi might present some challenges.

PLAN

I knew that I wanted to send the temperature data to a cloud database, and then create a React Native app to view/retrieve the data. I own an iPhone, and my partner has an Android. I wanted to get some experience writing a React Native app from scratch, for my own purposes, after having made some apps via online tutorials. I generally retain more information about something when I build it myself from scratch, or break it and attempt to rebuild it. This was a good lesson in figuring out what the problems were that I was trying to solve, and figuring out how to Google for the solutions.

DATABASE

I chose a Firebase database because I have some experience with it, and it is super easy to get up and running quickly. For this type of non-relational data (time and temperature), I felt it was a good solution.

Spoiler alert: I didn’t freeze ALL of the plants.

TUTORIALS THAT HELPED

I used this tutorial from Firebase to help understand how to integrate the database into a React Native app.

I used this tutorial on Firebase IoT to understand what Python code I would need to grab the temperature data and send it to my database. I got all of this set up, but quickly realized the Pi was dropping its WiFi signal and getting dropped from my local internet network. It wasn’t smart enough to reconnect on its own. This code for automatically reconnecting to the WiFi was a godsend! I set up the code to check for internet connection every few minutes. If the internet was connected, it ran my Python script to grab the temp data and send it to the database. Otherwise the Pi would attempt to reconnect to my WiFi network! It was good to get experience with shell scripts as well.

The extent of the React Native app I made: a simple view of temperature data to see how low and high the extremes are.

After some research and sandboxing, I determined that Victory was the best solution for my basic graph needs. I wanted the quickest, easiest implementation of a simple time vs. temperature graph. I found their docs easy enough to work with and implement!

RESULTS

The results of my experiment’s data were quite frustrating. The hay bales we used along the inside of the greenhouse did not dramatically improve the overnight low temperatures. The homemade heating mats we made did not increase the soil temperature above the ambient temperature. The large containers of water that we put in the greenhouse did not improve the ambient air temperature overnight. During the day, the heat in the greenhouse was great. But the soil temps were (almost) exactly the same inside the greenhouse as outside regardless of our attempts.

CONCLUSION

Not a complete waste of energy/time :)

This was a great experiment regardless of the results. That is because it really pushed me to solve technical problems that would help me with a practical problem on our farm. Moving forward, I realize that we will need a more traditional heating solution if we hope to do much greenhouse growing. Most importantly, however, I feel empowered to create and analyze our attempts at problem solving. I was able to figure out all of the hurdles that I needed to clear. I didn’t always know WHAT to google, or what the specific issue I had was. But I slowly figured it out!

MOVING FORWARD

If we were not a mixed-platform family, I would stick to writing this app exclusively in Swift. I think I’d like to make a more comprehensive Farm Management app for our family. It would help to keep track of which farm chores are done and which still need to be accomplished on a daily, weekly, monthly, seasonal, and yearly basis. I’m sure there are apps out there that would solve our particular problem, but I think it’d be interesting to create administrative roles for kids and the jobs they’re able to accomplish, and somehow tie that into our rewards system. For example: Daughter B finishes her 2 chores for the day, marking them off on the app on her device. This would trigger a request for approval from a Parent. Upon approval, that child would either receive her daily allowance into her bank account, or screen time! Everyone would know what chores are still outstanding for the day, week, and month. And no one would ask, “I’m bored, what can I do?” or, “How can I earn some screen time?” or, “Did you feed the ducks this evening?” (Can you tell my kids have been home and bored this entire summer?!)

There are always new chores that need to be taken care of, and this switches with the seasons of the year, and the animal’s ages, and kid’s ages.

Little chicks require lots of attention, multiple times per day.

Advertising Disclosure: Zera Farm will earn a commission if you click on affiliate product links and make a purchase using the link.

--

--

marni brewster
Zera Farm

software developer, farmer, and maker with a degree in physics.