Raspberry Pi as a Weather Underground Personal Weather Station


I live in an area where there isn’t a lot of easily accessible or good quality weather information. A lot of the websites that claim to provide local weather are actually funneling readings from the closest international airport which is 100km away which is not representative.

Weather Underground is a website that integrates all the standard weather sources (airports, governments, etc) with a network of more than 35,000 personal weather stations on a website providing rich weather information. It’s a great website for anyone to quickly check the website, but especially good for hobbyists, pilots, or anyone interested in weather. The company has an interesting history worth reading.

PWS Screenshot

A Personal Weather Station (PWS) is basically equipment setup by an individual to measure the outdoor temperature, humidity, wind speed/direction, barometric pressure, etc. Weather Underground allows for individuals to log the data from their stations on their servers so it’s available to the world and fully integrated into the “weather map.” Lots of companies make off the shelf hardware and software for this, but since the protocols for this aren’t difficult, I thought it would be fun to make an inexpensive station using the Raspberry Pi! The best information about Wunderground PWS’ is on the Wunderground Wiki.


For my weather station, I decided to start with just temperature & relative humidity. In the future I might decide to barometric pressure and wind speed. I based the the project off of the Adafruit DHT Humidity Sensing on Raspberry Pi with GDocs Logging tutorial which I’ll refer to a lot in this blog post. This project is very similar, but instead of uploading the data to a google docs spreadsheet we send it off to Wunderground.

Setup a PWS on the underground website

Before sending any data to Wunderground, you must first sign up for a free Weather Underground account and add then a a new personal weather station to it. Adding a new station basically means telling Wunderground exactly where (geographically) the data they will be receiving is coming from. Once you’ve signed up, here is the direct link to add a new station. Make a note of the station ID of your newly created station.

Connecting the Temp/Humidity sensor to the Pi

I opted for the wired version of the DHT22 temperature/humidity sensor. Wiring it up to the Pi isn’t difficult and requires no extra components (aside from a breadboard or some header connectors). In this photo, the sensor is connected via the terminal block on the right which goes through the breadboard to the cobbler and eventually to the Pi GPIO Port 4.

Raspberry Pi + Breadboard

I extended the cable of my sensor 2 meters so I could place the sensor outside (consult this page for optimal sensor placement).  Although not weatherproof, I liked the housing and that everything was all contained together. At some point I’ll put it into a solar radiation shield to improve accuracy and keep it safe from the elements.

DH22 Outside

The Adafruit post provides a c based driver for polling the sensor for data. Download and get it setup per these instructions. Make sure you can run it from the shell prompt and see reasonable data before continuing.

Uploading the data to Wunderground

Now that you have your sensor connected and functioning, the next step is to upload this data to weather underground. I’ve created a basic script to which reads the sensor using the Adafruit driver, then uploads to Wunderground using an HTTP GET request. A complete explanation of formatting for this request is available on the here on the Wunderground Wiki. You can view the script here or clone my script from github using this command:

$git clone https://github.com/tgreensweig/Raspberry_Pi_wunderground.git

Next, you need to configure the script so it knows which DHT sensor you are using, the time delay between uploads, and your personal weather station account information. Edit the script with and set:

$nano pi_wunderground.py

In order to run, the Adafruit_DHT file (c program that queries the sensor) must be located in the same directory so you’ll need to execute something like:

$cp /path/to/the/adafruit/script/Adafruit_DHT /path/to/the/pi_wonderground/Adafruit_DHT

Now just run it! You’ll need to do it as root due to the Adafruit_DHT so use:

$ sudo python wunderground.py
2013-03-02 09:28:56.141678 - Successful Upload
Temp: 68.9 F, Humidity: 42.1 %
Next upload in 600 seconds

You can now sign into your Wunderground personal weather station and view the posted data. The URL of mine is: http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=IHADAROM2

Running the Wunderground uploader script in the background

For the data to keep updating online the script must be running on your Pi which can be a bit annoying if you want use your Pi for other things. The best option would be to run the script as as service which automatically started with the Pi and I’ll cover how to do this in another post. A workaround, however, is to use the linux screen command. This command allows you to run multiple sessions that persist even after logging off. I’ll explain the basics below but a more complete explanation for using screen is available on this tutorial.

#First install screen with:
$sudo apt-get install screen

#run screen

#run the Wunderground uploader script and wait to see the first measurement
$sudo python pi_wunderground.py
2013-03-02 11:31:21.593304 - Successful Upload
Temp: 71.8 F, Humidity: 35.5 %
Next upload in 600 seconds

