Hello, I'm trying to measure the time it takes for me to send some data to the serial monitor, but apparently this time doesn't change when I increase the baud rate at Serial.begin. Shouldn't it be faster when I increase baud rate?
Here is my test code: (I'm using arduino UNO)
// Variables for results storage
unsigned long tempo_inicio;
unsigned long tempo_fim2;
unsigned long valor = 1023;
void setup() {
Serial.begin(9600); //begins serial communication
}
void loop() {
// leitura
tempo_inicio = micros();
Serial.println(valor);
tempo_fim2 = micros();
Serial.print((tempo_fim2 - tempo_inicio));
Serial.println(" us");
delay(500);
}
I'm getting about 204 us and it doesn't change when I increase the baud rate. Can someone explain why this is happening and what can I do to make it faster?
If anyone wants detais, I'm doing this because I want to get data from the ADC and print it so I can copy and use it later, but the printing time will affect my sampling rate (it will be equal to the actual sampling time + printing time) and with 204 us to print the data my sampling rate will decrease a lot (about 3 times).
Regardless of the reason, just the fact that the Serial.println() time isn't changing with the baud rate is really weird to me.
Any help is welcomed. Thanks in advance.