Introduction: Simple Weather Display Using Raspberry PI and Cyntech WeatherHAT

About: I am a Ham Radio operator, computer geek, robotic hobbyist. I've been "playing" with microcontrolers for the last several years, basic stamps, arduinos, and arduino like controllers, Raspberry PI, PICs & PICax…

* In 2019 Yahoo changed it's API, and this stopped working. I was unaware of the change. In September of 2020 this project has been updated to use the OPENWEATHERMAP API See the updated section below, the rest of this information is still good however. Thanks for looking, and thanks for letting me know about the Yahoo change. *

Recently I acquired a Cyntech WeatherHAT, but I was a little disappointed with the lack of software for it.

The HAT it's self appears to be well constructed, with 6 blue LEDs in the form of rain drops, 6 orange LEDs in the form of a thunder-bolt, 6 white LEDs in the form of a cloud. 1 (What I believe is a RGB LED) for the SUN - it displays orange (so I might be wrong about it being a RGB). And 6 WS2812 LEDs (These are RGB :-))

Cyntech does have a getting-started guide, and even that is good - it's easy to install and use the HAT.

So I was just surprised to not really see any software (other then the demo provided by Cyntech). I was equally surprise to not find anyone really using this - Maybe people want a "fancy" display with temperatures, and all that kind of information. For me it's nice to just look up at a few LEDs and know - it's Raining, or Thunderstorm, or Cloudy - At that point if I need more information I can look at my tablet or phone. :-)

A little more - this is really my first time using python, I'm by no means good at it. And I'm sure that people who really know python will tell me better way to do this.

Let's get started:

We need a SD card (at least 8gb)

