NO MORE SPRING FORWARD

by msuzuki777 in Circuits > Arduino

743 Views, 4 Favorites, 0 Comments

NO MORE SPRING FORWARD

UltimateClock.jpg
OldAlarm.jpg

Alternate Title: IP Time Clock part 3

If you like it, I’m entering this in the Clock contest.

Are you tired of having to Spring Forward?

Are you tired of having to Fall Back?

Well, I am. I have this old alarm clock that fixed this (for a while)(See Picture) It would automatically adjust for Daylight Saving Time and (I think) it has battery backup in case you lose power. Unfortunately, several years back, the U.S. decided to change the days for changing time. So now this clock needs to be manually changed four times a year! I use this only as a backup.

So this Lazy Old Geek (LOG) wanted the perfect clock. Everybody is different and times change (Ha!Ha!) and ideals change. Here’s my Ideal Bedroom Clock.

Always visible at night. CAVEAT: No blinking seconds at night, that’s too distracting.

Automatic DST (Daylight Savings Time). I hate having to change clock times twice a year.

Displays day of the week. Since I’m OLD and can’t remember.

So I do like seconds in the a.m. The ad says gargle for 30 seconds, so I like a clock that display seconds.

No blue light. We all know blue light is bad for you. Not always true, see this:

https://www.instructables.com/id/Blue-Light-Proje...

Okay, that’s pretty simple. Many clocks are visible at night and many are not blue. Some are ‘atomic’ clocks which adjust for DST. Actually some of my ‘atomic’ clocks I have to fiddle with DST changeovers.

Now the seconds situation is more specific. I actually designed my own to do that in this Instructable (although I noticed I didn’t explain it very well):

https://www.instructables.com/id/IP-Time-Clock-Par...

This clock lasted about four years, relatively maintenance free until a couple of months ago when it stopped working.

Fixing, First Step

Black screen.jpg
ESP-03 Header.JPG
MAX7219.JPG

