Enginursday: OLED Clock Part II

This week I'm getting back to my OLED clock, and discussing the changes I've made.

Favorited Favorite 0

Back in late September I made an OLED clock using our OLED Breakout and a ESP32 Thing. At the time, I was able to use the ESP32 to connect to a Network Time Protocol server to get the time, and created an animation of the segments falling off of the display as the time changed.

Clock Animations

There were a few things that I didn't like about where I left the project, though. The main concern was time zones and daylight savings time (DST). Time zones weren't a big problem, because I only planned on using the clock within the US, and the time zone could be limited to a few selections, but from a global perspective they are not a trivial problem to solve, as Tom Scott explains in this Computerphile episode.

The other problem I had was that I wanted an easy way to configure the WiFi. Originally I had just hard-coded the WiFi, which would have become a problem if I wanted to take it around with me or make more to give away to friends and family. In another clock, I had created a settings webpage where you could connect to the ESP's access point (AP) and load in the WiFi credentials, but I never bothered to turn off the AP once it was connected to the Internet.

Clock Web GUI

So I turned to you, our customers, to ask your advice on how to solve these problems. And you came through and pointed me to some fantastic libraries. For the time zone issue, Jack Christensen created a time zone library around the TimeLib library, which allows you to define when DST begins and ends. Once it's defined, the library will look at the date and decide if the time should be standard time or DST.

WiFi Manager Configuration Page

The other amazing library is the ESP8266/32 WiFi Manager. What I love most about it is how simple it is to use. In your setup function you only need two lines of code: WiFiManager wifiManager; to initialize the library, and wifiManager.autoConnect("AP-NAME", "AP-PASSWORD"); to create the AP. Everything else is contained in the library to connect to your AP and save your credentials to the ESP.

If you'd like to build your own, check out the GitHub repository, which has the Arduino code, schematic and .stl files for the case. Oh yeah, did I mention I added a case? It's not much, just a box really, but it makes it look a bit nicer in my opinion.

OLED Clock

More Work To Do

Like most projects, there's still more I'd like to do. One thing I don't like is that I'm still hard coding the time zone. I'd like to create a simple web page that allows you to select the date or time of the week for DST to begin and end. I also need to adjust the tolerances on the .stl files so the lid and body fit together a little nicer without having to do any sanding, as well as adding a hole for the USB cable to avoid having to take measurements to drill and file the hole.


Comments 5 comments

  • wd6cmu / about 7 years ago * / 1

    As you found out, DST calculations are available. I've built a couple of GPS-based clocks that can figure out their own time zones, I took the USGS maps for the continental US and compressed them down to about 1mi resolution, ended up under 6000 bytes.

  • Member #1375118 / about 7 years ago * / 1

    jaadjd

  • Member #134773 / about 7 years ago / 1

    (Tongue only somewhat in cheek...) One way to solve the DST problem is to move to Arizona, Hawai'i, or (now that they've seen the light) Florida, where it becomes a moot point! :-)

  • max2grand / about 7 years ago / 1

    Very nice. Though, were it me, I might have felt the need to limit it to UTC and add a print out to tape beside it for the time zone. 13:15 [-5].

    But I'm a difficult sort of person.

Related Posts

Recent Posts

Tags


All Tags