Obligatory WeatherFlow e-ink Display

I’m new to the community, but I wanted to share my e-ink display project. Full disclosure, I am not a programmer, I have no training whatsoever in Python, and furthermore failed C++ in college not once, not twice, but 3 times. Those caveats aside, this project is easily achievable by a novice. I do not want to give any false assumptions that the source code is mine, or that I have developed it in any way, that is not the case. I have taken the source and modified it to suit my needs and use the WeatherFlow data.

Edit: I made some pretty big improvements tonight so I felt as though a fresh, less glared picture was in order

First and foremost…

Bill of sale:

  • List item 1x 5x7 photo frame - I am in the midwest, I purchased a rather generic frame at my local Meijer
  • 1x Raspberry Pi Zero 2W
  • 1x WaveShare 7.5inch e-Paper HAT (B) - (I had bought the 3 color Red, Black, White version expecting to have red integrated. As I am not a skilled programmer leveraging someone else’s code, I shoehorned my 3 color screen into a 2 color screen code.)
  • MicroSD memory card
  • Ideally a 3D printer to make custom parts

Source Code:
The source code I used for this project was called e_paper_weather_display

Important Modifications:
This code is written to use OpenWeather API. Simply changing the URL does not allow the code to work with WeatherFlow. The following code is the key to success:

At the import section of the code, look for json - modify the line to look like this:

import requests, urllib.request, json

At the section where URL =, set it to use your station ID and API token. If needed, you can also change the units to what you prefer.:

URL = ‘https://swd.weatherflow.com/swd/rest/better_forecast?station_id=[StationID]&units_temp=f&units_wind=mph&units_pressure=inhg&units_precip=in&units_distances=mi&token=[API Token]’

From here, you will modify the JSON pull to use the upgraded method. This is the key to get the app to work. The original method returned garbage. See below:
# Check status of code request
if response.status_code == 200:
print(‘JSON pull from Tempest WX successful.’)
# get data in jason format
f = urllib.request.urlopen(URL)
wxdata = json.load(f)
f.close()
# get current dict block
current = wxdata[‘current_conditions’]

From this point you only need to plug in the JSON items you want to see. Reference [Place Holder for Tempest API link due to newbie restrictions] for the specific JSON items. Note: if you keep the source naming convention, selecting your data will look similar to (without the double quotes) “current[‘air_temperature’]” - setting this to a variable, eg temp_current = current[‘air_temperature’] - will allow you to use the the API data for the current temperature.

My Modifications:
I had a lot of fun with this project, so I went pretty far with it. I designed and printed a back for the frame as well as a mask for the e-ink screen. These allowed me to create mounting points for the driver HAT as well as the Raspberry Pi. Note: If the picture is not embedded in this original post, it will be in subsequent replies.

Top left:
I modified the source code to allow the use of day weather icons and night weather icons. This was achieved by using the sunrise and sunset data. Simple logic of if > sunrise and < sunset = daytime, < sunrise and > sunset = nighttime.

Barometer data. I added in barometer readings along with an icon for the trend. The icon I used was from [Place Holder due to restrictions as new user] were either from this list or modified from one on this list.

Top Right:
The feels like temperature is a product of humidity and dew point. The modification I made here was adding in a fire icon to the right of the feels like temp if it is equal to or exceeds 5 degrees above current temp. Conversely, if it is equal to or minus 5m it will display a snow flake icon.

Bottom left:
No changes

Bottom Middle:
Added Dew Point as a new line and Cardinal DIrections to the Wind reading.

Bottom Right:
If there is lightning detected in the last 3 hours, the panel changes from last updated time to a lightning icon with the number of strikes in the last 3 hours and the current distance reading for the strikes. Once the lighting stops, the 3 hour period will expire and the panel will go back to the last updated time.

For fun:
If the wind exceeds 10MPH, the weather icon will change to the ‘IT HECKIN WIMDY’ meme. This clearly has no scientific value, but it is fun to see a fox meme pop up.

Final notes:
I will provide images and descriptions of how I modified this code to make it work for me. However, since I did not create the source code I do not feel as though it is fair to claim it as my own. I modified what I found to make it suit my needs since the Tempest specific repository was taken down. This was a ‘oh crap I ordered all these parts and I need to make it work or the wife will kill me’ moment. With a bit of trial and error, this is a rather simple project. Creating a script to execute (without quotes) “python weather.py” in the root crontab @reboot is really all that is needed.

