May 24, 2021, 11:49am
When you switch-on the time stamping in the Serial monitor, you get printouts like this:
13:45:23.848 -> getData:
13:45:24.553 -> getData:
This looks like the 2nd getData command came ~700ms after the first, while in reality it came several minutes later!
The problem is that the time stamp seems to get printed out with a \n character. This thus becomes a meaningless value when the next print comes much later.
Instead, the timestamp should only be printed at the time-point a new print has begun!
How do you define " the time-point a new print has begun!"? On my system it prints when a new line starts to print, it could simply be a space which you did not see. Look at your print statement and see if you have a loose space at the end of the string.
May 25, 2021, 7:19am
I interact with the code via a web page, and trigger a printout. You see that the line is printed, PLUS the time stamp on the next line.
The next print is not using a new line, but follows directly the outdated time stamp. Thus the timestamp for this line is wrong.
But it is easy to test: make a loop to print out every minute, and compare with your computer time.
Like this you mean ?
static byte x = 0;
Which gives this output
08:22:16.184 -> 0
08:23:16.098 -> 1
08:24:16.064 -> 2
08:25:15.978 -> 3
which in turn matches the time display on my PC
May 25, 2021, 8:31am
Exactly. I took your code and got this:
10:0:32.336 -> 0
10:0:32.440 -> 1 # computer time: 10:01:32
10:1:32.440 -> 2 # computer time: 10:02:32
The '1' is printed at computer time: 10:01:32, the time stamp on the
3rd line, not the '10:0:32.440' on the 2nd line! And you see that the last line in the monitor already has a time stamp, although nothing was printed!
The above was obtained with the Arduino IDE 2.0 Beta7. After starting Arduino IDE 1.8.13, and looking at the running dvice, I get this:
10:23:39.489 -> 13
10:24:39.464 -> 14
10:25:39.474 -> 15
This is how it should be; and no extra line!
Obviously a regression in Beta7!
I have repeated my test with IDE 2.0.0-beta.7 and can confirm your observations
Thanks for the report, I tested it and have the same issue.
I created an issue on Github to keep track of it.
03:34PM - 26 May 21 UTC
04:40PM - 05 Oct 21 UTC
topic: serial monitor
**Describe the bug**
The Serial Monitor doesn't print the value just received
… with the correct timestamp but with the one of the previous received value.
If the board sends `A` at time `1` and `B` at time `2` this would be the output, first:
1 -> A
1 -> A
1 -> B
Changing the baud rate to a lower or higher one doesn't change a thing.
Steps to reproduce the behavior:
1. Create a Sketch with the following code:
static byte x = 0;
2. Upload it to your board
3. Open the Serial Monitor
4. Set the baud rate to 2400
5. Click Toggle Timestamp if not already on
Notice how the timestamp for the value printed now is not correct but reference to the previous one.
Also the first value is printed two times.
I expect the values to be printed on the correct timestamp when it's received by the PC.
**Desktop (please complete the following information):**
- OS: Linux
- Version: 2.0.0-beta.7
This issue has been original reported on the Arduino Forum: https://forum.arduino.cc/t/serial-monitor-gives-wrong-time-stamp
September 23, 2021, 3:36pm
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.