Skip to content

markyharris/metar

Repository files navigation

E-Paper METAR Display

Note: 1-7-2024. v2.1 has been updated to work with the new FAA API. Also, new features have been added to include the ability to select a subset of layouts to cycle through. Also, various units for display are now available and chooseable through the web admin page.

NOTE: 12-16-2023. The FAA has changed their API access causing the earlier version (1.xxx) to become non-functional. This update (v2.1xx) utilizes the newly released API located at https://aviationweather.gov/data/api/. Be sure to update to this new version.

This version also adds a newly configured Web Admin Page which allows for changing the Units to display various data points.

---------------------------------------------

This project is explained and amplified on Instructables.com. See; https://www.instructables.com/7x5-E-Paper-METAR-Display/

Updating from Github

If this software is already installed and you just want to update to the latest version of this software enter;

cd metar
sudo git reset --hard
sudo git pull

This software will display various layouts of METAR data on a 7 by 5 inch 3-color E-Paper. Specifically the 7.5inch e-Paper HAT (B) by Waveshare. See https://www.waveshare.com/7.5inch-e-paper-hat-b.htm for more information and pricing from Waveshare.

This software is written specifically to the size and 3-color nature of this display. However, the layouts are in a separate module and can be modified to fit other sizes of display if the desire is there. Theoretically a 2 color 7x5 could be used as well. See script 'metar_main.py' for comments on this.

For specific info on using e-paper display with RPi, see;
https://www.waveshare.com/wiki/Template:Raspberry_Pi_Guides_for_SPI_e-Paper
For information on the specific display used for this project see;
https://www.waveshare.com/wiki/7.5inch_e-Paper_HAT_(B)

Installation Steps

DOWNLOAD NEEDED APPS:
Download Balena Etcher - https://www.balena.io/etcher/
Download Berrylan Unix Bullseye Image - https://berrylan.org/
Download Berrylan App from either Apple App Store or Android Play Store to your phone

NOTE: The Berrylan image is not strictly required. It provides an easy way to setup the WiFi and enable SSH on a headless RPi system such as this. There are other ways to do this such as temporarily connecting a keyboard and monitor to the RPi to start. However, if you choose to give this to a friend then having the ability to change the WiFi network through the Berrylan phone app can be very handy. If Berrylan is not desired, visit; https://www.raspberrypi.com/software/operating-systems/ to download the latest image.

https://desertbot.io/blog/headless-raspberry-pi-4-ssh-wifi-setup provides steps to follow to setup WiFi on a headless system if Berrylan is not used.

WRITE IMAGE TO SD CARD:
Using Balena Etcher, write Image to Micro SD Card.
Put SD card into RPi and boot-up completely. This will take a minute or two. Watch the access LED on RPi for feedback.

SETUP WIFI USING BERRYLAN:
Open Berrylan app on phone and select for 'BT WLAN setup' or 'BT WLAN' or 'raspberrypi' depending on what is displayed. The most common is 'BT WLAN'. If you see more than one, then pick the first one and go through the steps. If it ends up not being this particular RPi, then run it again and select the next one. You may have to give the app alittle time to find it however, so don't be too impatient.

  • Select WiFi SSID to use
  • Enter the WiFi password
  • Write down the IP address that is displayed. You'll need this later. You can tap it and copy it to clipboard

LOGIN USING SSH CLIENT:
Open a SSH Client and enter the 'pi@IP address' to start the login process, i.e. '[email protected]'
Login using username 'pi' and password 'raspberry'. If a normal image was used, then SSH must be enabled before these clients will work. Berrylan automatically enables SSH. Otherwise use 'raspi-config' to do so. See https://www.raspberrypi.com/documentation/computers/configuration.html for info on using 'raspi-config'

Note: There are a number of SSH Clients. A few of the more popular are;

  • KiTTY.
  • PuTTY and other PuTTY versions
  • MobaXterm
  • WinSCP
  • SmarTTY
  • Bitvise SSH Client
  • Terminal (for Mac)
  • Chrome SSH extension

SETUP SPI INTERFACE:
At the cmd line prompt; 'pi@raspberrypi:~ $' enter the following;


  sudo raspi-config
  3 - Interface Options
  I4 SPI Enable this? Yes 

Note: You can change the hostname and password if desired at this point, but its optional
Answer 'Yes' when you exit raspi-config to Reboot the RPi

SETUP GITHUB ON RPI:
After RPi boots up and you login through your SSH client, enter;


  sudo apt update
  sudo apt-get install git
  git --version 

If you receive a git version number than you are good to go.

COPY FILES FROM GITHUB:
Enter;


  sudo git clone https://github.com/markyharris/metar.git
  cd metar
  ls -la 

This should list the files copied from github to verify it worked properly

DEPENDENCIES:
Install necessary dependencies needed for the software;


  sudo apt-get install python3-setuptools
  sudo apt install python3-pil
  sudo apt-get install python3-numpy
  sudo pip3 install Flask

FONTS:
The code is written with 'NotoMono-Regular.ttf' and 'LiberationMono-Bold.ttf' used, so at minimum these need to be installed. So enter;


  cd /usr/share/fonts/truetype/
  sudo mkdir noto
  sudo mkdir liberation2
  cd noto
  sudo wget https://github.com/markyharris/metar/raw/f1858d85ad3b79864fb6e082cd083346828661ef/fonts/noto/NotoMono-Regular.ttf
  cd ..
  cd liberation2
  sudo wget https://github.com/markyharris/metar/raw/f1858d85ad3b79864fb6e082cd083346828661ef/fonts/liberation2/LiberationMono-Bold.ttf

