RPi Weather Station and Digital Clock

6,443

58

9

Introduction: RPi Weather Station and Digital Clock

About: Hi, I love electronics, 3d printing and sharing what i make. I mostly try making useful things, but sometimes I also make some just for fun and for learning something new. And if you like what you see, follow…

This is a quick and easy project to make, and a nice display to show off. It displays both the time, weather condition and temperature. And if you like what you see, follow me on Instagram and Twitter (@Anders644PI) to keep up with what I make.

The code is based on StuffWithKirby's useful code on reading JSON weather data in python, and SteveAmor on Github's super cool SenseHat digital clock code.

You will need:

  • A Raspberry Pi 3(Any 40-pin Raspberry Pi will work)
  • A Raspberry Pi SenseHat(Or any other display, to display the weather data on)
  • A 5V 2.4A Power Supply for Raspberry Pi
  • A 8GB or higher Micro SD Card with the latest version of Raspian
  • A 3D printer and a spools of any color PLA (Optional)
  • This set of screws and standoffs (Optional: You only need this if you want to use the diffuser)

Step 1: Weather Data

We get the weather data from OpenWeatherMap.org, but you could of course add a termister or like to the Pi, and read data from that directly, if you really wanted to.

  1. Start by making a FREE account on OpenWeatherMap.org.
  2. Then copy your api-key to use later.
  3. Now download and open the city.list.json file, search for your city, and then copy the city-id for later.

Step 2: Setting Up the Pi

1. In the terminal on the Pi (with connetion to the internet) run this command, to get the Pi setup:

sudo apt-get update && sudo apt-get upgrade

2. Now download my GitHub repo and edit the script:

git clone https://github.com/Anders644PI/RPi-SenseHat-Digital-Clock-and-Weather-Station.git
cd RPi-SenseHat-Digital-Clock-and-Weather-Station nano RPi_Weather_Station.py

3. In the RPi_Weather_Station.py paste in your api-key and your city-id. You can also change the units to imperial (fahrenheit), if you want that over metric (degrees).

4. Now run it, and it should work great. But if you have issues, feel free to tell me in the comments, and I will be happy to help.

sudo python RPi_Weather_Station.py

Step 3: 3D Printed Accessories

This step is optional, by now you already have a functional weather station. But when i have access to a 3D-printer, I better use it.

1. First upgrade is a diffuser for the SenseHat, that can be screwed to the Hat with two screws and two standoffs for the Pi. I used some screws i had laying around, but some of these should work as well. Download file here: https://www.thingiverse.com/thing:2930576

2. Second upgrade is a vertical stand for the Pi. This one requires no screws, it just slides onto the USB-ports. This does make the USB- and Ethernetports not functional. Download file here: https://www.thingiverse.com/thing:2930597

Step 4: The Result

Congratulations, you're done!!! You should now have a nice RPi weather station to sit on your desk, and inform you with useful weather information.

I would love to see what you make with this project, so please tag me at @anders644pi, on Twitter or Instagram, if you do make it. And please, if you like this project, vote for me in the Microcontroller Contest: https://www.instructables.com/contest/microcontroller2018/.

Microcontroller Contest

Participated in the
Microcontroller Contest

1 Person Made This Project!

Recommendations

  • The 1000th Contest

    The 1000th Contest
  • Battery Powered Contest

    Battery Powered Contest
  • Hand Tools Only Challenge

    Hand Tools Only Challenge

9 Discussions

0
DavidP275
DavidP275

5 months ago

Getting this error when running .py

pi@raspberrypi:~/RPi-SenseHat-Digital-Clock-and-Weather-Station $ sudo python RPi_Weather_Station.py
Traceback (most recent call last):
File "RPi_Weather_Station.py", line 7, in <module>
sense = SenseHat()
File "/usr/lib/python2.7/dist-packages/sense_hat/sense_hat.py", line 39, in __init__
raise OSError('Cannot detect %s device' % self.SENSE_HAT_FB_NAME)
OSError: Cannot detect RPi-Sense FB device

0
Anders644PI
Anders644PI

Reply 5 months ago

Have you connected a Raspberry Pi Sense Hat, and tested that it works, with one of the examples for it?

1
ToniFIN83
ToniFIN83

1 year ago

Getting this error:
pi@raspberrypi:~/RPi-SenseHat-Digital-Clock-and-Weather-Station $ sudo python RPi_Weather_Station.py
Traceback (most recent call last):
File "RPi_Weather_Station.py", line 20, in <module>
print (weather['main']['temp'])
KeyError: 'main'


Running on Pi 3+ and latest Raspian stretch full

Any hints?

0
kimalajoy
kimalajoy

Tip 1 year ago on Step 2

API key needs to be in call caps when you paste it!

0
Anders644PI
Anders644PI

Reply 1 year ago

I didn't have that problem, but glad you got it to work.

0
btwebz
btwebz

Question 1 year ago on Introduction

Hi there,
Really like your project. Thanks for publishing it. The project was just what I was looking for. I am having one small problem though. The weather data is not updating. I can make it update manually by stopping the program and then starting it again but would be great if I could get it to update on its own. The time and date are working fine. It is just the weather. Would appreciate any help you could give me. Thanks again and best regards, Mark

0
Anders644PI
Anders644PI

Answer 1 year ago

Thanks for telling me, I have now added a "(...)-v2" on my GitHub repo (here: https://github.com/Anders644PI/RPi-SenseHat-Digita...), that should hopefully update the weather about every minute (you can change the delay, in the code, if you want). Try it, and tell me if it works / doesn't work.

0
btwebz
btwebz

Reply 1 year ago

Hi Anders644Pi
Thank you posting that update. It made the weather update successfully once every 50 minutes. I changed this in the code to update once a minute. Thank you very much again for your help!! I am very happy with my Weather station and Digital clock. Cheers Mark

0
Anders644PI
Anders644PI

Reply 1 year ago

You're welcome! Glad i could help.