Easy Daylight Savings Clock

Introduction: Easy Daylight Savings Clock

Story

This project started out as challenge for me to learn programming (coding) with the Arduino Uno and a single 1602A LCD display, I first wanted to push the Arduino to its limits for accuracy. This is a project to build a clock without the use of a RTC module (Real Time Clock module) and further not use any delay(); commands because the delay(); command halts the code for a determined length of time. As I worked through the basic time keeping code I thought this might be a little mundane so I decided to add a daylight savings time feature as a novel addition to spice things up and possibly create a little more interest in this project. At first the idea was purely novel but the more I work with it and watch the physical clock I have running on my desk the more practical the idea becomes. By adding a RTC module and adjusting the code this clock would be accurate for years to come and at very low cost to manufacturers and the public who purchase such a clock.

Daylight Savings Time or (DST) has been around for 100+ years (Google it, it has quite a colourful history). I don't want to get into the politics of it but it is a crude and painful exercise that does not make life easy for the common people (you and me). For the most part we enjoy the extra hour of daylight but the manner in which it is applied is brutal. It's time for a major upgrade to a very old idea.

This example is easy to live with and with the digital age and advancements in technology easily applied to all forms of digital clocks, but could help the demise of the analog clock. Rather than a 1 hour jump from standard time to DST time then DST time to standard time this clock is based on the gradual progression of time from the winter solstice to the summer solstice then back to standard time at the next winter solstice year after year. This transition takes place for 180 days out of every 6 month period, the adjustment is 20 seconds a day for 360 day with the remaining 5 or 6 days added to the length the solstices. My example here increments 1 minute once every three days within the 180 day cycle. On or about June 21 of each year the clock is a full 1 hour ahead and on or about Dec 21 of each year the clock has slid back to standard time. Leap year is easily accounted for especially if a RTC is used. The Southern Hemisphere is easily adapted to this clock as well, the slide scale is simply 6 months out of phase from the northern hemisphere.

There are three places in the world that DST would be pretty much unless, equatorial region, and the poles. I don't think the daylight changes much at the equator, I don't know if any of the tropical areas even use DST and the poles is a different story again, just 'WHAT' time is it at the poles anyway?

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: About the Clock

The clock I have created is based on standard time which never varies from the internationally accepted world clock, this is displayed on the first line of the 1602 LCD. The second line is the same time scale but it shows the off-set of minutes from one solstice to the next. From the winter solstice to the summer solstice the off-set increases one minute every three days up to a maximum of sixty minutes. From the summer solstice to the winter solstice the off-set decreases one minute every three days until standard time and DST time are the same.

For this example I have used military time (24 hour clock) and standard time (12 hour clock) AM and PM to help those people not familiar with the 24 hour time scale, also it gave my room to display the day number the DST is set from. The code can be changed to display the 12 hour clock. I have added three push buttons connected to digital pins 2, 3 and 4 to adjust time. These buttons will only increase seconds, minutes or hours only. The buttons are optional, the clock will still work fine if you don't wire in the buttons and no need to alter the code. I would recommend at least using a button to adjust the seconds and if complete accuracy cannot be attained keep the clock on the slow side, the button advances the time 1 second per second.

If you start the clock from the Arduino IDE it will take about 5.5 to 6 seconds for the sketch to load and boot, if you have the sketch loaded to the Arduino then plug it into a wall wart or power supply it will take about 2.5 to 3 seconds to boot and run.

There is some manual setup needed when you finally get the clock ready for operation.

This clock does not use a RTC module nor dose it use "delay();" commands.

If you like using the RTC with the Arduino this concept can still be used. The RTC will give you all the information you need to add the EDSC time. The code may be quite different with a RTC module, I have not looked into it. You are pretty much on your own if you do but it's a great way to exercise your brain.

Step 2: What You Will Need

SHOPPING LIST

1 Arduino Uno or Mega2569 (the I2C pins are A4 and A5 on the UNO and 20 and 21 on the 2560 Mega)

Just about any other Arduino should work, the pins used may be different. For that matter, any controller board will work. You will have to rewrite the code for that board or manufacturer.

1 1602 LCD display (colour of your choice)

I use an I2C back pack with the LCD, I find it easier and quicker to set up.

