Closed cyberman54 closed 5 years ago
2b) done.
Concept for 1): implement it maybe hardware based with timers an pulse counter of esp32:
1b) done.
Seems to work, we see precisions in range ~40-200ms now.
Further improvement option: Use interrupt on LoRa pin DIO0 to capture TxDone timestamps. Thanks to @terrillmoore who came up with this idea.
v1.7.4 now reaches ~10ms accuracy. Since this is suitable for a wall clock i close this now.
For a LoRaWAN-only time synched wall clock we need a precise on board clock, which generates the pulses (DCF77 or IF482) for the external wall clock in realtime.
Systime
fromTime.h
is originally a fully software counter based clock, and has to much drift. We need a more precise solution, which is close to hardware.So, we want to improve accuracy of clock controller by two enhancements:
ad 1):
Times bases could be a) hardware generated PPS by GPS (-> perfect for tests to validate the solution) b) hardware generated PPS or SQW by RTC DS3231 (-> perhaps best solution for production) c) software generated PPS by a ULP routine in RTC of ESP32 (-> perhaps sufficient solution for production)
template for 1c): https://forum.arduino.cc/index.php?topic=121088.15
The PPS signal shall trigger an interrupt in timekeeper.cpp
ad 2):
a) either implement own time-of-day clock, with counter based on 1) b) or use some implementation for syncing systime of Time.h with 1)
templates for 2a): https://github.com/liebman/ESPNTPServer/blob/master/ESPNTPServer/GPS.cpp
templates for 2b): https://github.com/DennisSc/PPS-ntp-server https://hackaday.io/project/13386-arduino-precision-time https://stackoverflow.com/questions/10654258/get-millisecond-part-of-time
Further suggestion from esp32.net: