PyWeather 2
PyWeather 2 (there isn’t an exact name for this project, so I made it up on the fly) is a weekend experiment to make an e-ink weather display with a Raspberry Pi.
The weather display refreshes every 5 minutes (due to the somewhat distracting flashing when refreshing the eink display) to update indoor temperature data. Weather data is updated every 15 minutes from Dark Sky (unless it’s about to rain, or about to stop raining, then the 5 minute interval is used).
For indoor temperature monitoring, an I2C sensor is used.
—
Hardware: Raspberry Pi 4/Raspberry Pi 3B, Pimoroni Inky wHAT (4.2 inch E-Ink HAT), Adafruit SHTC3 temp/humidity sensor
Language: Python
Frameworks: Dark Sky API, Pillow
Lines of Code: 350
Timeframe: A long weekend
—
PyWeather 2 the backbone for the How Hot Is It In My Dorm Room? Project, which you can view here.
—
You can view the source code for this project here.
The main weather screen. Given I had a 400x300 resolution to work with, and that 16px text was around the cutoff for legibility, this is about the maximum data I can put on the screen.
Up close, you can see the aliasing of the text which definitely looks off putting. However, at a distance of about 3 ft, the text is very readable.
The top portion is dedicated to current weather conditions, with an icon, temperature in 24px font size, then the current conditions. Over on the right, you’ll find feels like, wind speed, and humidity.
The middle portion is a 5-hour forecast (deliberately at 80px/interval because size constraints). Times are localized to the timezone of the forecasting location.
The bottom (but not super bottom) portion is a 4 day forecast, with an icon, high and low temperature.
The bottom bottom contains the indoor temperature & humidity reading, plus when the display was last updated.
If there’s an active weather alert, the bottom portion of the screen shows the most severe weather alert (warning takes precedent over watch, etc), and when it expires. To keep the user informed of when the last display update occurred, updated moves to where humidity would be shown, since it isn’t incredibly important data.
Because the Dark Sky API is used, I also implemented the display to show Dark Sky’s next hour forecast. If the next hour forecast is just (precip type) for the hour (without an alert), the UI shifts to this layout. Large portions of the current weather section get shifted up, and humidity data is hidden. I need to fiddle around with the UI for this a bit, the feels like/wind text does hang a bit too low for my liking.
And this is where the information density goes on overload. If Dark Sky produces a precip forecast where rain starts and ends within the hour (producing a comma, this is what the code looks for), then this wonderful UI is utilized. The top section is filled with 4 lines, the feels like/wind is shifted up even higher (to be in alignment with the first two lines). It’s pretty fun.
Full hardware build out. The Raspberry Pi is sitting under the Inky wHAT. This is also a no-solder prototype, thanks to the Stemma QT connectors on the SHTC3 sensor. Because of limited stock when I bought parts, I had to get a QT to Female cable, then buy standard male to male jumper wires to hook into the Inky wHAT.
Not pictured in the rest of this album is that the Inky wHAT has very convenient breakouts for 3.3V, Ground, I2C, SPI, etc etc.
Side view of the entire setup, mainly intended to show you how the inky wHAT is mounted. It comes with standoff screws for the Pi, and a 40-pin GPIO “riser” so it can reach the Inky wHAT on the standoff screws.
The current home of PyWeather 2 on my desk! It’s a very fun addition, and I love being able to glance over to this side of my desk to get the latest weather information. Instead of having to fiddle with my phone, I can know in an instant if I should get an umbrella for rainy days, or a sweater for when temperatures are getting low.
PyWeather 2 is a pretty fitting name, given that this does indeed show the weather, and it’s written in Python. Just in real life, instead of in a terminal window on a computer.
Since the original revision of PyWeather 2, I’ve added a few more things to the code.
The hourly forecast doesn’t include the current hour anymore, instead opting for the next hour instead.
Sunrise/sunset times are now shown in the hourly display, with an appropriate icon.
Not shown here are some good improvements to the backend code, which include better alert handling, changing which data is shown when there’s limited lines available, etc.
Bonus photo: This is what I had working after about 30 minutes from finishing hardware assembly. I was able to get the temperature and humidity from the I2C sensor, and output the time at the top right of the screen.
(excuse the photo quality, this is a screenshot taken from a Snapchat video)
This is the UI design on the very first iteration after about 4 hours of coding. I originally intended for the e-ink display to contain multiple screens of information (including Google Calendar and Todoist), controlled via a gesture sensor. Thus, the persistent “status bar” at the top.
However, I quickly realized that having a standalone weather display was the best purpose for this device. Having a Calendar made sense, but the gesture sensor I got only recognizes single-finger gestures from at most about 3-4 inches above the sensor. Todoist makes no sense, since I always have that open on my computer.
The extra real estate gained by removing the always-present status bar meant that showing minutely data from Dark Sky was possible.