A framework to display weather data on e-ink screen.
Important note: this repo uses submodules.
You should use the command git clone --recurse-submodules https://github.com/pb475/e-ink_weatherdisplay
to ensure all submodules are pulled in and initialised as well.
I tried several free apis to get the weather data I needed, these were either at too low resolution in time, low spacial resolution, or didn't offer the outputs I wanted. Eventually I settled on accuweather. There is the drawback that the api only allows 50 calls per day, but this is plenty for this project.
To get access to the api you will need to set up your own api key. The accuweather developer website can be found here: https://developer.accuweather.com/
The easiest place to start setting up is here: https://developer.accuweather.com/getting-started
I set up a new app with the Core Weather Limited Trial
product added.
This allows 50 API calls per day.
- Go to https://developer.accuweather.com/getting-started and set up a new developer account.
- Create a new app, and be sure to select the
Core Weather Limited Trial
product from the list. - Find the unique API key for the app.
- Create the file
my_accuweather_api_key.txt
. - Paste this API key into
my_accuweather_api_key.txt
. An example of what this should look like can be seen inmy_accuweather_api_key.txt.example
.
You will want to set this up with the latitude and longitude of wherever you want the weather data to point to.
- Head to https://www.latlong.net/, and put in the location, and it should return a latitude and longitude.
- Create the file
my_lat_lon.csv
. - In the newly created file
my_lat_lon.csv
paste in the location_name, latitude, and longitude. You may follow the example as given inmy_lat_lon.csv.example
.
I used a waveshare 800x400 e-ink screen, originally purchased here: https://www.waveshare.com/7.5inch-e-paper-hat.htm The code to draw on the screen is not very flexible as it was quicker to use pixel-based adjustments for drawing the items on screen. If you're using a different screen, much of the code should be re-usable, but I cannot verify that items will be placed nicely.
This project has only been verified as working nicely with a Raspberry pi zero 1.1.
This code is built using python. To keep the repo tidy, the following was removed:
- c code
- examples for other screen sizes
- Jetson nano code
See the original repo here: https://github.com/waveshareteam/e-Paper
Icon files have been gratefully downloaded from https://www.flaticon.com/. These are used to display the weather icons to sceen. Examples:
- Ensure you have the correct version of Python installed.
The version used for this project can be found in
python_version.txt
. - Create a new virtual environment, using a commend like
Python3 -m venv venv
. - Activate the newly created virtual environment, using
source venv/bin/activate
. - Install the requirements from the
requirements.txt
file to the virtual environment. You may use the commandpip install -r requirements.txt.
to do this. - The script
initialise_all.sh
should be run from the command line with./initialise_all.sh
. You may need to make this executable withchmod +x initialise_all.sh
. - Note that depending on when you initialise the code, the forecast might not capture the current hour. Simply wait and the program will correct itself within the hour.
There are three options for the user to modify.
These are found at the top of draw.py
.
- construction - this sets the items placed on the screen to be surrounded with a black bounding box to highlight the edges. This is useful to turn on when continuing development.
- testing - if testing mode is
true
, then the output will be piped toscreen_image/img2display.png
. Iffalse
, then the img should be piped to the e-ink screen. This is for development and testing purposes. - funmode - if
true
, then little scenes will be added depending on the day. By default this is set tofalse
.
Enjoy!
ssh [email protected] weird thing with python packages: screens
We want to ensure the script runs automatically on boot. An easy way to do this is to use crontab. Run the following command:
sudo crontab -e
Select option 1 for nano
text editor.
Then, once editing the file, you should add the following line to the bottom of the file:
@reboot /home/<USERNAME>/Documents/e-ink_weatherdisplay/initialise_all.sh
Where <USERNAME>
is your current username used to set up the raspberry pi.
In this instance, I cloned the repo into my Documents directory.
You may need to change the filepath if you have cloned to a different location.