WiFi Clock

An ESP8266 based LED Clock that automatically sets the time and demonstrates many features of the Sming framework.

Similar projects worth following

In my continuing quest to pay Verizon less money, I got rid of my cable box in my bedroom, which, while saving me money, removed the digital clock display from the room. Wanting to create a project that used the ESP8266, I created a WiFi based clock which set its time through NTP, and updated daylight savings time automatically. You plug the clock in, it sets and maintains the time without any user input, just like the clock on the cable box. The firmware communicates with a Raspberry Pi running Node Red through MQTT. It features the ability to do OTA updates, and can become a WiFi access point that hosts a web page to configure the WiFi network information.

The hardware is fairly straightforward. The display is made up of some eBay specials 1.5" blue 7 segment LEDs where each segment contains 2 blue LEDs. To get across 2 blue LED voltage drops, the clock is supplied with a 7.5V wall wart, and and off the shelf adjustable switching buck module drops the voltage to 3.3v for the logic chips. The LEDs are driven by some NPIC6C596 open drain shift registers controlled by some GPIOs on the ESP-12 version of the ESP8266. A couple of discrete blue LEDs make up the colon and another, the PM indicator, and a TEPT-4400 phototransistor is used to detect the ambient light and dim the display accordingly. A couple of buttons provide reset and OTA flash and a DS18B20 temperature sensor gives the ESP8266 something to do when it is not updating the display. The full schematic is here. The PCB is home made using photosensitive boards as described here.

The software is based on the Sming framework , which provides the ability to do Over The Air firmware updates through the RBoot bootloader, the MQTT connectivity, the Network Configuration web pages, and basic Arduino-like access to various resources of the microcontroller. I setup my development environment using Eclipse. The time display is bit-banged through the shift registers before they are latched in. The display is dimmed with a PWM signal on the enable pin of the shift registers controlled by the value of the ADC reading the phototransistor. Time zone information is broadcast through the MQTT topic by some javascript running on Node Red (because I could not find a good, simple way to get TZ info through an IP Location web service). The TZ message is an MQTT retained message so that the correct TZ is available on the MQTT topic whenever the clock boots up. MQTT also provides a control channel where clock can be put into config mode, start an OTA flash, or the clock can be restarted through an MQTT message. The values from the DS18B20 are published on an MQTT topic every 30 seconds, where Node-Red picks up those messages and publishes to for graphing. Full source code for the firmware is located here.

The project is encased in a 3D printed enclosure made from PETG with the display protected by a transparent blue acrylic cover. The OpenSCAD files for the case are here.

  • PWM and the ESP8266

    Kevin Kessler05/17/2016 at 16:52 0 comments

    Boy those blue leds are bright, and the really need dimmed to prevent the bedroom to be lit up like a movie studio. Unfortunately, PWM on the ESP8266 is somewhat broken, in that you cannot get the duty cycle below about 20%. I only discovered only after I built the clock PCB, so I had to bodge in a single inverter, 74HC1G04, into the !OE line of the shift registers. Now, instead of having a duty cycle of effectively 20%-100%, I have a duty cycle of 0%-80%, and can dim the display enough (about 10% duty cycle). Since the LEDs are so bright, maxing out the brightness at 80% is not a problem. The schematic and PCB eagle files are updated to show this modification.

  • MQTT and OTA update conflicts

    Kevin Kessler05/17/2016 at 16:44 0 comments

    I found that OTA updates were very unreliable when the ESP8266 was connected to the MQTT broker, probably due to the fact that the MQTT keep-alives would interfere with the download of the firmware image. The Sming MQTT client class did not have the disconnect functionality, so I had to add that myself. Because all of the Sming MQTT Client class elements were private, I could not simply derive my class from theirs, I had to create a copy of the Sming class, KMKMqttClient, and add the disconnect functionality. It is a hack, but I now call the disconnect method before the OTA download, and it is very reliable.

View all 2 project logs

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates