Raspberry Pi Weather Station

My first longer term project, begun over a year ago, was my Raspberry Pi weather station. It began as an Arduino-based weather station. The goal was to measure various weather variables using sensors, store the data, and then send it somewhere. I teach a high school course called Earth and Space Science, which includes a unit on the atmosphere and weather. Wouldn’t it be great to have a class weather station to use for data collection? Since I was learning about Arduino programming at the time, I spent a considerable about of time building a custom hand-soldered shield for the UNO and writing code for it. But in the end, the limited flash memory and ram of the Arduino (ATMEGA328P), together with connectivity issues, made the end result unreliable. I was grabbing several libraries to read the sensors, as well as log to an SD card, AS WELL AS sending http get requests over wifi with a CC3000 shield. It was too much, and it didn’t work for more than a few hours without freezing up. I set it aside for some months.

The project was resurrected when I took up learning about the Raspberry Pi and coding with Python. The limitations of the simple 8-bit Arduino microcontroller are handled nicely by the more capable Pi system-on-a-chip. With a simple wifi dongle, I could connect to my home network without problems. I soldered a small bit of perf-board to plug into the Raspberry Pi Model B GPIO pins. The pressure sensor is wired directly to board, which is inside the enclosure. Since the air pressure would equalize between the inside and outside of the stations, I didn’t need to get the pressure sensor outside. The temperature/humidity sensor and light (lux) sensors are plugged into header pins on the perf-board so they can be both strung outside and unplugged as needed.

Components:

Code:

I played around with building my own web service, but went instead with the free personal weather station page provided by Weather Underground. Once you create an account and register your station, you can upload your sensor data using this simple protocol.

Here is my working code (with my own station id and password removed). It is set to run automatically at boot with an entry in the Pi’s crontab. (I’ll let you google how to autorun scripts in Linux. Have fun!)

Enclosure:

I used PVC conduit boxes and pipes from the hardware store to weatherproof my station. The power adapter is in the lower box to keep extra heat away from the board and sensors. The exterior temperature is taken at the end of the bending pipe and hood, protected from rain. The Raspberry Pi core is in the top box. The bending pipe is to prevent any blowing rain or snow from getting to the Pi. I even drilled holes in bottom of the “U” section to allow any collected moisture to drip out. After over a year outside in harsh Minnesota weather, I have had no problems with moisture.

I have just two minor problems with the design as it currently stands. Every once in a long while the Pi freeze and stop transmitting. I have to unplug the station to get it to reboot (SSH won’t let me in). This is only once every 1-2 months. Also, my station does not have a proper radiation shield, making it sensitive to direct sunlight. I have placed it in the shade of a large tree, but I still see spikes in my temperature data when sunlight hits it. -DF

Images:

weatherstation_side_farweatherstation_side_near

weatherstation_powerweatherstation_pi

weatherstation_pressure

weatherstation_light_inside

weatherstation_light_outside

weatherstation_humidity_outside

weatherstation_humidity_inside

About Dan Fisher

A physics teacher and father of four who likes to build things. Interests include: science, Arduino, Raspberry Pi, education, avr-gcc, engineering, piano, and chickens.
This entry was posted in Projects and tagged , , . Bookmark the permalink.

Leave a comment