Skip to content

Conversation

@mjcross
Copy link
Contributor

@mjcross mjcross commented Oct 26, 2025

A proposed new NTP example that differs from the existing pico_w/wifi/ntp_client in the following ways:

  1. uses the SNTP app already provided by lwIP (in threadsafe background mode)
  2. uses pico_aon_timer to create a time-of-day clock that can be read asynchronously from user code
  3. illustrates the use of a POSIX timezone (TZ) to convert UTC to local time with daylight saving
  4. includes a README.md to explain what the example does and how to use it

The program connects to Wi-Fi, initialises the lwIP SNTP app, syncs the pico_aon_timer to NTP and then enters a loop to display the local time in London (or UTC, or whichever timezone the user defines); resynchronising to ntp.pool.org in the background every hour.

I suggest it's quite an important use case for the Pico-W, and illustrates a couple of features users may find helpful (such as how to create and use a POSIX timezone).

@lurch
Copy link
Contributor

lurch commented Oct 27, 2025

Hmmm, if #716 and #714 got together and had a baby... 🤔 😂

@mjcross
Copy link
Contributor Author

mjcross commented Oct 27, 2025

Hmmm, if #716 and #714 got together and had a baby... 🤔 😂

https://digitalcollections.smu.edu/digital/collection/tir/id/205/

@lurch
Copy link
Contributor

lurch commented Oct 28, 2025

Thanks for the extra comments 👍
Not having done any time-based processing in C myself, I was misreading asctime() as ascii_time() whereas I guess it's actually meant to be read as as_ctime() 😂

@mjcross
Copy link
Contributor Author

mjcross commented Oct 28, 2025

I was misreading asctime() as ascii_time() whereas I guess it's actually meant to be read as as_ctime() 😂

Oooo never considered that... My "lengthy and extensive research" (ha ha) suggests it might be the former: https://retrocomputing.stackexchange.com/questions/25601/what-is-the-meaning-of-asctime
In fact for anything more complex than a timestamp it's probably better to use strftime() but that's a bit OTT for an embedded app :-)

@mjcross
Copy link
Contributor Author

mjcross commented Oct 28, 2025

Found a way to avoid hardcoding the timezone names in the printf() :-)

@mjcross
Copy link
Contributor Author

mjcross commented Oct 28, 2025

Many thanks for the excellent suggestions - should be all wrapped up in the latest commit (please let me know if I missed anything)

@mjcross
Copy link
Contributor Author

mjcross commented Oct 28, 2025

Looking really good now - many thanks again for your time to review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants