Introduction: True Binary Clock With NTP Sync
A true binary clock displays the time of day as a sum of binary fractions of a full day, as opposed to a traditional "binary clock" that displays time as binary-encoded decimal digits corresponding to the hours/minutes/seconds. Traditional "binary clocks" are really using binary-encoded-decimal-encoded-sexagesimal. What a mess! True binary clocks simplify things immensely.
In a true binary clock, the first digit tells you is the half day, the second digit is a quarter day, the third digit is an eighth of a day, etc. It can be read to any resolution very quickly (with practice of course). The first digit effectively encodes AM versus PM, the second digit encodes whether it's early AM/PM or late AM/PM, and so on.
In designing my true binary clock, I used twelve digits of resolution, so the day is divided into 2^12=4096 parts (each increment is approximately 20 seconds). Instead of keeping all the digits in a line, the 12 digits were separated into 3 rows of 4 digits. Though the actual binary digits are unchanged, this allows the clock to be read as 3 binary-encoded hex digits, the first line showing 16ths of a day (1.5hrs), the second line showing 256ths of day (~5 minutes), and the third line showing 4096ths of a day (~20seconds).
The clock is synced to NTP (Network Time Protocol) using an ESP8266. The ESP8266 is configured so that, on startup, pressing a button on the clock will send it into settings mode. In settings mode, the clock will create a WiFi network that serves up a webpage that can be used to enter your own wifi settings, NTP server, and timezone. This information is stored in the EEPROM of the ESP8266 and is read when the clock starts up in clock mode so that it can connect to internet and retrieve the time.
Supplies
- NodeMCU ESP8266
- WS2812B LED strip
- Pushbutton
- 470 Ohm resistor
- 10K Ohm resistor
- 470 uF capacitor
- Popsicle sticks
- Marbles
Wood (or other sheet of material) for the case
Step 1: Circuit
In order to have a display, this project uses a RGB led strip laid in 3 rows. I cut 3 strips of 8 leds from the strip of WS2812B leds and soldered them together. (They are fragile and soldering the small pads can be difficult. I wrapped the soldered ends in electrical tape so as to insulate them from any bending.) Even though I only needed 4 leds per row, I cut out strips of 8 so that I could have greater spacing between the lights by only using every other led. These strips were then stuck to a flat base made of popsicle sticks. In between each row, a double layer of popsicle sticks provides the profile so that the front face can be stuck against the inside of the case of the clock (see photo).
The led strip is powered from the VU and GND of the NodeMCU. VU is power coming (almost) directly from the USB, so it provides 5V to the WS2812B LEDs even though the ESP8266 works at 3.3V. I placed a 470 uF capacitor across the power for the WS2812B strip to protect the leds. Data for the led strip is connected to the D3 pin of the NodeMCU via the 470 Ohm resistor. Refer to this instructable for more info on how to control WS2812B leds with the ESP8266. The circuit was soldered onto proto-board with some male-to-female headers for the NodeMCU.
A pushbutton was also attached to D6 of the NodeMCU. This pushbutton can be pressed while the clock is starting up to send it into settings mode (in which wifi settings, NTP server, and timezone preferences can be modified). On one end the pushbutton is connected to D6 and also to GND via a 10K Ohm resistor and on the other end it is connected to power. When the button is unpressed, D6 reads low; when it is pressed, D6 reads high.
Step 2: Software
The software for the ESP8266 was written using Arduino code. The LEDs are handled using the FastLED library and NTP syncing is done by the NTPClient library. Time is synced by NTP every hour.
At the start of the setup function, the program checks to see if the button connected to D6 is pressed. If it is, the ESP8266 creates a wifi network (the SSID and password can be changed in the code, default SSID is "TrueBinary" and password is "thepoweroftwo"). Connect to this network from any device and navigate to 192.168.1.1. The ESP8266 will serve up a webpage with forms where you can input your wifi SSID and password, preferred NTP server, and timezone offset from UTC. After these forms are submitted to the ESP8266, it will save the info to its internal EEPROM storage.
If the button is not pressed, the clock starts up normally, reads the settings from EEPROM, connects to wifi to use NTP, and starts displaying the time.
NOTE: the function setDisplay(int index) takes the digit number from 0-11 where 0 is the first digit (the half day) and 11 is the last (1/4096 of a day) and turns on the corresponding LED using the "leds" array. This function has to be filled in according to how you configured the display. My commented out example corresponds to how I soldered the rows in a zig-zag fashion rather than end-to-end and skipped every other LED.
Attachments
Step 3: Housing
To house the clock, I used an angle of painted wood I happened to have. On one outer face, I drilled 12 holes in a grid corresponding to the positions of the LEDs. I then stuck the LEDs to the inside of the angle by gluing the raised faces of the popsicle sticks in-between the rows to the wood (as shown). To diffuse the light from the LEDs, I stuck glass marbles on top of the holes. I accomplished this by dipping the bottom half of each marble in epoxy resin and then placing them in the holes. The NodeMCU and proto-board were screwed into the other inside face of the angle. The sides were covered using small triangles of wood, attached with wood glue. One of the sides has a hole for the micro USB port of the NodeMCU and a cut in the corner for the pushbutton.
Step 4: Done!
Our true binary clock is finished! To set it up, keep the button pressed while plugging it in to put it in settings mode and then enter the WiFi credentials on its webpage. Once set up, the clock can be plugged in anywhere and will automatically connect to the internet and begin displaying the time in binary.
It takes a spot of practice to read time in true binary format, but it's a fun exercise and after a while it becomes a quick way to get the time with only a glance!