Surprised by RTC value at ESP8266 boot/reset? #9163
Replies: 5 comments 9 replies
-
Are you using Thonny or rshell? |
Beta Was this translation helpful? Give feedback.
-
Thonny at the moment. |
Beta Was this translation helpful? Give feedback.
-
Ah... well... that is just annoying. LOL. |
Beta Was this translation helpful? Give feedback.
-
Yes, I am very familiar with how RTCs can be off the mark. Even on some high end servers across the various enterprise environments I have engineered and supported over the years, we had to do massive synchronization 'waves', it was not uncommon to have servers that had to be synchronized every 4 to 6 hours. Microsoft Active Directory domains and kerberos based environments have little tolerance for clock deltas. On ESP8266 my base scripting logic always synchronizes the RTC at boot/reset and then every 4 hours, typically. For when I do sensor data capture that needs time indexing, I capture the clock drift as well, easy to do, since I have the device report the time and I capture the time when the database record is created. This is not completely legit because it ignores the data transmission time cost, and other overhead time lag, but for my needs it will capture any gross delta. I also use a visual indicator, every 5 minutes I flash/blink a GPIO driven LED (not the on-board) 5 times, with a 1 second interval, this is aligned with 0 seconds for the given minute at execution. So when I walk pass a group of devices, installed or on a test bed, where I see the flashing poorly synchronized, I know the which devices likely have a higher drift issue. I developed this approach because even across Raspberry Pi devices I saw some odd RTC drifting at times. |
Beta Was this translation helpful? Give feedback.
-
One weird phenomenon explained, it bugged me as well. Another thing I have been wondering is that my ESP8266 seems to connect to Wi-Fi automatically and get a working IP from my DHCP service. Any idea why this happens?
I have yet found no way how to use this live connection in my application, though. I can see that Wi-Fi is on and get the values from ifconfig() but it is not usable and I cannot "reconnect" using the correct credentials. Using simple scripts works fine but inside a class init() function nothing works, for instance. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Since I almost always do a time sync (via ntptime or home rolled NTP query) right after WiFi connect, I was surprised that the RTC seems to magically have the correct time after a machine.reset and connect to WiFi when the script I am testing IS NOT setting the RTC. Ghost in the machine? I looked up the documentation on the machine.RTC and I did to any reference to the RTC getting set per se at boot. So is the network.WLAN doing a stealth time sync? Moreover I though machine.reset() clears RTC memory, no? I even pulled the power, and when I reconnected to WiFi, RTC spooky time set?
See in bold below...
Run! Alive
WiFi! Network
WiFi! Worstation
WiFi! Link True
WiFi! Connect? False
WiFi! Connect? False, Status 1, Time Out 30
WiFi! Connect True
WiFi! Alive
WiFi! Media
WiFi! Name 'esp8ff589'
MQTT! Connect
MQTT! Ping Alive
MQTT! Listen Active
MQTT! Publish 'status/esp8ff589/acknowledge', PayLoad '{"payload": true}'
Main! Alive
Schedule! Task 0x3fff0f30, Interval 5
Schedule! Task 0x3fff0b50, Interval 0.1
MQTT! Ping '715206401'
MQTT! Publish 'status/esp8ff589/ping', PayLoad '{"payload": 715206401}'
MQTT! Ping '715206406'
MQTT! Publish 'status/esp8ff589/ping', PayLoad '{"payload": 715206406}'
Run! Interrupt
Main! Not Alive
MQTT! Publish 'status/esp8ff589/acknowledge', PayLoad '{"payload": false}'
MQTT! Disconnect
Run! Not Alive
Beta Was this translation helpful? Give feedback.
All reactions