Uno using timestamp

When I ask for a time stamp along with my sensor data, it appears nicely on the serial monitor screen just like the text supplied by my sensors.

BUT, when I read the data coming across the serial port (using python) the timestamp does not show.

I am assuming it is sent to the serial monitor via the serial port but apparently this is not true. How, then, does the time stamp arrive on the serial monitor if it is not coming from the serial port?

Or, more importantly, how can I capture the time stamp along with my data?

I realize there is such a thing as an RTC but I am trying to do this just in the software.

How does the timestamp arrive on the serial monitor without passing through the serial port?

Many thanks.

Please post the software using code tags.
All print outs sent to serial monitor is in ASCII. The value 1234 is sent as the ASCII characters for "1", "2", "3" and "4". It's not sent as the numerical value 1234 which is very different, likely a 2 byte integer.

Welcome to the forum

The timestamp is added to the Serial monitor by the IDE software running on the PC. It does not come from the Arduino Serial port

As you suggest, you could use an RTC to timestamp your data or if your Arduino board can establish an Internet connection then you could get the time from an NTP server.

My sensor data is being read perfectly so my code is correct.

I am asking why the time stamp, which is on the arduino serial monitor does not come across as the serial data does?

Thanks

Because it is added in the serial monitor, by the ide software, only if you tick the checkbox 'show timestamp', it was never sent along the serial line... unless you send it explicitely, in your code.

To print a "time stamp" from the Arduino, one approach is to print the current time since startup in milliseconds, then the data.

Serial.print(millis());
Serial.print(", ");
Serial.println(data);

You've got the explanation by now.
Posting the text had shown what You were telling. Words only are often unclear.
Personally I've never used/seen any timestamps.

So the serial monitor is not really a serial monitor as it is not just watching the serial port.

Thanks

It really is a Serial monitor as it enables you to see data coming from the Serial port. The fact that more information is added to it does not change that fact

Don't understand.
The serial monitor is a serial monitor with some useful options ( autoscroll and timestamp ).
The timestamp is very useful ( as it can timestamp in 'human readable format' even if your board has not an rtc )

Timestamps are added by the IDE, not native to the Serial Monitor.

As mentioned by @jremington, you can use millis() or micros() functions to keep track of time (which is not actual date and time).

Another way is adding the timestamps already on PC by your python program, like it done with Serial monitor.

BTW, you should note that since the timestamps are generated on the PC side, they have a "granularity" that is dependent on the PC's scheduler, which is ... relatively coarse.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.