![]() ![]() ![]() Reconfiguration of the microcontroller’s timers. Even signed long may encounter errors as its maximum value is half that of its unsigned counterpart. In that case I would not have to worry about correctly handling the roll-over since this would happen so long into the future (like 500 million years or so). Please note that the return value for millis () is of type unsigned long, logic errors may occur if a programmer tries to do arithmetic with smaller data types such as int. So is there a different function available (like millis64()) that returns a 64 bit millisecond value instead of 32 bit? Of course the problem might be unrelated to the way millis() operates, but still. I have a problem that my sketch resets at intervals approaching the 49 day limit (nut sure), so I figured I should find a different function for timing than millis(). it just means that after the 4,294,967,295 (232 - 1) milliseconds you go back to 0. If ((CurrentTime - LastMeasureTime) >= Interval) when millis () 'overflow' it does not mean you start writing somewhere else in memory. Something like this inside loop(): CurrentTime = millis() Since millis() is a 32 bit integer function it will roll over in about 50 days, so I have taken this into account by using subtraction to determine if the next read time has occurred. I have set it up to use millis() inside the loop() function to determine if it is time for the next measurement. Connects to my WiFi LAN to send measure results to my webserver at regular intervals (like 1 hour). It also only has a resolution of 4 microseconds on the Arduino Uno. ![]() It uses an ESP-07 controller and 4 AM2302 DHT sensors. Unlike millis(), micros() will overflow, or reset back to 0, every 70 minutes or so. I have this temp/humid logging sketch running in my attic since about a year. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |