Frogweather is a weather app and library written in Python. It generates images that show both the current time and weather information, specifically the temperature and precipitation probability within the next three hours. The background image shows a frog-themed visualization of the current weather.
Since this app is meant to provide weather station images that are displayed on a 64x128 LED matrix, the images are of size 64x128.
If you need other sizes, you can resize the images or replace the background images by your own images.
The background images are located in the images
folder.
First, run the example script:
-
Install the dependencies via
pip
:pip install duallog pygame PyYAML requests
-
Clone the repository:
git clone https://github.com/acschaefer/frogweather
-
Request an API key from Weather API. The key comes for free and allows you to access the Weather API weather service 1M times per month free of charge. Frogweather is designed not to exceed this limit.
-
Paste your key into the file
apikey.yaml
. -
Find out the geographical coordinates of your location, for example via the GPS Coordinates website.
-
Paste your coordinates into the file
location.yaml
. -
Run the example program:
python frogweather/frogweather.py
This command will open a window that displays the weather station image. It will also continuously update the image.
Now you can use the frogweather
package in your own Python module.
The following Python code snippet shows how to do it:
# Import the module.
import frogweather
# Read the configuration files.
frogweather.init()
# Continuously check for new weather station images.
while True:
# Check if a new weather station image is available.
if frogweather.update():
# Access the updated image.
image = frogweather.get_image()
In order to generate an image, the frogweather
module executes the following steps:
- It retrieves the current time from the operating system.
- It downloads the current local weather information, i.e. temperature and precipitation probability, from Weather API.
- It renders the weather station image.
In order to set up a frogweather-powered weather station consisting of a Raspberry Pi and two 64x64 LED matrices, you first need to set up the hardware. For detailed instructions on setting up the matrices, see the Raspberry Pi LED matrix driver repository. If you have access to a 3D printer, you might find my 3D model of a frame for two LED matrices helpful. Once the hardware is set up, follow the steps below to make the software work:
-
Install Raspberry Pi OS Lite on the Raspberry Pi. We recommend the version "bullseye". More recent versions enforce using virtual Python environments, which are harder to use with sudo privileges.
-
Switch off on-board sound, because it does not work with the LED matrix library: Change the corresponding line in the OS file
/boot/config.txt
todtparam=audio=off
Then, blacklist the sound driver and reboot:
cat <<EOF | sudo tee /etc/modprobe.d/blacklist-rgb-matrix.conf blacklist snd_bcm2835 EOF sudo update-initramfs -u sudo reboot
-
Disable unnecessary services:
sudo apt-get remove bluez bluez-firmware pi-bluetooth triggerhappy pigpio
-
To isolate the fourth CPU from tasks scheduled by the operating system, append the following to the Raspbian system file
/boot/cmdline.txt
:isolcpus=3
Make sure the command above is separated by a space from the preceding commands; do not insert a line break.
-
Download the excellent Raspberry Pi LED matrix driver repository:
git clone https://github.com/hzeller/rpi-rgb-led-matrix
-
Build the Python bindings of the LED matrix driver: Navigate to your clone of the
rpi-rgb-led-matrix
repository and in the folderrpi-rgb-led-matrix/bindings/python/
, run the following commands:sudo apt-get update && sudo apt-get install python3-dev cython3 -y make build-python sudo make install-python
-
Follow the steps in the previous section to install the frogweather app. Make sure to install all dependencies with
sudo
privileges - we need to run the app withsudo
for the LED matrix library to work properly. -
Navigate to the folder
frogweather/frogweather
and launch the weather station:sudo ./showfrog
The
sudo
command is required by the LED matrix driver. -
In order to launch the weather station automatically after boot, append the following command to the Raspbian system file
/etc/rc.local
:sudo python /path/to/frogweather/frogweather/showfrog &
The result looks like this:
The background images used in this project are modifications of the background images shown in Google's weather app.