Calculating Daylight Saving Time


Closed Thread
Results 1 to 20 of 20

Hybrid View

  1. #1
    Join Date
    Mar 2003
    Location
    Commerce Michigan USA
    Posts
    1,166


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    Dwight, Here is the code I flashed into the ESP8266-01 I use for NTP time service. It is NOT ESP8266Basic but the standard AT command set with an added set of commands to interface with the NTP pool.org for the NTP service. It also allows for all of the other AT commands to be used. I found the ESP8255Basic to be too unstable.
    Attached Files Attached Files
    Dave Purola,
    N8NTA
    EN82fn

  2. #2
    Join Date
    Oct 2009
    Location
    Utah, USA
    Posts
    427


    Did you find this post helpful? Yes | No

    Default Re: Calculating Daylight Saving Time

    @Art
    Unless you have a calendar you’d still want the data table anyway.
    Any time you want to add or subtract time you need a calendar.

    If the clock retrieves UTC time as 00:01 1st Jan 2016, and has to subtract one hour.
    It has to know right down to days in month, leap years, the whole lot.
    In my case, my clock does not keep track of the date or year.
    I only use the Day of Week, Month and Date to determine if DST is or is not in effect.

    My ESP module gives me those three items along with the HH:MM:SS and my algorithm then determines whether or not I need to add 1 hour to the provided STD time. After that I don't bother with anything other than HH:MM:SS.

    My code above seems to be working good so far and I did test for DST/STD crossing in both directions and it seems to work.

    @Dave
    Thanks for sharing your code, I'll take a look at it.

    So far my module running ESPbasic has been running solid with this code loaded in the ESP module...
    '================================================= ==========
    '--- This is the code running on the ESP8266-01 module ---
    '================================================= ==========
    '''memclear
    '''cls
    '''timesetup(-7,0)
    '''baudrate 9600
    '''serialtimeout 2000
    '''delay 1000
    '''button "Exit" [Exit]
    '''timer 100 [PicSer]
    '''wait
    ''''
    '''[PicSer]
    '''serialflush
    '''input picin
    '''picin = mid(picin,1,5)
    '''if picin == "Time?" then gosub [gettime]
    '''wait
    ''''
    '''[gettime]
    '''bla = time()
    '''dy = mid(bla,1,3) 'dow
    '''mh = mid(bla,5,3) 'month
    '''dd = mid(bla,9,2) 'date
    '''hh = mid(bla,12,2) 'hour
    '''mm = mid(bla,15,2) 'min
    '''ss = mid(bla,18,2) 'sec
    '''yr = mid(bla,21,4) 'year
    ''''
    '''if dy == "Sun" then dow = "1/"
    '''if dy == "Mon" then dow = "2/"
    '''if dy == "Tue" then dow = "3/"
    '''if dy == "Wed" then dow = "4/"
    '''if dy == "Thu" then dow = "5/"
    '''if dy == "Fri" then dow = "6/"
    '''if dy == "Sat" then dow = "7/"
    ''''
    '''if mh == "Jan" then mth = "01/"
    '''if mh == "Feb" then mth = "02/"
    '''if mh == "Mar" then mth = "03/"
    '''if mh == "Apr" then mth = "04/"
    '''if mh == "May" then mth = "05/"
    '''if mh == "Jun" then mth = "06/"
    '''if mh == "Jul" then mth = "07/"
    '''if mh == "Aug" then mth = "08/"
    '''if mh == "Sep" then mth = "09/"
    '''if mh == "Oct" then mth = "10/"
    '''if mh == "Nov" then mth = "11/"
    '''if mh == "Dec" then mth = "12/"
    ''''
    '''picout = dow & mth
    '''picout = picout & dd
    '''picout = picout & "/"
    '''picout = picout & hh
    '''picout = picout & mm
    '''picout = picout & ss
    ''''
    '''serialprintln picout
    '''return
    ''''
    '''[Exit]
    '''end
    If you want to see the code running on the PIC in the clock just search the forum for "nixie".

    I wonder if you were having problems with a certain version of the ESPbasic OS. Mike did seem to have a couple of versions that were a bit unreliable.

    My ESP module is currently running Version 1.67 of the OS. I think he is up over 1.8x now and I think it is working pretty well also.
    I think the problems were in the 1.7x region of his revisions. (not exact)

    The ESPbasic is based (I believe) on the arduion IDE and the arduino/ESP foundation so if you are competent at the arduino C-like language then that is probably a good way to go.

    I just like the built in IDE of the ESPbasic and it's (for me) easy to understand and no external IDE required.

    thanks all!
    Dwight
    These PIC's are like intricate puzzles just waiting for one to discover their secrets and MASTER their capabilities.

Similar Threads

  1. Calculating time delay between two inputs?
    By grimmjow in forum General
    Replies: 11
    Last Post: - 18th October 2010, 14:52
  2. Calculating Time for clock's preset
    By menta in forum General
    Replies: 33
    Last Post: - 5th July 2008, 06:09
  3. Calculating elapsed time, how?
    By Eng4444 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st June 2006, 09:00
  4. FYI Daylight Saving Time in the U.S.
    By ccsparky in forum General
    Replies: 1
    Last Post: - 7th November 2005, 15:05
  5. Sinus calculating !
    By Don Mario in forum mel PIC BASIC Pro
    Replies: 29
    Last Post: - 28th November 2004, 23:56

Members who have read this thread : 7

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts