Raspberry Pi Internet Weather Station




Introduction: Raspberry Pi Internet Weather Station

About: Founder of Powerhouse Electronics. For more info goto: www.jimk3038.com

*** Update ***

This Instructable has fallen out of date. The weather services for the weather data, used in this Instructable, no longer work. HOWEVER, there is an alternative project that does basically the same thing (only better - this Instructable was always just a hack). So here is the link you will want to follow:


Thank you so much go to Gene Liverman at PiWeatherRock for take Up the mantle on this project.

This Instructable will show you how to build a really cool Raspberry Pi Internet-based weather station. Actually, to call this build a "weather station" is a bit of an under statement. This build could easily be extended to provide much more than simply the weather. However, it's a good start and it looks really cool on my desk.

Our family (OK, mostly me) has enjoyed having the family iPad on the kitchen counter, when not in use, quietly showing the current outside weather conditions. However, it's a pain to load and unload the iPad in and out of the arcade cradle case. Plus, just when I go to look at the weather, I discover someone has taken the iPad / weather display. What's needed is a permanent counter-top display that the kids are not going to swipe like the iPad.

Step 1: Gen 1 - the Lunchbox Pi Weather Station

My first thought was to use a little composite video display. I picked up the one in the picture on Ebay for $22 bucks - simply search on "4.3 Inch TFT LCD Car Rear View Monitor Car Monitor". The display has a reported resolution of 656 by 416 pixels which defiantly makes displaying a lot of useful information a challenge! The display requires 12Vdc as the supply voltage. The Raspberry Pi, of course, needs 5Vdc as the supply voltage. To resolve this, I bought a cheap USB car charger from Amazon. For around $6 bucks I found a 5Vdc by 2 Amp car changer. Therefore, the lunchbox has an external 12Vdc wall wart power supply. The 12Vdc powers the display directly. The 12Vdc also goes to the USB car charger which steps the voltage down to a regulated 5Vdc. As a final hack, I soldered a pair of wires directly between the car charger and the Raspberry Pi - not my best idea.

While it all kinda worked I was not really satisfied with the quality of the video on the composite display. The small font on the display was more fuzzy than I would like. Plus, while the lunchbox at first seemed cute later it seemed kinda cheesy.

Step 2: Gen 2 - HDMI Monitor + Laser Cut Plexiglass Arcade Case

Back on eBay I found a nice looking $54 dollar HDMI open frame monitor with a resolution of 800x600. By definition, an open frame anything needs a frame to mount in. Since the cuteness of the lunchbox was long over it was time for some laser cut acrylic. My local hacker space i3Detroit has a really nice 150 watt cutter that can make mince meat of 4.5mm acrylic.

I loosely based my arcade enclosure on the iPad arcade box. If I ever make a Gen 3 design it would defiantly include a removable / slide out tray for the Pi. Turns out, it's a major pain in the neck trying to plug things in and out of the Pi since there is not much room between the Pi and the side walls.

The HDMI monitor also requires a 12Vdc feed. So, I used the same trick of using a USB car charger again. This time, however, I chopped up an old USB cable so soldered wires on the Pi was not required.

If anyone is interested in the arcade case post a comment below and I'll upload the DXF files. Or, the files are on my web site at ph-elec.com.

Step 3: Pi Setup

To setup a new Raspberry Pi with the needed software is not that hard. All the software is written in Python with just one added Python module. The extra Python module is called "pywapi". Here is a link where you can download the module. This module makes it easy to get real-time weather from either Yahoo, Weather.com, or NOAA.

First things first, here is a checklist to setting up a raw Raspberry Pi:

  1. Download the latest Raspbian (Debian Wheezy). Unzip to obtain a .img file.
  2. Write the to a SD card with "dd bs=4M if=2014-09-09-wheezy-raspbian.img of=/dev/sdb"
  3. The dd command takes about five minutes. When complete, run "sync" to flush the pipes.
  4. Install SD card in the Pi and reboot. Make sure there is an Ethernet connection to the Pi.
  5. Using the "Attached Devices" page on the router, find the IP address of the new Pi.
  6. Login to the Pi using "ssh pi@192.168.1.???" where ??? is the IP number from above. Password will be "raspberry".
  7. On the Pi, use the command "raspi-config" to setup defaults.
    1. Turn on automatic boot into the GUI.
    2. Set the host name to something like "MyPi".
  8. Install VNC on the Pi with "sudo apt-get install tightvncserver".
    1. Run "tightvncserver" which sets the password.
  9. Back on the big Linux box, use "Remote Desktop" to view the Pi GUI desktop.
    1. Set Protocol to "VNC" and IP number to "192.168.1.???:1". Note the ":1" on the end of the IP number.
    2. Hit the connect button and supply the VNC password.
    3. Bingo, remote GUI Pi desktop!
      1. This saves dragging out a monitor, keyboard, and mouse to connect up to the new Pi.
    4. On the desktop, run the WiFi setup icon. Setup the new Pi / USB WiFi to connect to the network.
    5. Close the VNC connection - we're now done with remote desktops.
  10. Back in the ssh window, reboot the Pi with "sudo reboot". Disconnect the Ethernet cable since the WiFi is now setup.
  11. Back on the home router, find the new IP number the Pi is using with WiFi.
  12. Using ssh, log back in using the new IP number. This time the connect will be over WiFi.
  13. Using the Files Manger on Linux, connect to the Pi using the "connect to server" command.
    1. The server address is "sftp://192.168.1.???/home/pi".
  14. Basic setup complete.