#type control-a then push d, this will bring you back to your original terminal
#you can return to the terminal running the script by typing:
$screen -r

For a future post…

  • How to run the script as a service that starts automatically with your Pi
  • How to add additional sensors

Questions? Comments?

Since I may have glossed over some of the basics, let me know if you have any questions or run into any trouble while running through these steps.

Rebooting This Blog

I created this blog a few years ago before to capture my experiences volunteering at the Village Health Works Clinic in Burundi — after the trip it sort of fell by the wayside.

Lately I’ve been increasingly feeling that I’d like to have a place to share everything from my life as a medical student, to my work with electronic medical records, living in Israel, and tinkering with the Raspberry Pi. So, here’s the reboot.

Time permitting I’ll try and backfill a few exciting things from the last few years but not promises! In the meantime, hope you enjoy and find something meaningful for you here.


Hello from Frankfurt

6 days later than expected (explanation later), I am now connecting in Frankfurt en-route California. Although It is good to be back in my world, the world of spotlessly clean granite floors and impeccable German engineering, it does at the moment feel a bit foreign and strange (but I’m quickly getting used to the 3MBit T-mobile Hot Spot).

I am sorry to all for not updating this blog more frequently; the truth is that it’s been on my mind constantly. I cannot count how many times over the past six weeks I muttered to myself, “This moment, right now, is the perfect blog post.” My time in Africa was foreign, fascinating, and full of many moments of realization and learning. I wanted to share each and every one with you and, selfishly, this blog has been a wonderful way to process everything. BUT, two things happened: First, time flew and my work turned all-consuming. Between adopting a few extra projects and ending up a patient in the PIH Hospital in Rwanda (more on all that later, I’m healthy) it just didn’t happen. Second, immersing myself in what is quite literally another world has been emotionally straining and often I wasn’t sure just what to say or how to say it. Not that that’s necessarily changed now, but thoughts are definitely coming together and I am anxious to share them. After all, this trip wasn’t all “heavy” and I can’t remember the last time I had this much fun and wholesome adventure!!!!

Although it may not be as exciting as living my discovery vicariously in real-blog-time, I promise several posts are brewing. Some are summaries, some are commentaries, some are just stories but in the end I think taking the time to process and contextualize will make for better reading.

In the meantime, I have taken advantage of the lighting-fast Internet here in Germany (after 26 hours of uploading and 2 frustrating failures in Burundi) and present to the world, for the first time ever, the Kigutu Waka Waka music video! It’s fun, the dancers are adorable, and it’s probably the best 3 minute summary of my time in Kigutu you’ll get. The video is set to the song Shakira released for the World Cup in South Africa that was so incredibly exciting for us in Kigutu and truthfully all across Africa (I have a great post for this one). The video was created mostly by my fantastic a co-volunteer Brad and I helped bit with some editing.



Thank you everyone for reading (I know the posts are really long) your emails of encouragement. It’s really wonderful to get them and I’m trying to respond as quickly as possible! I’ve been a little under the weather with a cold for a few days but I’ve had a few adventures this weekend and have a couple posts to go up this week.  In the meantime…

  1. I enabled comments on the blog. I’d love to hear from everyone. You don’t need to sign up to leave a comment. Just click the post name (may need to visit www.greensweig.net for email subscribers) and scroll to the bottom of the page that opens.
  2. I got a Burundian SIM card for my (conveniently) unlocked iphone so you can call me. The number is +257.799.04818. The + is the same as 011 if you’re using a landline. I think it’s 14 cents/min on Skype. If I’m near a computer I can always call you back from Skype. You can also text me although I can’t text back.
  3. I’ve been twittering, follow me. http://www.twitter.com/thetobster

Day in the Life

I am living in a residence with about 15 other VHW staff and one other volunteer. Everyone from the security guards to the physicians live here. It’s comfortable but very simple by USA standards. There may be as many as 5 in a room depending on who is here at the time; people tend to come and go back to their homes in Bujumbura or elsewhere. I have my own for now. It has a double bed (unusual) and a bunk bed where I am keeping all of my clothes etc. The bathrooms are at the end of the hall and communal. There are two for men and one for women, reflecting the ratio of the staff. The bathrooms have flushing toilets, a sink, and an ice-cold shower. After 5 days my body is sort of getting used to it; looking on the bright side it is very refreshing and wakes you up even better than the Burundian coffee.