TEST RUN METAR DISPLAY:
Enter;


  cd ~
  cd metar
  sudo python3 metar_main.py

If all is well the cmd line will display debug data including a raw metar string. Watch your e-paper display to see if it starts to blink as it updates. The full refresh can take a number of seconds so be patient. After a bit a layout should be displayed showing the default airport from metar_settings.py
If so, you are good to go!

Now edit the 'metar_settings.py' file as you wish. These values are defaults that the script falls back on.


  # Default User Settings
  airport = "KFLG" # enter default airport identifier to display. Be sure to use quotes
  interval = 1800  # enter default time in seconds between METAR updates - 3600 = 1 hour, no quotes
  use_disp_format = 7 # Choose which display layout to use. -1 = Random layout, -2 = Cycle layouts
  use_remarks = 1  # 0 = display airport information, 1 = display metar remarks info 
  random_airports = ["KEYW","KDFW","KSEA","KORD", "KLAS","KCMR","KABQ","KDEN", \
                   "KPHX","KNBC","KBKV","KTTS"]

TEST CMD LINE CONTROL:
The script was written to except up to 4 cmd line arguments;

1st argument - airport identifier - must be 4 character ICAO format
2nd argument - layout number - will accept -2, -1, and 0-7
3rd argument - update interval in seconds - 60 = 1 minute, 3600 = 1 hour
4th argument - use remarks - 1 = display metar remarks key info, 0 = display airport information
They must be in the order shown, but not all of them are required. For instance you can enter only the Airport ID and the default settings will be used for the last 3 args

For example enter;

  sudo python3 metar_main.py kflg 7 60 0
The display will show the Flagstaff Airport using Layout 7 for 60 seconds before updating using airport info.
Assuming this is works properly, then using the 'webapp.py' and metar.html scripts below will work just fine.

TEST WEBAPP.PY:
From the metar directory enter;

  sudo python3 webapp.py
This will run a Flask module that will run 'metar_main.py'. Flask sets up a web server so we can also run an html file to control the display from any computer, tablet or phone that is on the same WiFi network.

When first run, your E-Paper display will show a screen providing the proper URL to use to access the admin web page. This screen will stay for on 60 seconds then will start to cycle through each display layout from there. Each time the RPi is restarted, the admin URL will be displayed. This will help if the in the future a new IP is assigned to your RPi.

Make note that when webapp.py starts, admin web page information will also be displayed in your SSH client. You will need the URL that it provides. For instance; '* Running on http://192.168.86.71:5000/ (Press CTRL+C to quit)'. This is an example, yours will be different.

TEST METAR.HTML:
Using the URL from the previous step, open a web browser and enter it in the URL. If all is well you will see a web page that allows for easy control of the E-Paper display.

Note: The html file must be run from a computer, tablet or phone that is connected to the same WiFi network using the URL provided when WiFi was originally setup. The URL must have ':5000' appended to the IP Address, ie. http://192.168.86.71:5000/ (Your IP will be different, this is just an example).

SETUP RC.LOCAL FOR STARTUP:
This is optional, but if you would like the display to restart automatically after a shutdown, or accidental power outage then this is a good way to go. Also, the webapp.py must be running for the web interface to work properly.

Enter;

  cd ~
  cd /etc
  sudo nano rc.local

Before the 'Exit' statement add;

  sudo python3 /home/pi/metar/webapp.py &
Then to save and reboot;

  ctrl-x
  y
  sudo reboot now

Note: There may be times when you don't want 'webapp.py' to startup automatically, so simply open up rc.local again and comment out the line that was added then resave and reboot.

SETUP POWEROFF.SERVICE FOR SHUTDOWN:
This is optional as well, but its nice to blank the epaper display when the unit is shutdown. A power outage won't blank the screen, but once the power comes back on it will reset the display if you setup rc.local above.

Copy 'poweroff.service' into /lib/systemd/system;

  cd ~
  cd /lib/systemd/system 
  sudo wget https://raw.githubusercontent.com/markyharris/metar/main/poweroff.service

Enable the service by entering;


  sudo systemctl enable poweroff.service

Copy the python script 'metar_poweroff.py' into /opt/metar_poweroff;


  cd ~  
  cd /opt
  sudo mkdir metar_poweroff
  cd metar_poweroff
  sudo wget https://raw.githubusercontent.com/markyharris/metar/main/metar_poweroff.py

MISC:
At this point the installation is complete, however it is suggested that the image on the SD Card is backed up to your computer in case something goes wrong, rather than going through this installation process again.
To do so;
  • Download Win32DiskImager from; https://sourceforge.net/projects/win32diskimager/
  • Insert SD Card into your computer's card reader.
  • Click the folder icon and locate a directory to store the image and provide a name, ie. metar_display.img
  • Click 'Read Only Allocated Partitions'
  • Click 'Read' and let it do its thing.
  • Once complete eject SD Card and re-install in the RPi
Mount the display and RPi in the frame of your choice and enjoy. - Mark