Author Topic: ESP32 DCF77 transmitter DST issues  (Read 1364 times)

0 Members and 1 Guest are viewing this topic.

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1552
  • Country: ca
ESP32 DCF77 transmitter DST issues
« on: March 26, 2023, 10:51:42 pm »
Hi All,

I made a DCF77 transmitter, link here https://www.eevblog.com/forum/rf-microwave/dcf77-transmitter/ and everything works well except the DST which follows the EU DST and not the NA schedule. I can't figure out where is that defined in the code. I've attached the code, maybe someone can figure out.

Cheers,
Miti
Fear does not stop death, it stops life.
 

Offline CountChocula

  • Supporter
  • ****
  • Posts: 209
  • Country: ca
  • I break things—sometimes on purpose.
Re: ESP32 DCF77 transmitter DST issues
« Reply #1 on: March 26, 2023, 11:54:11 pm »
Howdy! The daylight savings triggers are set in the TZ environment variable, which your code sets in NTP.ino at line 11, using the content of the TZ_INFO macro, which is defined in DFC77_ESP32.ino. This string follows the POSIX TZ format to define the name of the timezone and its daylight savings counterpart, followed by a specification that tells the system when DST starts and ends.

In your case, you have the following spec:

AST4ADT,M3.5.0/02:00:00,M10.5.0/03:00:00

This defines:
  • A standard time timezone called AST that has an offset of 4 hours behind UTC. (that is, you have to add +4 hours to it in order to reach UTC)
  • A daylight savings timezone called ADT that has no offset (which is therefore assumed to be 1 hour) from standard time
  • Daylight savings starts at 2AM on the 0th day (Sunday) of the 5th week of the 3rd month of the year (March)
  • Daylight savings ends at 3AM on the 0th day of the 5th week of the 10th month of the year (October)
I'm not sure when you switch where you are, but you can just make the necessary adjustments and it should work. For example, here in Ontario we switch at 2AM on the 2nd Sunday of March, and switch back at 2AM on the 1st Sunday of November, so our string looks like EST5EDT,M3.2.0,M11.1.0. If you're in Atlantic time, yours is probably very similar, i.e. AST4ADT,M3.2.0,M11.1.0

Note that most UNIX systems also define a set of shorthand strings (such as America/Toronto or America/New_York) for convenience, but these aren't supported by the datetime system on the ESP32 (or, at least, they weren't the last time I checked).


—CC
Lab is where your DMM is.
 
The following users thanked this post: Miti, bingo600

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1552
  • Country: ca
Re: ESP32 DCF77 transmitter DST issues
« Reply #2 on: March 27, 2023, 12:32:10 pm »
The DST start/end are encoded in the TZ_INFO string.

Did you try changing it to just AST4ADT?

It is set to AST4ADT as I think the clock adds an hour. However, I don't want to change the code every spring and fall.
Fear does not stop death, it stops life.
 

Offline MitiTopic starter

  • Super Contributor
  • ***
  • Posts: 1552
  • Country: ca
Re: ESP32 DCF77 transmitter DST issues
« Reply #3 on: March 27, 2023, 12:38:58 pm »
Howdy! The daylight savings triggers are set in the TZ environment variable, which your code sets in NTP.ino at line 11, using the content of the TZ_INFO macro, which is defined in DFC77_ESP32.ino. This string follows the POSIX TZ format to define the name of the timezone and its daylight savings counterpart, followed by a specification that tells the system when DST starts and ends.

In your case, you have the following spec:

AST4ADT,M3.5.0/02:00:00,M10.5.0/03:00:00

This defines:
  • A standard time timezone called AST that has an offset of 4 hours behind UTC. (that is, you have to add +4 hours to it in order to reach UTC)
  • A daylight savings timezone called ADT that has no offset (which is therefore assumed to be 1 hour) from standard time
  • Daylight savings starts at 2AM on the 0th day (Sunday) of the 5th week of the 3rd month of the year (March)
  • Daylight savings ends at 3AM on the 0th day of the 5th week of the 10th month of the year (October)
I'm not sure when you switch where you are, but you can just make the necessary adjustments and it should work. For example, here in Ontario we switch at 2AM on the 2nd Sunday of March, and switch back at 2AM on the 1st Sunday of November, so our string looks like EST5EDT,M3.2.0,M11.1.0. If you're in Atlantic time, yours is probably very similar, i.e. AST4ADT,M3.2.0,M11.1.0

Note that most UNIX systems also define a set of shorthand strings (such as America/Toronto or America/New_York) for convenience, but these aren't supported by the datetime system on the ESP32 (or, at least, they weren't the last time I checked).


—CC

Thank you for a very clear and detailed explanation!
I thought that the DST settings are in the TZ_INFO but then I got pulled on a false track, I found somewhere something about a "na_dst.h" or so file and I tried to find that file but I think that doesn't apply to ESP32 time library.

Cheers,
Miti
Fear does not stop death, it stops life.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf