bablokb / circuitpython-clock

A Clock for E-Ink Displays like the Badger2040 or Magtag
GNU General Public License v3.0
3 stars 1 forks source link

A Clock for E-Ink Displays

This project implements the software for an e-ink clock using CircuitPython. The clock displays the current time and is updated every minute. It also supports the display of temperature and humidity.

Update of date and time uses an attached ESP-01S (unless you use a board with integrated WLAN like the Badger2040W, Magtag or a PicoW). Update occurs at system startup and once a day. An external RTC is used to keep date/time in case this update fails.

The software is optimized to minimize battery usage. E.g. you can define an "active" period during the day when updates take place, otherwise the clock is left in deep-sleep.

Hardware

You need the following components:

Out of the box the software supports:

Porting to other hardware should be easy (see section "Hardware Hacking" below).

Wiring

Sensor and RTC use I2C. Connect to Stemma/Qt or respective pins. The ESP-01S uses UART (RX, TX), a reset-GPIO, 3V3 and GND.

The Magtag only needs the RTC and the sensor. The Badger2040 has suitable pads on the back for UART, 3V3 and GND. Use the INT-pad for the ESP-01S reset.

The Badger2040W only needs the sensor.

Installation

  1. Install the current version of CircuitPython to your device

  2. Install the following libraries from the CircuitPython library-bundle to the lib-directory of your device

    • adafruit_ahtx0
    • adafruit_bitmap_font
    • adafruit_bus_device
    • adafruit_display_shapes
    • adafruit_display_text
    • (adafruit_ds3231)
    • adafruit_espatcontrol
    • (adafruit_pcf8523)
    • adafruit_register
    • adafruit_requests
    • (circuitpython_pcf85063a)

      The preferred way to do this is to use circup (note that the device must be mounted):

      sudo apt-get -y install pip3 sudo pip3 install circup circup --path /mountpoint/of/device install -r requirements.txt

      You can save some space if you delete the unneeded rtc-drivers.

  3. Clone the repository

  4. Configure the software for your board and preferences. See Configuration below.

  5. Copy all files from below src to your device.

Configuration

For configuration, you need the python-file configuration.py in the root-directory of your device. You can find a template in `template/configuration.py'. Copy this file to your device and adapt it to your needs. For some specifc hardware, you find special configuration templates in the directory.

There a few things you should change:

Other settings (like ui.*) are optional and let you tweak the appearance and behavior (especially useful on other hardware).

Hardware Hacking

To support alternative hardware, you might have to implement a few lines of python-code. You need a suitable configuration.py and maybe a board-config-file.

The configuration.py not only contains settings, it also creates the Python-objects wrapping the hardware. The template-directory contains a few sample configuration files.

Board-specific functions (like battery-level or pin-alarms) are in a file within src/config. The file has the name <board-id>.py (with "-" replaced by "_" in the board-id).

If no board-specific file is available, the system uses src/config/def_config.py, which might already be sufficient.