Calculation of time interval
-
I am trying to calculate time interval by calling millis() function in loop().
Looks like returned values are affected by smartSleep(). I mean time doesn't grow much during sleep.
Is there a more reliable way to detect timeout?
-
@benya the 'sleep' function causes the millis() timer to stop. Using an external clock (rtc) would be the best solution for low power operation. If you know how long you sleep you can do some calculations in the loop. Smartsleep() is not very predictable in this case
-
@AWI If there is no RTC, should I opt to use requestTime() and receiveTime()?
-
@benya That would be a solution just be aware that you need to wail for reception of the time information.
-
@AWI If node requests time and values before going to sleep, it will receive them upon return from smartSleep?
void loop() { requestTime(); request(1, V_STATUS); request(2, V_STATUS); smartSleep(200); } void receive(const MyMessage &message) { ... } void receiveTime(unsigned long ts) { ... }
Suggested Topics
-
Day 1 - Status report
Announcements ā¢ 23 Mar 2014, 22:45 ā¢ hek 24 Mar 2014, 20:12 -
Can not compile MySensors on esp8266
Troubleshooting ā¢ 24 Aug 2024, 15:35 ā¢ TheoL 29 Aug 2024, 20:47 -
Compiling Sensor code using BME280 and ESP8266
Troubleshooting ā¢ 26 Feb 2025, 00:32 ā¢ dpcons 26 Feb 2025, 06:22 -
Echo request is not set
Troubleshooting ā¢ 12 Aug 2024, 15:36 ā¢ kamilb85 3 Sept 2024, 08:58 -
Ghost Child
Troubleshooting ā¢ 27 days ago ā¢ FcNanoLed 23 days ago -
DHT22 wrong sensor type in Home Assistant
Troubleshooting ā¢ about 16 hours ago ā¢ Commodoreuno about 16 hours ago