Our TrinketPro is capturing data from our sensor every second, saving to SD card then sending the file every hour over bluetooth. For some reason the clock keeps speeding up.
After the first day it had sped up by 2 minutes so it was sending at 2 minutes before each hour. Now on the second day it has sped up by another 2 minutes so it is sending 4 minutes before each hour. I assume this trend will continue.
Anybody experience this? Have any ideas how to resolve?
Thanks
Trinket Pro clock speeding up???
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Trinket Pro clock speeding up???
This is typical for most computers - large and small. The processor clock is not optimized for long-term timekeeping. So the frequency is not super precise and most will exhibit some drift. For Arduinos and compatibles, several minutes per day is not unusual.
For accurate timing you can use a "Real Time Clock" module such as the DS3231: https://www.adafruit.com/product/3013
For accurate timing you can use a "Real Time Clock" module such as the DS3231: https://www.adafruit.com/product/3013
- jweekley
- Posts: 5
- Joined: Mon Nov 27, 2017 7:33 pm
Re: Trinket Pro clock speeding up???
Ok, well how can I reset the clock each hour? Since I am sending the sensor data over bluetooth from the Trinket, I can also get the latest time sent back to the Trinket via bluetooth. Any ideas from a code standpoint how I can auto update the time each hour with this new time and not cause other problems?
- adafruit_support_bill
- Posts: 88093
- Joined: Sat Feb 07, 2009 10:11 am
Re: Trinket Pro clock speeding up???
The process is similar to the way your computer clock gets periodically synchronized with network time. If your Bluetooth host has a reliable time base, you can have it send periodic sync messages to the Trinket. The exact implementation of the time sync will depend on what code you are running on each side The DateTime library has some example time sync code using Processing on the host side: https://playground.arduino.cc/Code/DateTime
Please be positive and constructive with your questions and comments.