Blue screen of death, IP Clock (actually it's black).

Technobabble:

A brief description of IP Clock. It uses an ESP-03 microcontroller, this connects to the internet with WiFi. I soldered two 2mm male header strips on the ESP-03 so it will plug into a socket on the PCB.

It uses two seven segment-3 digit displays like: https://www.aliexpress.com/item/4000300425570.htm...

I don’t remember if these were common cathode or anode.

A Max7219 to drive the displays and the individual LEDs for days of the week.

For more details, please look at my IP Clock part 2 Instructable.

Well, the first thing I tried was to reprogram the ESP-03 (microcontroller) so I looked at my Instructable and tried but it wouldn’t let me program it.

IRRELEVANT HISTORY: Okay, I’m an OLD man so my mind wanders. One of the reasons I got into Instructables.com was that it had great Instructables on Arduino. It was one of the primary reasons I got into Arduinos and learned how to use them. Instructable writers are at all different levels and skills but I can often find some that are at a level I can understand. So thank you Instructables for helping me out over the years.

To return the favor, I write Instructables that I hope will help others.

A second reason I write Instructables is to help me remember how I did projects. While writing Instructables I try to provide all of the details to do what I did. Apparent to me I don’t always do a good job.

Okay, I put the IP Clock on a back burner.

My theory is that more blue light gave me more energy (see above blueproject Instructable) and focus to revisit this problem. What I finally figure out was that the method I was using to program the ESP-03 no longer worked. I wrote this up in another Instructable:

https://www.instructables.com/id/2020-ESP8266/

Problem 1 solved, I can now program ESP-03s with Arduino sketches.

Fixing Next Problem

Black screen.jpg
EERO.jpg
TP_Link.jpg

Well, I programmed an ESP-03 with my old Arduino sketch, put it in my IP Clock, still didn’t work. The way, I’d written the sketch, nothing was displayed until a successful connection to the Internet and NTP server (provides accurate time on the Internet) was made so I had a blank screen.

Using the Arduino Serial monitor, I could see that it wasn’t connecting to the NTP server.

NOTE: The ESP-03 uses an ESP8266 microcontroller. One of the nice things about the ESP8266 is that it has built in WiFi. In technical terms it can connect to a WiFi hotspot or WiFi router which many homes, including mine, has.

Getting pretty technical here, new WiFi routers have two bandwidths, 2.4GHz and 5.0GHz. (See picture for my router) I like to think of them as the difference between AM and FM radio. (Remember those?)

A limitation of ESP8266 is that they only use 2.4GHz bandwidth.

More technical stuff, when you connect to WiFi you need an identifier called an SSID. It’s like an individual radio station, K Earth 101. And for security reasons, you also need a password.

Well, many WiFi dual band routers (2.4GHz and 5GHz) use the same SSID for both bands.

Anyway for some reason, I couldn’t connect an ESP-03 with my router. I seem to recall other people having similar problems.

Bottom line: I setup another router that had separate SSIDs for 2.4 and 5 GHz band, e.g., "mtslink24" and "mtslink50" and was able to talk on Internet.(See Picture)

WARNING: If you have a dual band router with the same SSIDs on both bands, it may not work with ESP8266s.

Fixing Last Problem

NTP server.png

What I was seeing was that I still couldn’t connect to NTP server. I found another Sketch to see if I was able to use the Internet and that worked, so the next problem seemed to be connecting to the NTP server.

Well in my original sketch, I used an IP address to connect to an NTP server:

https://tf.nist.gov/tf-cgi/servers.cgi

So I tried several IPs from Boulder and FT.Collins which are pretty closer to where I am. None of them worked. Did some playing around and actually got a global sketch to work but it would only lock in maybe one out of five times. Did some more research and found something called pool.ntp.org. Apparently what this does is rotates through a bunch of IP addresses so no single address is overloaded and all of them should be active.

Well, I don’t really understand this WiFi programming all that well, but managed to find an example that I could adapt to my sketch and got it to work. Yippee!

Arduino Sketch

Arduino-Logo.jpg

Attached is my working sketch, Special.ino

Here’s some comments about it:

This is where you put your own SSID and password. (This must be 2.4GHz.)

char ssid[] = "YourSSID"; // network SSID (name)

char pass[] = "Your SSID Password"; // network password

Using pool.ntp.org server list.

IPAddress timeServerIP; // time.nist.gov NTP server address

const char* ntpServerName = "pool.ntp.org";

//get a random server from the pool
WiFi.hostByName(ntpServerName, timeServerIP);

Two DST functions:

void findChangeDates(); // Find Spring/Fall change dates

bool IsDST(); // Check if it is DST

findChangeDates(); takes the current year and figures out what days in March and November are the changeover dates

bool IsDST(); determines if the current day is DST or not

void digitalClockDisplay()

Well, unfortunately my old brain can’t figure this out any more. What I think it does is turn off the seconds display after 9p.m. and turns them back on around 5a.m. I find it very annoying to look at a clock when I’m in bed and see the seconds ticking off. But when I get up in the a.m. I like to see the seconds so I can ‘time’ my gargling.

Downloads

Programming the ESP-03 & Conclusions

ModSchematic.png

I am currently using Arduino version1.8.12.

The easiest way for me to install the ESP8266 stuff is using Board Manager using this method:

https://github.com/esp8266/Arduino#installing-with...

Once installed, when selecting Board, I select “Generic ESP8266 module”.

WARNING: On my PC there are two versions of “Generic ESP8266 module”. The one under the category “ESP8266 boards” works, the one under Sparkfun does not.

Well, I am lazy. What I actually did was take an ESP-03 and programmed it in my modified ESP adapter from:

https://www.instructables.com/id/2020-ESP8266/

What I could’ve done is modify my IP Clock 2 PCB according to this schematic just adding a couple of jumpers.

In addition, I modified a CP2102 USB adapter to have RTS connected to the pin next to GND.

With these modifications, it’s like loading a regular Arduino sketch without having to push any buttons.

CONCLUSIONS: Well, I like my IP Clock. It meets all of my criteria. Despite what the picture shows, the LEDs are red not white so no blue.