If anyone has any questions or feedback, please let me know and I will do my best to answer!

Edit: Upon request, I have created a fork from the original code for my version to work with Tempest: https://github.com/OG-Anorine/Tempest-7.5-E-Paper-Display

6 Likes

Tempest API reference Link: Tempest API

Weather Icon source: Weather Icons

3D Printed back:

Lightning tracking mod:

1 Like

Super good looking. Have you noticed anything re: burn-in on the display, and how often does it refresh ?

Thanks! I appreciate the feedback! I am refreshing every 5min. I also run a reboot at 3:30am in order to completely reinitialize the screen. So far I have seen zero burn-in.

awesome work! a purely meme-based weather layout could be fun. when temp <= 20 (F) or UV >= 10, simply “don’t go outside” is sufficient in big letters.

I have added more memes for personal use. I have always wanted to experience thundersnow. Using the data, I built in logic for my personal display that will have the Ron Paul “IT’S HAPPENING” meme pop up.

I do have the git repository up to date, though I did pull out the Ron Paul meme. The new release here has a skull and crossbones next to the feels like when the dew point is equal to or greater than 76 (help us all if that happens): Shameless Plug for Code

I’ve recently included a number of fixes for things that I have noticed along the way. Future state I plan on prioritizing NWS alerts, but I need the json for multiple alerts in order to code it properly. Unfortunately, when I thought that hey, that’s a good idea, the double alerts in my area had expired 3 minutes prior.

If you look at my fork, I grab only the most current NWS alert that is still active. Look around line 217 or so in weewx-epaper/weather-cron.py at twocolor · vinceskahan/weewx-epaper · GitHub

I also updated mine to have two variants, one that loops and sleeps, and one (like yours) that is called by cron. I’m finding the called by cron variant the best way to do it, as it is graceful if the code blows up by getting something unexpected. Worst that happens is you get a blank screen for a few minutes til cron runs it again. Stops you from getting stale displays that can burn in too. I also added a ‘clearscreen.py’ script for that just.in.case.

Same for forecasts. I get only the first active one. Forecasts are tougher because NWS uses some crazy long strings that don’t fit. I just hack brutally on the string if it’s too long. Should be obvious.

I ended up creating a service to run it and I have found it is way more stable. I was kicking everything off via cron at the beginning, but things would get stuck every once in a while.

For multiple alerts I plan on using the severity field to make sure the most severe alert is displayed first. Again, I need to see double alerts to fully understand the logic I will need to write. I may have to combine that with urgency to get proper results. In the end, I think that will be a great addition for keeping on top of what’s going on.

My ‘guess’ is that the most important one is first in their list, but I didn’t do much more than a quick few looks to see if that’s indeed what they are doing. Sure wish they’d publish their dictionary of what words they use for the alerts and forecasts rather than having to figure it out experimentally.

I’ve found cron 100% reliable and simpler than worrying if systemd will work or not. Only downside is that I don’t (currently) save the previous logfile someplace if it had failed so I can see what I logged if it aborted. At this point it’s just me not doing a good enough job at wrapping things in try/except blocks.

I’ve been eager to build one of these for myself since I got my Tempest, but I’m running into some issues and I’m hoping I could ask for a bit of troubleshooting.

I think the main issue is dealing with the display type. Mine is just a two color as I thought that would make things easier. I did run the test script from Waveshare and the display does work.

Display

  • Waveshare 800*480
  • 7.5inch E-Ink display
  • HAT for Raspberry Pi 2B/3B/Zero/Zero W
  • Two-color:Black White
  • SPI interface
  • No Backlight

After making the changes for my weather station, I ran it as is. The script executed, but nothing appeared on the screen. That’s when I noted the comments regarding the ‘red’ colors. So I commented out those lines.

In addition, I used the “epd7in5_V2” script instead of the ‘b’ version. Since that one was just for the gray scale, but this produced the following error.

Which I found odd because “imagered” doesn’t exist in “epd7in5_V2”. Here’s what I’ve got for this section of the script. I noted my changes with arrows

I think I’m really close here, but I just can’t determine what I’m doing wrong.

Yeah you look super close. Have you updated the waveshare files from their github? If you follow their instructions and on the build out for file placement, you can get the updated files here. As for the initialization, a setup like this should work for your 2 color:

Let me know if either of these get you in the right direction.

1 Like

I vaguely remember running into this kind of stuff trying to use @anorine’s nice app on my twocolor display. I took a quick look at my fork and saw a note I made to myself that might help.

# note: for the 2-color display this needs to use the older
#       v4.0 version of the waveshare libs but the 3-color
#       still uses the original upstream (later) library

So you might want to grab the older library that I use in mine, making sure to use the twocolor branch - (GitHub - vinceskahan/weewx-epaper at twocolor) - mine’s been running for well over 6 months now pretty much perfectly. It ‘rarely’ seems to lock up using a pi zeroW when wifi gets spotty. Since I call the script via cron it self heals if I just power reset the zeroW to get a clean boot.

At a minimum you can grab the older twocolor-compatible lib from my repo above.

Note - my fork is ‘not’ directly WeatherFlow compatible but the display stuff therein should get you going hopefully. I also have a little ‘weathertest.py’ script to test the display with hard-coded data to battle through the display nuances. Those ePaper can get finicky to get working.

1 Like

Where, in relation to Weather.py do you load those profiles? Should they be in that same folder as Weather.py or somewhere else, maybe in a system folder?

I’d rate myself as an amateur when it comes to this stuff. I’m able to get around, but I still struggle to comprehend Linux-based systems.

No problem at all, I was 100% in the same boat when I made this. I made it up as I went along :joy:

You will want the files to reside in ~/tempestwx/tempest-7.5-E-Paper-Display/lib/waveshare_epd based upon the screenshots you sent earlier to gather the paths.

As an additional note, I would recommend using the test program that waveshare has in the install process, as it will let you know your screen is configured correctly. It will show random garbage, but if you get that far, your screen is up and running. From there it is a matter of running weather.py as you see fit if it is crontab or as a service.

You’re super close, keep it going!

Edit: If you arent super familiar with linux stuff, ~/ is a shortcut to your home folder of the active account. So in this case, /home/tmpstwxmgr/ - I didn’t include that earlier, but I wanted to make sure I clarified my suggestion.

Heck yes!

Now I need to design an enclosure and get it stood up in the living room.

Thanks again for all the help. In the end, I updated the weather.py script to match what you suggested, deleted “epd7in5b_V2” to be safe, and then once I replaced the two “epd7in5_V2” files from those from the Waveshare repo and it worked!

2 Likes

That’s awesome!!! Congrats!!

I have a couple STL files for 5x7 frame that has a mask as well as a mount if you are interested/have access to a 3D printer. I used threaded inserts for mounting the hardware on the back with M2 screws/washers. From there, I removed the original stays from the back of the store frame and used them to mount my custom back:

This is the v2 final product from the front:

2 Likes

So, I had additional issues when it came to getting the crontab business to work. Somewhat surprisingly, ChatGPT came in clutch to sorting this out for me. Ultimately, I ended up creating a service using systemd and this seems to have fixed the timing an access issues I was having with crontab.

I used ChatGPT by feeding it the errors and explaining what I did. It honestly did a remarkable job at explaining those, but also giving suggestions to fix. As I worked through them, I told it what wasn’t working until it eventually got me to this path.

Here’s what I did.

  1. Create the systemd service (/etc/systemd/system/tempest.service)
[Unit]
Description=Tempest E-Paper Weather Display
After=multi-user.target dev-spidev0.0.device

[Service]
ExecStart=/usr/bin/python3 /home/<folder>/Tempest-7.5-E-Paper-Display/weather.py
WorkingDirectory=/home/<folder>/Tempest-7.5-E-Paper-Display
Environment=PYTHONPATH=/home/<folder>/Tempest-7.5-E-Paper-Display/lib
User=<user>
Group=spi
Restart=on-failure

[Install]
WantedBy=multi-user.target
  1. Enable the Service
sudo systemctl daemon-reexec
sudo systemctl enable tempest
sudo systemctl start tempest

At this point the screen was flickering, but nothing was being displayed so something wasn’t right. So I checked the service and found there were permission issues to some of the files.

  1. How to Check the Service
journalctl -u tempest -e

That led me to the error that indicated there were some file permissions issues. So I fed the error log lines into ChatGPT which it then parsed and suggested all the steps necessary to take ownership of those files. As soon as that was done, the screen refreshed once more and voilà, it’s working!

IMPORTANT: I am leaving in the crontab job to reboot the system.

1 Like