This "Rainbow TIX clock" runs in microPython on an ESP8266.
In addition to an ESP8266 dev board and its power source, it requires:
- A 32 NeoPixel 4*8 display (I use
- An accurate clock source (I use the 52PI RTC, an I2C RTC clock designed for Raspberry Pi and supported in microPython by the following Adafruit library https://github.com/adafruit/Adafruit-uRTC it should be possible to use internal RTC and initialise it from RTP over Wifi, but that is way more complicate and require connectivity)
- An implementation for HSV_to_RGB, I use a version coming from colorsys, I use a simplified version of the full Python Library
- An implementation of random library that contain the sample function, I use a simplified version of the full Python Library
Both the Pimoroni Unicorn pHAT and the 52Pi RTC clock are supposed to be used with a voltage of 5V, but they it seems to work OK with a 3V source. So if you lack 5V source, you can cheat and provide 3V on the 5V pin of both.
To have an accurate clock, the RTC must set to the right time (use local time) and you can do it one of the following ways:
- from a Raspberry Pi reading the 52Pi documentation: http://wiki.52pi.com/index.php/BAT_RTC(English)
- from the ESP8266 in microPython following Adafrult examples: http://micropython-urtc.readthedocs.io/en/latest/examples.html
ESP8266 pinout:
- GPIO 4 is used for I2C SDA to talk to the DS1307
- GPIO 5 is used for I2C SCL to talk to the DS1307
- GPIO 12 is used for controlling the 32 NeoPixels of the Unicorn pHAT
- 3V and GND are also used
Unicorn pHAT pinout link https://pinout.xyz/pinout/unicorn_phat)
- Hardware Pin 2 (5V) is connected to 3V (it should be 5V but it works with 3V)
- Hardware Pin 6 (Ground) is connected to Ground
- Hardware Pin 12 (BMC 18) is connected to GPIO 12
52PI BAT RTC pinout link http://wiki.52pi.com/index.php/BAT_RTC(English)
- Hardware Pin 3 (BMC 2 SDA) is connected to SDA (GPIO 4 of ESP8266)
- Hardware Pin 3 (BMC 3 SCL) is connected to SCL (GPIO 5 of ESP8266)
- Hardware Pin 4 (5V) is connected to 3V
- Hardware Pin 6 (Ground) is connected to Ground
Clock reading explanation
Original TIX clock need more pixels than the 4*8 from the Unicorn pHAT, so information had to be squeezed.
- 4*3 pixels are used to display the hour. All values from 0 to 12 are used. 0 is used for midnight and 12 for midday.
- 4*2 pixels are used to display the number of 10 minutes in the current time (first digit)
- 4*3 pixels are used to display the number of minutes remaining (second digit)
To clearly identify the separate blocks, 3 differents colors are used. Rather than a different fix color for each, a rainbow of color is used, but each pixel of the same block is always in the same color. The pixels turned ON are random, and this is modified every 10 seconds.
This combo make it both easy to read (as it is not moving too much) and easy to know the clock is not stop due to the rainbow effect.