2

Basically I want to be able to display the time the arduino collected the data with the data value, not the time the arduino printed off the data. Theres a timestamp feature on the console, however I want to find the time the data was collected.

I'm a bit new to this so any help is greatly appreciated!

  • 2
    did you record the time when the data was collected? – jsotola Oct 28 at 1:06
  • Which Arduino are you using (just in case you mis-tagged the question)? – ocrdu Oct 28 at 17:54
  • By itself, an arduino-uno's only timestamp is the number of milliseconds since reset. Serial.println(millis()); – DataFiddler Oct 28 at 22:32
1

Getting a "timestamp" of when data is collected is entirely down to you.

Most Arduinos don't have any concept of the current time, only the time since the program started running. To know what the time "now" is you have to have some mechanism to tell the Arduino what the time is, along with a method of keeping track of that time.

There are devices called Real-Time Clock (RTC) modules which keep track of the time for you. They don't magically know the time - you still have to tell them at least once.

You could tell it the time through the serial port to set the clock - from then on (assuming the RTC has power) the RTC will know what the time is.

Another option to get the time into the RTC is to use an internet connection (ESP8266, WiFi shield, Ethernet shield, etc) to perform a Network Time Protocol (NTP) query to a time server on the internet (such as pool.ntp.org) to get the current time and update the RTC. This should be done regularly to correct any drift in the RTC.

Once you have an RTC and a method of setting the time you can query the time whenever you sample some data and store that time along with the data in whatever way is most suitable for your situation.

| improve this answer | |
0

It depends on how you define the time stamp. A Unix timestamp is the number of seconds elapsed since Unix epoch time, i.e. January 1 1970 00:00 UTC, this is a very common time stamp. You can setup with NTP via the internet, or you can use a RTC on your board. How you do it depends on how accurate you want it and what you have available. Try this link it may help: https://currentmillis.com/

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.