RGB Wifi Binary Clock (ESP8266+WS2812b)

by Soumojit in Circuits > LEDs

2386 Views, 9 Favorites, 0 Comments

RGB Wifi Binary Clock (ESP8266+WS2812b)

RGB Wifi Binary Clock (ESP8266+WS2812b)

Hey guys, in this tutorial I will show how to make a cool RGB binary clock with esp8266 and WS2812b addressable RGB Leds that updates time from internet.

Leds and IoT is the things I most like, So I was thinking to build a binary clock and I didn't had any RTC module, I got some esp8266 (nodemcu and esp01) laying around, So I used some addressable Leds to drive all of them with only one data pin and used NTP to get the time from the Internet. That's how I got the idea to build this.

How to Read the Binary Clock

220px-Binary_clock.svg.png

As we are making a clock, we need to know how to read it first.

Binary number is a number expressed in the base-2 numeral system or binary numeral system, a method of mathematical expression which uses only two symbols: typically "0" (zero) and "1" (one).

A binary clock is a clock that displays the time of day in a binary format. Originally, such clocks showed each decimal digit of sexagesimal time as a binary value, but presently binary clocks also exist which display hours, minutes, and seconds as binary numbers
Most common binary clocks use six columns of LEDs to represent zeros and ones. Each column represents a single decimal digit, a format known as binary-coded decimal (BCD). The bottom row in each column represents 1 (or 20), with each row above representing higher powers of two, up to 23 (or 8).

Here is a good explanation about how to read a binary clock: https://www.wikihow.com/Read-a-Binary-Clock

Gathering the Material

IMG20200329211848.jpg
AD272-21.jpg

Okay so we know how to read the binary clock. So, now its time gathering the required materials

  1. ESP8266 (Nodemcu (ESP12E) or ESP01) (Probably you can also use ESP32, need to change some minor coding)
  2. WS2812b Addressable RGB LED * 20
  3. Wires
  4. 5v Power supply
  5. Bread Board (For testing)

You will also need Soldering tools and some basic tools, You can build any kind of case you want its upto you, for the prototype I used a wooden ply board and drilled holes in it (Basically its lockdown and I dont have anything laying around to make a enclosure).

Circuit

Untitled Sketch_bb.png
IMG20200402131422.jpg
IMG20200401224424.jpg
IMG20200402144339.jpg

Now its time to do the connections.

As we are using addressable Leds the connection is pretty simple. Leds are connected in a chain as shown in the diagram, their is 6 columns (Hours, Minutes, Seconds each have 2 columns) the top of the column led data out is connected to the bottom of the next columns first led data in. We need to be careful about the direction of the data flow in the leds.
All VDD and VSS are connected together and with respective pins in ESP8266.

The first Led's data in is connected with the pin D3 of esp8266.

Codes

Screenshot_86.png
IMG20210520130929.jpg

Now its time to write some magical words so the it collects the time from internet and display it in binary.

If you are trying to program an ESP8266 for first time, I will recommend you to look on this tutorial-

https://www.instructables.com/How-to-Program-NodeMCU-on-Arduino-IDE/


Here is the link of the GitHub repository with the code (Don't forget to give it a star) - https://github.com/Soumojit28/binaryclock_esp8266/


You will need these libraries-

Before upload the code we need to change some options in the code-

  • The first thing is Wi-Fi SSID and Password, change it according to your Wi-Fi.
  • Next is the time offset, the time offset is in seconds, you ca easily calculate it by converting your time zone to seconds (Eg- My time zone is +5:30 = (5*60*60)+(30*60)= 19800 seconds)

After changing these you can go ahead and upload the code in your ESP8266 and the clock will be show the time.

Code Explanation and Troubleshooting

Screenshot_87.png

so now a bit explanation about those magical words. So basically the code first make a udp client and uses that to take time from a ntp server with the offset according to the time zone, then it separate it hour minutes and seconds, after that it calls a function that set specific Leds turn on in each columns. It also increase the hue value in loop so the color get automatically changed.

I am currently working on a next version where we can change the time offset color, etc from a web ui. If you wanna help on developing just comment below.

If something is not working first check the serial monitor first. Make sure the SSID and Password of the Wi-Fi is correct. Also check for the led directions and data pin connection with the microcontroller.
If you cant get anytime from ntp try a different server or try with a different WIFI network.

Conclusion

IMG20210520131100.jpg

I hope everyone liked this project. If you have any problems or doubts just comment down and I will try to solve it.

Its was kind a lockdown fun project for me to build with things that I have laying around. It will be nice to see if any one makes a custom case for this project.

As I said before I am trying to make a next version, So comment down if you are interested developing it.

Thanks.