Intro: NeoPixel NTP Clock Using ESP8266
I recently had an idea to build a clock using NeoPixel ring and the popular ESP8266 module. I am sharing the instructions for others who may want to do the same/similar and save some time.
The hardest part was getting the code right; as I was using a clone of the Adafruit NeoPixel ring, it was wired in reverse, meaning that the led's were addressed in anti-clockwise direction. I therefore had to compensate for that in the firmware.
Step 1: About the Project
Like one of my previous projects (WiFi enabled MP3 player) I am using the Wemos D1 mini ESP8266 module, however in this project I decided to use the Arduino IDE to write the firmware. The module comes ready to be programmed this way so it saves one extra step of installing the MicroPython interpreter.
Step 2: Parts Required
The part list for this project is very brief making it a pretty simple project.
There are many variants in types and sizes of the NeoPixel ring, I am using a clone of the Adafruit 60 led ring which is best suited for a clock. The ring is sold as 1/4 circles with 15 LED's per 1/4. These retail for approximately $10-15 in the US or you can get them for a lot cheaper from China if you are willing to wait a month or so for shipping.
Step 3: Assembly and Wiring
I wanted to make this really simple and keep the wring to a bare minimum. So I ended up with a solution that uses just three wires. Two for the power, ground and VCC and one for data.
Assemble the Ring
The first step is to assemble the 4 1/4 rings into one full circle. At the back of the ring you should see solder pads labeled 5v, Gnd, DOUT and Din.
You need to form a full circle and solder 5v to 5v, Gnd to Gnd and DOUT to DIN all the way round accept the last section of the ring where you have to leave the DOUT and DIN separate. (see picture)
Cut, strip and solder one end of the DuPont cables to DIN, 5v and GND on the first ring. Note DIN on this ring should not be connected to the DOUT of the adjacent ring as these mark the start and end point.
Now connect the 5v and Gnd to the 5v and Gnd of the ESP8266 and the DIN from the ring to one of the digital pin of the ESP8266, I used D4 as it is right next to Gnd and 5v.
Step 4: The Firmware Code
In keeping things simple the code for the firmware is fairly simple after going through several iterations and simplifying things as much as possible.
In use there is simply an initial step of configuring the ESP8266 module to connect to your local Wifi and from there on it works completely autonomously get it's time from an NTP server and updating the clock face accordingly. Whilst others have used a more elaborate visual display I have kept things deliberately simple. In doing so I have managed to keep the amount of current required a relatively low value so that the ring can get it's power from the ESP8266 module instead of needing an external power supply.
At any given instance there are just three LED's active, I use color to signify what each represents, Hour, Minute and second.
You will need the following libraries for everything to work.
Most of these are available directly through the arduino IDE; However you will have to manually add the WiFi Manager library. The WiFi manager library is a very nice utility that provides WiFi configuration magic by initially setting the ESP8266 module in access point mode and serving a web page through the HTTP server that allows the user to select a local WiFi and set the password so that the ESP8266 module can reboot and connect to it.
- Check out the details for the WiFi manager on Github
At initial setup you will need to use a smartphone or any other wifi client to connect to the clocks AP and using a browser to configure it's WiFi to act as a WiFi client. From there on it will automatically connect to WiFi and get it's time from a pool of NTP server.
check out the video to see this working.
The code has been published on My Github Repository
diverich made it!