Problem with Serial Plotter, No Graph

Hi, I working with the EMG with muscle sensor. I just copy the code from Google and use it. In fach the data in Serial Monitor looks great without any problem, but there is no graph in serial Plotter. I'm really confuse that , people should use different code with different Sensor? Every code i can find online, looks same and simple, but none of them shows the Graph in Serial Plotter.
Could someone help please.

Tanks
VV

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorValue = analogRead(A1);
  float millivolt = (sensorValue/1023)*5;
  
  Serial.print("Sensor Value: ");
  Serial.println(sensorValue);
  
  Serial.print("Voltage: ");
  Serial.print(millivolt*1000);
  Serial.println(" mV");
  Serial.println("");
  delay(1);       
}

Welcome to the forum

Can we assume that the baud rate of the plotter matches that of the sketch ?

Hi @vv111. What you have here is fine for a human to read, but Serial Plotter requires that the data has a very specific format in order for it to be parsed completely.

This is an example of how correctly formatted data would look:

Sensor_Value:362.00,Voltage:1769.31
Sensor_Value:363.00,Voltage:1774.19

Your code has the following problems:

  • Spaces in label text are not supported (notice that I replaced it with _)
  • Spaces after label separator (:) are not supported (notice that I removed the space)
  • End of line must only be used as a record delimiter, not as a field delimiter (notice that I replaced it with ,)
  • Do not include any extra text (notice that I removed the mv)

So with all of those problems fixed, the code would look like this:

void setup() 
{
  Serial.begin(9600);
}
 
void loop() 
{
  float sensorValue = analogRead(A1);
  float millivolt = (sensorValue/1023)*5;
  
  Serial.print("Sensor_Value:");
  Serial.print(sensorValue);
  
  Serial.print(",Voltage:");
  Serial.println(millivolt*1000);
  delay(1);       
}

yep, i use both 9600 baud.

Thanks for your advice. I will try the new code.

It is really helpful, thankx a lot.

You are welcome. I'm glad if I was able to be of assistance.

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