Next, the pywapi needs to be downloaded and installed. Again, this is not too hard with the following steps:

  1. Download the latest from here. Extract the archive into a new directory.
  2. Using File Manger, copy the directory to the Pi home directory.
  3. Using ssh, do the following on the Pi:
    1. cd pywapi-0.3.8
    2. sudo python setup.py build
    3. sudo python setup.py install
  4. Done.

Update, I forgot two mention two other things:

  1. On the Pi run the following command:
    1. sudo apt-get install avahi-daemon
      1. This allows connecting to the Pi by name. So, on your main computer you can connect as "ssh pi@MyPi.local" instead of using IP numbers. With multiple Pi's on the network it's easy to get them confused unless called out by name.
    2. sudo raspi-config
      1. Look for and run the 4th option called "Internationalisation Options" and set your timezone.
      2. With the timezone set and ntpd (network time protocol daemon) running the Pi will always display the correct time to within a couple milliseconds! Gotta love it.
  2. OK, now we're done again.

Step 4: Source Code

All the source code for this little weather display is based on Python, PyGame, and Pywapi. All open source / free software.

PyGame is used to do all the GUI stuff. Really amazing stuff. Using PyGame, the entire display is rebuilt once per second. Near the top of my source code you'll find a section that allows tweaking for different display sizes. There is one section for the small composite video display and a second section for the larger HDMI display. I simply comment out one of the two sections based on the display size I need.

To get my source code running just unzip the attachment and copy the whole directory onto the Pi using File Manage. Once copied, start the code use the following ssh commands:

  1. cd Weather
  2. sudo python weather.py

The sudo command is needed so that Python can control / read the GPIO pins. There is probably some way around this restriction but it eludes me.

Once everything gets working using ssh it's time to get weather to start automatically on a reboot. This is also really easy to do.

  1. Using ssh, run "sudo vi /etc/rc.local"
  2. Just before the last line, which says "exit 0", add the following to lines.

    1. cd /home/pi/Weather
    2. sudo python weather.py &> err.log

This will automatically start the weather application on the Pi after a reboot. If later you want to turn this off, just use ssh to edit the file and add the comment character "#" in front of both lines and reboot.

Note, my source code is a big hack and I'm not very proud of it. However, if I waited until it was presentable it never would be presented. So, take it or leave it just don't cry about as I have a very thin skin.

A couple of other things to note about my code. Buried down in there you'll notice some code to talk to an X10 device. This was my attempt to control my outside pole lights that are on address A3. I simply wanted the lamps on at dusk and off at dawn. Seems easy enough and I thought I had it working. Using a USB-to-RS232 dongle on the Pi I had connected a CM11A X10 module. The CM11A is an old X10 macro module. The CM11A also has a RS232 port that allows control over the X10 bus. Seems there are still some bugs because the lamp pole lights aren't getting the message!

Also of note, on the larger display there is a nice open gap along the right hand side of the display. My plan is add some status lamps in that area. I'm playing with some IEEE802.15.4 radios and their outputs will one day show up in that open spot.

For the latest and greatest updates please visit my web site at ph-elec.com.

Well, let me know in the comments section below any questions you may have.

Thanks, Jim.

Oh, and don't forget to vote for me! Thanks again.

BTW: There is always more info on my web site: www.ph-elec.com

Step 5: Metric Update

Attached is a new version that allows the display of either metric or imperial.

Hope this helps,


Tech Contest

Participated in the
Tech Contest

Microcontroller Contest

Participated in the
Microcontroller Contest

33 People Made This Project!


  • Big and Small Contest

    Big and Small Contest
  • Game Design: Student Design Challenge

    Game Design: Student Design Challenge
  • Make It Bridge

    Make It Bridge



3 years ago

I updated my system the other day and after trying to run the script, I get the error below. I have my Pi connected to the Officail RPi 7" screen. This has been working flawlessly until I updated it. Using Stretch any ideas?

pi@weatherstation:~/weather $ sudo python weather.py
Warning: can't open ttyUSB0 serial port.
X Display = :0.0
Framebuffer Size: 800 x 480
Traceback (most recent call last):
File "weather.py", line 803, in <module>
if myDisp.UpdateWeather() == False:
File "weather.py", line 611, in UpdateWeather
self.w = pywapi.get_weather_from_weather_com( 'CAXX0102:1:CA', units='metric' )
File "/usr/local/lib/python2.7/dist-packages/pywapi.py", line 136, in get_weather_from_weather_com
dom = minidom.parseString(xml_response)
File "/usr/lib/python2.7/xml/dom/minidom.py", line 1928, in parseString
return expatbuilder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 940, in parseString
return builder.parseString(string)
File "/usr/lib/python2.7/xml/dom/expatbuilder.py", line 223, in parseString
parser.Parse(string, True)
xml.parsers.expat.ExpatError: syntax error: line 1, column 0