A Raspberry PI (I'm using a Zero W) it needs to have internet access.

and we need the Cyntech weatherHAT

If you use a Raspberry PI Zero W you will need to also be able to solder a set of headers to the board.

Otherwise the skills needed are the ability to use software and setup the SD card.

Step 1: Set the SD Card and Raspberry PI

You will need to download the latest Raspbian (at the time of this instructable that is Raspbian Stretch March 2018 (2018-03-13))

I used the desktop edition, even thou I am running my setup headless, and doing most things from the CLI (command line interface) over ssh.

Follow the setup guide found here:

After Etcher is done, remove the SD card, and reinsert it into the computer.

* You really only need to do this step below if you plan on doing a headless install

We need to setup SSH and WIFI before we use the SD card in the Raspberry PI. In the BOOT partition of the card, create a file named "ssh" without the quotes. nothing has to be in the that file. When the PI boots it will see that file, and turn on SSH.

We also need to create a file called "wpa_supplicant.conf". We need to edit this file with your wifi settings.

It should looks something like this:

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev





* You really only need to do this if you plan on doing a headless install

Once that is done, safely remove the SD card and put in the Raspberry PI (make sure there is no power on the PI).

Attach the weatherHAT, and power on the Raspberry PI.

Step 2: Setup the WeatherHAT Libraries

For this step we will be following the Getting Started Guide found

IF you are doing a headless install you'll want to ssh pi@raspberrypi.local

If you don't have a ssh client - PUTTY is a good one.

If you are using a keyboard and monitor - the guide above is a good one to follow, it starts you at a GUI desktop.

The important steps here are to install the WS281x library and the WeatherHAT libraries, along with the dependence for each.

sudo apt-get update
sudo apt-get upgrade -y
sudo apt-get install build-essential python-dev git scons swig python-smbus
git clone <a href="" rel="nofollow">
git clone <a href="" rel="nofollow">
cd rpi_ws281x
cd python
sudo python install

Now we need to make sure I2C is turned on.

sudo raspi-config

The guide is written for a older version of raspi-config and says to goto "Advanced Options" which has been replaced by I believe "Interfaces"

Once you turn on I2C you'll have to reboot.

Now it's time to test the HAT

cd WeatherHAT
sudo python

If everything went well you should see all the features and a rainbow.

ctrl-z will stop the program.

*Special Notes: I learned that the timings of the Raspberry PI 3 are different and the rainbow may not work correctly. IF you have this issue here is how to fix it.

Once everything is working, we can continue to the next step.

Update: (Oct 6, 2020) This repository now contains my script, this is great news, as interest has sparked again, and new things are bound to happen.

Step 3: Installing Weather-api and GetWeather Script

So, I put in a PULL request to CyntechUK for my script - hopefully they will accept the request, and you can skip download my repository. (they may not want to include my code thou)

(Oct 6, 2020) The PULL request was approved, my getWeather script is now included in the Weatherhat repository.

*********You can still use this information if you like, however has been included in the weatherhat repository now ************************************

My respository can be found here:

and my script is called

IF they do accept the pull request you'll already have this script - if not you'll need to clone the repository.

in your home directory (/home/pi) type:

git clone <a href=""> <a href="" rel="nofollow"> <a href="" rel="nofollow">  </a> </a> </a> getWeather

this will clone the repository into a directory called getWeather, next we need to checkout the getWeather branch.

cd getWeather
git checkout getWeather


You will need to cd into the weatherHAT directory that was cloned earlier and

We need to edit the script for your location.


You should see a line that starts with

location and ends with lookup(45042) - This is my zip code, I've found that it doesn't work as well as you'd think

and the line right above it that is commented out works better with a city name. That is the one that you probably want to use. So Comment the zip code line (#) and uncomment and change your city name.

*********** OLD YAHOO INFORMATION - No Longer required ***********

We need to install one more library for this to work, weather-api which is a wrapper for the Yahoo weather API.

The install is easy -

pip install weather-api


Now we can run the script:

sudo python &

The & will let the script run in the background. The script sleeps for about 5 minutes, and then checks Yahoo Weather if something has changed - if so it updates the display. The 5 minute time can be changed, it's near the bottom of the script.

sleep(60 * 5)

You could set up a crontab job (remember this needs to be run as root) that will start the script at each boot.


sudo crontab -e


@reboot python /home/pi/weatherHAT/

I think that should work - I've not setup cron yet on my system.

That's pretty much it -

As I stated this is one of my first python programs, and I'm sure someone who know more will see a better way to do this.

I've only done limited tested on this - I have seen "Snow" "Rain" and "Thunderstorm" work so far,

There are some conditions that I'm not sure how to handle yet - I welcome ideas.

Step 4: Updated Information For: Openweathermap API

In Sept of 2020, I updated the script to use the API.

NOTE: This was a "quick" fix for me, and limited tested - (It's been overcast for the past few days, and all I see is the cloud and rain display) - While I believe I caught all the conditions that are easy to display, it's possable that I missed a couple because of how "quick" this fix was done. That being said, if you think there is a problem please leave a comment and time permitting I'll look into it - or try to point you in the right direction. *

You will need to sign up for an API key using the link above, when you edit the script to place your city, you'll see a place for the key. Just copy and paste it, and you should be good.

Other notes:

This script now uses the "Current weather data API" information about that API can be found here: One thing to note is you can use a city, state, and country.

IE: the city "Dayton" becomes "Dayton, OH, US" notice how the state and the country codes are both uppercase, this is required. The API says it can use just "Dayton, OH" but I got errors from the script when I did this - and since this was a quick fix, I haven't looked into why. SO, I recommend using the "city, state, country"

IF for some reason you don't get good information using a city name, you can also lookup the City ID, or use latitude and longitude or the zip code. In each case the URL will need to be changed, if you click on the link on the right hand side of the API website, it will give an example of what the URL should be.

You need to change the URL in the script as well.

Even more notes: Oct 3, 2020

@Itsmedoofer pointed out that they needed to install the library python-requests with the new update. I'm not sure that I did need this, (it's also possible that I had it installed from years ago, or different versions of python install different libraries by default). So if the script gives an error about python-requests it's simple to fix.

type this command into the CLI: python -m pip install requests

and you should be good.

Hopefully this makes since, this was a quick fix, and maybe one day time permitting I can work on cleaning it up a bit better.

Update (Oct 6, 2020) The github pull request was accepted, the original CyntechUK original repository now includes this script. The user Boeerb has some ideas on how to display some of the conditions that are currently not displayed, as well as some other ideas for use. So keep an eye on that repository. And hopefully things will be happening.

Update: (Oct 8, 2020) Open Weather Map has a short tutorial on setting up and using the API, A good place to start.

*Thanks for the users below in the comments that pointed out this wasn't working*

Pocket-Sized Contest

Participated in the
Pocket-Sized Contest

Microcontroller Contest

Participated in the
Microcontroller Contest