Get Growing Blog

The Joy of Coding: Raspberry Pi edition

August 14, 2020


When I decided that I wanted to pursue a career in ecological research and education I knew that there were a lot of new skills that I was going to learn as I obtained my bachelor’s degree and eventually a PhD. I knew I was going to learn how to develop questions, and design research experiments. Although I learned those things during my journey to becoming a postdoctoral researcher, there were many skills that I also developed that I had never even thought would be necessary. Some of those things include how to develop and maintain collaborations, how to convey results through presentations and publications, the publication process, and perhaps the most surprising to me was learning how to code. Learning how to code was not only surprising, but empowering! Once I began coding I was hooked and now use it for all sorts of applications. The main thing that ecologists use coding for is to analyze data in an open source program called R (see Juliana Medeiros post on the topic!). However, coding can also be used for many other things.

In my current project I am using coding and a device called a raspberry pi to collect micrometeorological data at the Leach Research Station in Madison, OH. I needed to get fine scale data for my experiment on the effects of drought on eastern red cedar plants from different populations (see more here!). The reason I needed to do this is because we constructed a rain out shelter over the plants, which is known to increase the temperature and the humidity compared to outside the shelter. I wanted to be able to record the exact conditions the plants were experiencing, so using a local weather station was out of the question. Using the raspberry pi I was able to install a number of temperature and humidity sensors to monitor the conditions, and also install 12 moisture sensors to monitor my drought treatments to make sure they are dry, but not so dry that my plants die. I’m able to do all this thanks to my raspberry pi.

Not your mom’s Raspberry Pi

Often when I talk about my raspberry pi telling me about the weather I get some odd looks, until I explain that a raspberry pi is a micro computer. The raspberry pi can do just about everything a desktop computer can, but it is the size of a credit card and at less than $100 it costs a fraction of the price! Just hook up a monitor, keyboard, mouse, and an internet connection and you can surf the web, watch videos, make spreadsheets, even play video games. While all that is impressive I was drawn to the raspberry pi for its ability to interface with all sorts of different electronics, just google raspberry pi projects and you can see videos of kids building robots, automated gardening systems, DJ systems, and gaming consoles. I thought I could utilize the pi to build a system to monitor the environment for my experiment and give me fine scale data. Although there are plenty of prebuilt systems that you can purchase to do this, they are considerably more expensive, are less customizable, and way less fun!

Making my Pi

The first step to setting up my system was coding the programs that I needed to get the information from the sensors to the pi. Through lots of trial and error I was able to successfully obtain the environmental data from the sensors and then save it to a file with a timestamp on the pi that I could later use. Most of this work I did socially distanced in my home office; it is much easier to code on my monitor then the 7” screen that I use when I am working in the field. Once I had the code ready I started installing the sensors in the field. The nice thing about the setup I made is that it is fully customizable and I can install as many or as few sensors as I would like, I was even able to add some light sensors after one day I realized I should also be recording that. Ten dollars later I had two sensors installed with just a minor change in my code. The bad thing about it being so customizable is that everything is built from scratch, but this did mean I got to work on my wire crimping and soldering skills!

I’m happy to report that as you read this I have two raspberry pis (I’ve named them apple and rhubarb) silently collecting data out in Madison, letting me know when the plants need water and how hot and humid the day was!

Moisture and temperature/humidity sensors installed. A close up of the moisture sensor is on the left, nail polish and silicone caulk are used to waterproof the electronics, and on the right is a temperature/humidity sensor located above the plant canopy.

The two pis installed and collecting data. “Apple” is on the left and “Rhubarb” is on the right, both are collecting soil moisture, temperature, and humidity data for different sets of plants. Having two pis installed makes sure that I don’t lose all of the data if something happens to one of them.

Here’s more to explore

View all

What can we help you find?

Return to site

Debug info for popularity tracking: Disable within popularity-tracking.php file once ready.

Time: 1716249600 / Saved: 1716249600

Views (7 day(s) ago): 1

Views (6 day(s) ago): 3

Views (5 day(s) ago): 1

Views (4 day(s) ago): 2

Views (3 day(s) ago): 1

Views (2 day(s) ago): 1

Views (1 day(s) ago): 1

Views (Today): 3