Reply 3 years ago

Hi there! Can you send us your python script? Thank you!


2 years ago

Just got word from Darksky, they sold out to Apple. API will stop working in 2021 :(

"Hi there,

We have some important news to share: Dark Sky has joined Apple. You can read more here: https://blog.darksky.net.

The self-service API for existing customers is not changing today, but we will no longer accept new signups. The API will continue to function through the end of 2021."


2 years ago

I want to try something similar. I have my own research grade weather station in my backyard with an IP address. Does this method work to display that or can someone point me in the right direction please?


3 years ago on Introduction

I have not tried it yet...but this might be able to replace the weather.com API. I prefer Jim's display...but this link might be a base to get our weather stations back up...

Update 1-20-2020: I was able to get the below project up and running and with a few tweaks it looks every bit as good as the original!!



Reply 3 years ago

Hi, I found a bug in this program. The wind is blowing. You can add to weather.py and then add your icon to the icon directory wind.png:
line 160: elif icon == 'wind':
line 161: icon_path = 'icons/{}/wind.png'.format(size)


Reply 3 years ago

Hello everyone! I am the owner of https://github.com/genebean/PiWeatherRock I am excited to help any of you who have problems switching over. I just merged in some updates tonight for fixes to issues that a couple of people from here found. The updated readme now also includes both instructions on updating to the latest code and some info on getting support.


Reply 3 years ago

My Edits.


Reply 3 years ago


Thank you! Did you change the weather.py script? What does your config.py look like?

Reply 3 years ago

hello. I changed only weather.py and I used other weather icons.

There are some my changes :
256 self.time_date_text_height = 0.140
245 self.xmax = pygame.display.Info().current_w - 6
246 self.ymax = pygame.display.Info().current_h - 0
621 time_string = time.strftime("%a, %b %d %H:%M:%S", time.localtime())
622 am_pm_string = time.strftime(" ", time.localtime())
710 hours_and_minites = time.strftime("%H:%M:%S", time.localtime())
711 am_pm = time.strftime(" ", time.localtime())
495 umbrella_txt = 'Dnes Si Vem Deštník!'
497 umbrella_txt = 'Deštník Můžeš Nechat Doma.'
486 'Vítr:', wind_txt, False, 1)
474 'Pocitově:', int(round(self.weather.apparentTemperature)),
489 'Vlhkost vzduchu:', str(int(round((self.weather.humidity * 100)))) + '%',
531 'Pocitově:', int(round(self.weather.apparentTemperature)),
543 'Vítr:', wind_txt, False, 1)
546 'Vlhkost:', str(int(round((self.weather.humidity * 100)))) + '%',
63 dirs = ["S", "SSV", "SV", "VSV",
64 "V", "VJV", "JV", "JJV",
65 "J", "JJZ", "JZ", "ZJZ",
66 "Z", "ZSZ", "SZ", "SSZ"]
94 ca_dict['windSpeed'] = 'Kilometry m hodině'
95 ca_dict['windGust'] = 'Kilometry m hodině'
725 self.sPrint("A weather rock powered by Dark Sky", small_font,
self.xmax * 0.05, 3, text_color)
self.sPrint("Východ Slunce: %s" % self.sunrise_string,
small_font, self.xmax * 0.05, 4, text_color)
self.sPrint("Západ Slunce: %s" % self.sunset_string,
small_font, self.xmax * 0.05, 5, text_color)
text = "Denní Světlo: %d hod %02d min" % (day_hrs, day_mins)
self.sPrint(text, small_font, self.xmax * 0.05, 6, text_color)
# leaving row 7 blank
if in_daylight:
text = "Západ slunce za %d hrs %02d min" % stot(delta_seconds_til_dark)
text = "Východ slunce za %d hrs %02d min" % stot(seconds_til_daylight)
self.sPrint(text, small_font, self.xmax * 0.05, 8, text_color)
# leaving row 9 blank
text = "Počasí Aktualizováno v"
self.sPrint(text, small_font, self.xmax * 0.05, 10, text_color)
text = " %s" % time.strftime(
"%I:%M:%S %p %Z on %a. %d %b %Y ",
self.sPrint(text, small_font, self.xmax * 0.05, 11, text_color)


Reply 3 years ago

Hello, thank you! Could you please tell me where the source is your icons? I think that's very good!

Reply 3 years ago

Thx! Working fine!


Reply 3 years ago

Hi there! Can you please send me your weather.py and your config.py? I only get error messages? That would be nice! Thank you!