Jumper wires

OPTIONAL SUPPLIES

1 medium size bread board

1-3 momentary contact push buttons

1-3 10 K ohm resistors

This instructable is long, so I'm not going into the mounting or cabinet I've used to display the clock. If you like this project and want to make a permanent version design it to your liking. This design is perfect for me because I had everything I needed in my junk box and I like the looks of it.

NOTES:

To avoid the pit falls of power outages my final clock is powered by a solar panel I have outside. The solar panel keeps a 12 volt battery charged with a regulator on it to prevent over charging. This battery is connected to the Arduino via the power jack next to the USB port. I keep the USB port connected to the grid to reduce draw on the battery. Both power sources can be used at the same time with no damage to the Arduino. A 12 volt battery can be charged to 14.5 volts max which is too high for the Arduino so I use a buck converter to reduce the supply voltage from the battery to a range of 9 to 12 volts. The 12 volt battery I keep charged will last 3 or 4 days if the days are overcast. The regulator I use will cut power to the Arduino if the battery voltage drops to 11 volts. The battery I have comes from emergency light system for commercial buildings, its about one quarter the size of a small car battery. If you intend to use a car battery be sure to keep it in a well ventilated area (outside), car batteries give off hydrogen and oxygen gas as they charge and discharge, this is an explosive combination.

WARNING

KEEP BATTERY IN A WELL

VENTILATED AREA,

OUTSIDE

Step 3: Wiring

I have provided a schematic for all the connections in this project, if you use a breadboard you will need a medium size board, the switches will need room to be spread out so the circuit is not confusing.

The 1602 LCD display has an I2C back pack for simplicity, if you use SPI connections you will need to look up how to use it and alter the code near the beginning of the sketch. I've never used the SPI connections so pins 2, 3 and 4 may not be available for the three push buttons.

The three push buttons are used to adjust the time on the clock. They only advance the time (AHEAD). In the final adjustments keep the clock in the code on the slow side (about 1 to 2 seconds per day or several days) this way you can advance the time if necessary. Each button advances the time one increment per second, the bottom button 2 seconds per second, the middle button 1 minute per second and the top button 1 hour per second. A fairly high degree of accuracy should be doable so you won't need to adjust it very ofter.

If you are adjusting seconds, minutes or hours ( for example if the minutes are advanced 58, 59, 00) the hour will advance to the next hour.

These three buttons are a last minute addition to the clock, they work well but there may be a better way. Just remember that if you mess with this part of the code the "delay();" command cannot be used. I used this method because I don't need to worry about switch bounce and strange jumps in the time advances.

Step 4: What the Display Shows

I have put a lot of information on the 1602 LCD display that needs some explanation:

Line 1 Or line zero '0' when talking in code, shows the standard time. On the left is 'STD', this stands for 'STandarD' time.

Next on the first line in the middle is your local standard time. Do not start with daylight savings time, the clock will display this on the second line.

This time scale is a 12 hour clock so on the right side is 'AM or 'PM' to indicate morning or after noon.

Line 2 Or line one '1' when talking in code, shows the daylight savings time which varies according to the day of the year. The 'DST' on the left means 'Daylight Savings Time'

In the middle of the second line is your local military time which is a 24 hour clock. You will hear it referred as 'oh six hundred hours' for example.

On the right side is the day of the year as referenced from the winter solstice, in the Northern Hemisphere December 21 (approximately) is day zero '0' and in the Southern Hemisphere June 21 (approximately) is day zero '0'.

I have provided two .pdf files for reference when first setting up the clock. Choose the file that refers to the hemisphere you live in.

The three buttons on the right increment seconds, minutes and hours from bottom up.

Step 5: Sketch Setup

There are several lines of code that need to be set up for the initial start up. Some of these lines need to be changes each time you disconnect the clock and change the values of the variables in the sketch. If you start the clock for the IDE it will take about 6 seconds to load and start. If you load the sketch from the IDE then disconnect the clock and restart it from a wall wart or power supply the sketch will boot up in about 2.5 seconds.

Line 11 LiquidCrystal_I2C lcd(0x27,2,1,0,4,5,6,7);

