Digital clock with weather status on a Pimoroni Unicorn HAT HD for the Raspberry Pi
This script relies on:
- AccuWeather to retrieve weather information
- https://sunrise-sunset.org/api for sunrise and sunset information to adjust the brightness accordingly
- Clone this repository
git clone https://github.com/jalenng/unicorn-hat-hd-clock.git
- Ensure you have Python 3 installed
python3 --version
- Install the required dependencies:
pip install -r requirements.txt
pip install -r requirements-sim.txt
(if using the simulator)
- You will need an AccuWeather API account to get an API key: https://developer.accuweather.com/.
- Find the AccuWeather location key for your location.
- Open the file
options.json
with a text editor - Make the desired edits to the file
clock
Name Default Value Description 12hrFormat
true
If true
, clock displays in 12-hour time. Otherwise, clock displays in 24-hour time.demo
false
If true
, the time is sped up, and the screen cycles through the various iconsomitLeadingZeros
true
If true
, the leading zeroes of the hour are dropped. Otherwise, include the leading zeros.color
[255, 255, 255]
An array of values in RGB order. Determines the color of the clock. led
Name Default Value Description fps
10
Desired framerate of the screen minBrightness
0.004
A float between 0.0 and 1.0 that determines the brightness of the screen during the night maxBrightness
0.5
A float between 0.0 and 1.0 that determines the brightness of the screen during the day rotation
180
Rotation of the screen weather
Name Default Value Description enabled
true
If true
, shows and updates weather informationapiKey
N/A Important: Insert your AccuWeather API key here locationKey
N/A Important: Insert your AccuWeather location key here updateInterval
1800
Time in seconds between API calls to get weather data sunrise
Name Default Value Description enabled
true
If true
, updates display brightness according to sunset and sunrise information. Otherwise, display brightness will constantly be at the average ofminBrightness
andmaxBrightness
latitude
N/A Important: Insert your latitude for sunrise/sunset data longitude
N/A Important: Insert your longitude for sunrise/sunset data updateInterval
86400
Time in seconds between API calls to get sunset/sunrise data
- Save your changes to the file
- Run the script to make sure everything is working as intended.
- e.g.
python3 main.py
- e.g.
- Open the file
/etc/rc.local
with a text editor- e.g.
sudo nano /etc/rc.local
- e.g.
- Before the line that says
exit 0
, add the linepython3 <path to main.py> &
- e.g.
python3 /home/pi/unicorn-hat-hd-clock/main.py &
- Be sure to include the
&
at the end
- e.g.
- Save your changes to the file