I usually wake up about 6am. Most others get up around this time and we greet each other with “mwaramutse” (good morning). I take a shower and put on a pair of jeans with a tshort or polo (it’s casual here) and head off to the IT room for some email before returning to the residence around 730 for breakfast. Breakfast, like all our meals, is very consistent: Burundian Coffee, Tea, and chapati which are a cross between a tortilla and a pancake (see photo). The coffee is spectacular; and I don’t typically even like coffee.  Coffee is actually one of the few things that this very depressed economy exports and the US Ambassador that I met on the flight explained that the US government has been working on ways for the farmers to directly export and bypass the government “tariffs” meaning more money in their pockets. Apparently Starbucks has taken an interest in Burundian coffee, perhaps one of my coffee connoisseur readers can let us know in a comment. We eat all of our meals in the communal outdoor dining area with an absolutely magnificent view of Lake Tanganyika.  As we are entering ther dry season the morning air is crisp but not to the point of being chilly, quiet except for the buzzing of bees and serenading of the birds. There is no noise pollution from cars or airplanes in Kigutu, only quiet. As we eat and enjoy the view out over the food security garden, the community members and workers arrive in single-file to begin working the garden.

After breakfast I join the doctors for morning rounds starting in the malnutrition ward and working through the in-patient facility and isolation (TB) ward. Depending on who is available, there are between one and tree doctors that go on rounds (Volunteer Muganga Peter from the USA who returned home on Wednsday, Muganga Melino, or Muganga Bazile) as well as several nurses. We see the gamut, everything from malaria, to heart failure, infectious disease, and trauma. Today we had a guy come in who had a hunting spear pass clear through his from the upper part of scrotum out his back about the level of his iliac crest just lateral to the lumbar spine. Miraculously it doesn’t appear that no organs were damaged!  He got initial treatment in Bujumbura but came to us for care of the now infected wound. I’ve been learning about malnutrition treatment regimens and seeing all the medications from PBL cases at LECOM pop up on a regular bases. I’ll write more details about clinical activities in subsequent posts but have been impressed with the personalized attention and compassionate care the patients get. Rounds last about 2 hours for the roughly 8-12 patients, each one getting lots of personalized attention and compassionate care.

While we are on rounds, the patients begin to arrive and the nurses record their vital signs and put them into a numbered line in the breezeway outside the examination rooms. By the time rounds are done there are usually more than 100 patiently waiting. They may wait 3-4 hours to be seen but sit very patiently with their “health passports” (medical records) in hand.

After rounds I head off to work on various projects (more later). Depending on the day of the week, Melino may talk with a group of HIV patients or pregnant women before seeing the patients individually. When I need a break “pop into” the clinic and see a few patients with the doctors which is always interesting and educational. Dr. Bazile, our Hatian medical director, uses a translator to go between the native language Kirundi and French although when I’m presents it’s no problem for them both to switch to English. As a fun fact, Dr. Bazile also speaks Spanish and Creole and plays the guitar/sings in all of those languages.  He is fantastic. Dr. Melino is native Burundian and incredibly dedicated to his patients. He is also great about explaining things to me in flawless English. I have a deal with the docs to come grab me if they see something really interesting; for example today Melino got me to see a 14-year-old boy with Mumps.  He presented with bilateral parotitis but fortunately for him no orchitis which is inflammation of the testicles that accompanies about 30% of cases. I can’t say that mumps would have been high on my differential diagnosis but it was a good reminder that here in Burundi many children are not vaccinated as we are in the USA.

By about 12:30 the cooks have lunch ready and usually I’m pretty famished. It’s either rice and beans or on special occasions they will serve beans and rice. (that was a joke). Sauce and potatoes also come with every meal. At least you never have to wonder what’s for lunch (or dinner for that matter).

After lunch it’s back to work. More details to come in subsequent posts but last week was very productive. I spent most of the week analyzing the solar power consumption and expanding our network, moving the IT room to the community center, and starting the transition to google apps (a private-labeled version of gmail, google calendar, etc that is free for non-profits but usually quite expensive).

The sun sets here around 630. I have a rule that I always go watch the sunset by the water tower that supplies Kigutu (courtesy of VHW). There are benches up at the top of the hill above the clinic I’ll either go alone or sometimes with others. It’s a very peaceful and beautiful spot to go and decompress and think, usually needed after a day in Kigutu.

Dinner is at 8, no need to elaborate. Reading then bed around 9-10.

Dr. Melino Group Pregnancy Consultation

Malnutrition Patient in a new Walmart Shirt

Dr. Bazile on Rounds

Hospital Food for Malaria Patient

About to be Discharged from the Malnutrition Ward

Dining Area

My Room


Heart Failure

Breakfast Chapati