computers

Raspberry Pi Weather Display

While going through some old project components, I found a cute little case for a Raspberry Pi and a TFT screen. Instead of allowing it to collect more dust, I decided to try to make something useful with it. The small size was perfect for some sort of informational display, so I decided to turn it into a weather display to keep by the door to remind me to take a coat or umbrella.

Finished Raspberry Pi weather display!

The display case was for a Raspberry Pi Model B (version 1!) and a 2.8″ TFT screen. I was able to find an old Model B and got started.

The first step was to get the PiTFT screen running as I had no idea if it even worked. I first started by installing Raspbian Bullseye on the Raspberry Pi, but was unable to get anything to display on the screen. After digging in a bit more (and reading the manual), I found that these screens can have issues with Bullseye, but often work on Raspbian Buster. I tried again with a fresh Raspbian Buster install but still had problems with the display not showing the desktop (but the console worked as expected). I was finally able to get the screen to work by installing Adafruit’s recommended lite distribution and then installing the PIXEL Desktop on it.

I then used the Adafruit Easy Install instructions to set up HDMI mirroring between the Raspberry Pi and an external monitor. It’s a good idea to make any last configurations that require the higher resolution of the monitor before running the easy install script as the HDMI mirroring mode downscales the monitor to 640×480 resolution. This includes disabling any screensavers that could interfere with the display.

Once I had the desktop environment running, I tried out a few Linux desktop apps to see if they would work for my display. Sadly, most of the apps were designed for higher resolution screens which made them difficult to read on the TFT screen. GNOME Weather was almost good enough, but its lack of an auto-refresh feature made it infeasible for my project.

Close but no cigar: GNOME Weather on a Raspberry Pi

My next option was to build my own weather display application. I decided to use the OpenWeatherMap API as their free version had all of the data I needed and their free subscription tier had enough request quota for my purposes. I also wanted a set of icons for my display and found the open source weather-icon project, which contains icons for almost any weather condition imaginable (including aliens!)

Once I had the data for the project, I started investigating how to build a graphical user interface for the display. After a false start with Python Tkinter, I decided to use Pygame. This was my first time using Pygame (or any Python GUI toolkit for that matter) but it was relatively easy to make progress with it. Although this framework is tailored towards building games, I found it to be quite effective for building the GUI for this project. After a bit of tinkering, I was able to build a customizable weather application for small displays. The code is available here.

I then copied my code over to the Raspberry Pi and was able to see the screen in action! I made a few small display tweaks and then configured autostart to run the display program on startup.

Raspberry Pi weather display by the door

And that’s it! I now have a neat little weather display by my door and I was finally able to use some parts that I bought eight years ago!

Raspbian

While working on another project, I set up my Raspberry Pi (revision B) with Raspbian. Although it was a bit time consuming, it was not difficult at all. Instead of using the default desktop environment (LXDE),  I decided to try out Raspian Mate as it’s a fork of the well-loved GNOME 2 desktop environment.

Raspbian

I was happy to see that GNOME 2 was still alive and well. I used to run Ubuntu on my home computers, but abandoned it when they switched over to GNOME 3 and Unity. The lack of features in GNOME 3, the clunky Unity interface and the poor device support in Ubuntu pushed me over the edge. I sold out to Macintosh and happily resigned myself to never having to look at xorg.conf ever again.

Raspberry Pi

It surprises me how far computers have come already in my lifetime. As a little girl, I remember playing with my grandfather’s Color Computer 2. It seemed remarkable at the time and I never expected computing to progress as rapidly as it has. For some perspective, the CoCo2 cost $240 in 1983 and had 16KB of RAM and an 8 bit processor at 1 MHz. Twenty years later, the Raspberry Pi costs $35 and has 512 MB of RAM and a 32 bit processor at 700 MHz. It will be interesting to see what the next twenty years brings.