Beginner friendly weather dashboard designed for Raspberry Pi computers paired with an external display.
-
You should understand the following concepts before utilizing this program:
- Terminal based text editors (such as
nanoorvim). - File navigation in Linux.
- How to read Python code and understand what it is doing.
- Understand basic Bash commands and Linux terminal usage.
- How to get an API key from OpenWeather.
- Modifying CSS (SASS).
- Read and understand the license provided with this project.
- Terminal based text editors (such as
-
You can modify program configuration in the
config.pyfile. -
You can calculate how frequently you can run this program while staying under the "1,000" free calls limits using the
calculate.ipynbfile. (You will need a program that can run Jupyter files).- The default configuration should keep you under the 1,000 call / day limit. However, you are responsible for ensuring you will not exceed the 1,000 free call per day limit, even with the default configuration.
- It is good practice to double check any code you use to ensure it works how you want it to work!
- The default configuration should keep you under the 1,000 call / day limit. However, you are responsible for ensuring you will not exceed the 1,000 free call per day limit, even with the default configuration.
# Ensure you have the latest updates (if cloned from main repo)
git pullTwo options exist to install dependencies. Pip,
which is included with Python (and by extension Raspberry Pi OS), and Pipenv, which requires a separate installation (sudo apt install pipenv).
- Use
pipif you are a beginner with Python & Raspberry Pi / Linux - Use
pipenvif you are a more advanced user of Python & Raspberry Pi / Linux.
# Set up virtual environment
python -m venv .venv# Enter virtual environment
source .venv/bin/activate# Install packages
pip install requests jinja2 python-dotenv playwright ipykernel# Install playwright
playwright installTo install pipenv on Raspberry Pi, run the command: sudo apt install pipenv
Run the following commands from root of the project directory to setup project:
# Ensure virtual environment is created within project root directory
# You can either run this command every time you use this project or paste it in your `.bashrc` file (located in home directory).
export PIPENV_VENV_IN_PROJECT=1# Install dependencies & set up virtual environment
pipenv install# Enter virtual environment
pipenv shell# Install playwright
playwright install# Start program (must be in virtual environment)
bash run.sh# Run Jinja Python Script (on its own) (must be in virtual environment)
python jinja.pyOptional: The following command is not required to use this project. CSS will be kept up-to-date if this program is ever updated, so you do not have to build it yourself. The following is provided in case I forget to provide updated CSS or you wish to compile the CSS file yourself.
# Install Sass (Node.Js Required, use Node Version Manager (NVM))
npm install -g sass
# Compile .sass to .css
sass styles/style.sass styles/style.cssIncluded is a file named .sample.env. This file is prepopulated with all environment variables set to blank values.
For this project to run you must complete the following:
-
Obtain an API key from OpenWeather
- Note: The code and setup instructions for this program are written to stay well below the "1,000 API calls per day for free", however developers of this code are not responsible for any charges that may occur for use of this API in conjunction with this code. You should audit / test this code yourself to ensure you will not exceed the API call limit, especially if you modify it for your needs.
- This project uses the following APIs:
- One Call
- Geocoding (optional, can be set manually from
config.py) - Air Pollution
-
Populate the environment variables with your API key & coordinates. You are responsible for finding the coordinates you wish to use.
-
Remove the comments from the top of
.sample.env -
Rename
.sample.envto.env
You should now be able to properly populate an html file (weather.html) from the template.html.j2 file by running the python jinja.py command.
For the automation to work properly, you must give necessary file executable permissions. Execute the following commands to do so.
chmod +x run.sh
chmod +x jinja.py
chmod +x screenshot.pyIf you wish to revoke executable permissions for any reason:
chmod -x run.sh
chmod -x jinja.py
chmod -x screenshot.pyIf prompted to select a text editor, it is recommended to select nano for its simplicity, but choose whichever you are comfortable with.
# Setup a cronjob for the run.sh script to be run every 5 minutes.
export EDITOR=/usr/bin/nano
crontab -eAdd the following line to crontab (you must modify the following line with your file path to the run.sh file):
*/5 * * * * bash ~/path/to/run.sh
# Cancelling the cronjob
# Run the following commands and remove the line added in the "Setup" section.
export EDITOR=/usr/bin/nano
crontab -eNote: These explanations are not written by a meteorologist. They are intended to be an introduction to each term. If you wish to learn more about any of the terms below, you are encouraged to research them using scientific books and websites.
Temperature is the measure of the kinetic energy of the vibrating atoms of matter.
- Kelvin: Thermodynamic temperature measurement unit starting at the lowest possible temperature of 0 K (absolute zero).
- Absolute Zero: The lowest possible temperature in which any atoms of a substance cease to vibrate.
- Celsius: Temperature system where the freezing point of water = 0Β° and the boiling point of water = 100Β°.
- Fahrenheit: Temperature system where the freezing point of water = 32Β° and the boiling point of water = 212Β°.
- Direction: The direction the wind is coming from / traveling in.
- Speed: Speed in which the wind is traveling.
- Gust: A sudden increase in wind speed.
- Definition: Concentration of water vapor present in the air, indicating the likelihood for precipitation, dew, and/or fog to be present.
- What does 100% humidity mean?: 100% humidity means the air is holding the maximum amount of water it can at its current temperature.
- Definition: How far a healthy human eye can see factoring in meteorological obstacles such as fog, clouds, and more.
- Definition: Force exerted by the body of air above an area.
- How is it measured?: A mercury barometer can be used, with the height of the mercury in the barometer changing with the barometric pressure surrounding it. It is measured in pascal units (Pa), with 1 Pa = N/m^2 (1 newton (N) = 1 kg * m/s^2).
- What is
hPa?: hPa stands for hectopascal (1 hPa = 100 Pa)
- Definition: Measurement of the intensity of ultra-violet radiation. Higher UVI results in increased risk of sunburn.
- Definition: Measurement of how polluted the air is at a given time.
- Definition: The temperature air has to be cools to for the relative humidity to be 100%.
- Definition: Volume of the sky covered by clouds, measured as a percentage.
Moon phases are caused by the Moon's position in Earth's orbit and how much light is shone on the visible surface of the moon. The below image by Nasa does a good job visualizing what causes the phases of the Moon.
