Skip to content

Python script that shows time and weather on a 16x16 LED display

Notifications You must be signed in to change notification settings

jalenng/unicorn-hat-hd-clock

Repository files navigation

Unicorn HAT HD Clock

Digital clock with weather status on a Pimoroni Unicorn HAT HD for the Raspberry Pi

This script relies on:

GIFs

GIF of the clock

sun sun and cloud clouds fog

rain rain and cloud storm snow

snow and cloud hot cold wind

moon moon and cloud loading disconnected

Instructions

I. Download the required files

  1. Clone this repository
    • git clone https://github.com/jalenng/unicorn-hat-hd-clock.git
  2. Ensure you have Python 3 installed
    • python3 --version
  3. Install the required dependencies:
    • pip install -r requirements.txt
    • pip install -r requirements-sim.txt (if using the simulator)

II. Configure AccuWeather

III. Configure the options

  1. Open the file options.json with a text editor
  2. 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 icons
      omitLeadingZeros 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 information
      apiKey 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 of minBrightness and maxBrightness
      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
  3. Save your changes to the file

IV. Run the script

  • Run the script to make sure everything is working as intended.
    • e.g. python3 main.py

V. Schedule the script to run on startup

  1. Open the file /etc/rc.local with a text editor
    • e.g. sudo nano /etc/rc.local
  2. Before the line that says exit 0, add the line python3 <path to main.py> &
    • e.g. python3 /home/pi/unicorn-hat-hd-clock/main.py &
    • Be sure to include the & at the end
  3. Save your changes to the file

About

Python script that shows time and weather on a 16x16 LED display

Topics

Resources

Stars

Watchers

Forks

Languages