This line addresses the LCD display and sets the proper address of the I2C back pack. 0x27 is the address of any of the back packs I bought. If you power up the clock but there is no data displayed but it lights up the address is probably different on you LCD. I will put a link below for a description of how to change the address of your LCD back pack or find the address.

Lines 24 int minuteSt = 35;

Set the start minute for the standard clock, usually set it 5 minutes before you start the clock to allow for setup time.

Lines 25 int hourSt = 18;

Set the hour to STD time (24 hour clock) is starting in. 6 PM would be hour 18.

Line 26 int DSTdays = 339;

Download and refer to the "Easy DST Clock Time Scale" pdf file (Northern or Southern Hemisphere) you live in, look up the date and insert the Day # into this line. (Left column). Example (Nov 24 is day #339 in the Northern Hemisphere and day #156 in the Southern Hemisphere)

Line 27 int DSTyear = 2019;

Enter the current year.

Line 92 if ((masterTime - previousMasterTimeSt >=1000) && (microTime - previousMicroTimeSt >= 500)){

The "previousMasterTimeSt" needs to be compared to the number of milliseconds so this '1000' may need to change to 999 depending on the internal clock of the Arduino board then adjust the previousMicroTime to fine tune the clock. The internal clock although 16MH has variations from one board to the next.

The "previousMicroTimeSt" fine tunes the internal clock to help count off an accurate 1 second. If the clock is too fast increase the microseconds and if the clock is too slow decrease the microseconds and if need be drop the milliseconds to 999 and then start the microseconds at about 999,990 or increase the speed the clock.

Each Arduino board has a slightly different speed therefore these numbers will change with each board you use. Part of the code has not yet been tested, this is line 248 to account for each leap year. In the next few weeks I will test it and post any changes if necessary.

Step 6: Final Notes

This project is easy to build but the concept and necessary adjustments in the code may be a task, take your time and think it through, the clock doesn't expire until the end of 2037. I am going to keep a close eye on my email for questions as I'm sure there will be some, I am not a literary genius so some of my descriptions may be a bit muddy.

There are two .pdf files included, download the file for the hemisphere you live in, this file will give you necessary information to start the clock accurately.

With the information manipulated in the sketch it would be easy to display not only the standard time and DST time but also day and date on a 2004A LCD. If you like the challenges this project provides try connecting a 2004A LCD display then add code to display the additional information or if enough interest is shown I will do another variation of this project including this additional information.

I've tried to be all-inclussive in this project but I found three areas in the world in question. The North Pole, the South Pole and the Equator.

Is DST necessary or even possible on the North or South Poles?

What time is it on the North or South Pole?

What direction would you travel to leave the North Pole or South Pole?

From the South Pole what direction would you travel to reach Austrailia, North America, Europe or Asia?

What time zone does Santa live in?

Does he need DST?

What time is it anyway at the North Pole?

What direction does Santa travel to deliver all his gifts?

At what latitude is DST effective?

Now for the Equator;

Is this clock useable at the Equator?

Would they use the Northern or Southern Hemisphere scale?

What is the dates for the winter solstice and summer solstice?

At what latitude is DST effective?

Do the penguins need DST?

Do you think I'm weird for thinking about these questions?

Happy building everyone!

philmnut

Step 7: Other Links

This is a link to determine or change the address on the I2C back pack:

https://www.instructables.com/id/1602-2004-LCD-Adapter-Addressing/

PiotrS has written an excellent instructable for I2C hardware addresses

http://playground.arduino.cc/Main/I2cScanner

This link will scan your I2C device and return the address

Be the First to Share

    Recommendations

    • Trash to Treasure Contest

      Trash to Treasure Contest
    • Raspberry Pi Contest 2020

      Raspberry Pi Contest 2020
    • Wearables Contest

      Wearables Contest

    Discussions

    0
    tytower
    tytower

    19 days ago

    I particularly liked the time travel pictures .
    Time travel is just a science fiction fantasy the same as religion . There is not one piece of tangible evidence that either can be fiddled with . In both instances the other places would be packed out. Everyone would want to get there. Einstein was wrong ....and who gets to choose what goes and what stays?. Insects ,Cromagnon man,worms,infectious viruses? They are all "life".

    Seems to be valid work on the clock so Ill have a look and get back to you.