When I open my serial plotter to get the graph for my HC-SR04 sensor it doesn't show anything. My plotter looks different too. I have attached images below as well.

enter image description here

This is what it shows

Only those numbers on the top-most move with time.(100,200,300) Here's my code:

int trigPin = 12;
int echoPin = 11;

int pingTravelTime;
float pingTravelDistance;
float distToTarget;

int baudRate = 9600;

int dT = 10;
int dT2 = 500 ;

String msg1 = "The distance is equal to ";
String msg2 = "cm";

void setup() {
  // put your setup code here, to run once:
  pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(trigPin, LOW);
  digitalWrite(trigPin, HIGH);
  digitalWrite(trigPin, LOW);
  pingTravelTime = pulseIn(echoPin, HIGH);

  pingTravelDistance = pingTravelTime * ((765. * 5280. * 12.) / (3600. * 1000000));
  pingTravelDistance = 2.54 * pingTravelDistance;
  distToTarget = (pingTravelDistance / 2);

  Serial.println(msg1 + distToTarget + msg2);

What do I do??

  • Does the serial monitor connect without issue with this code? Commented Apr 13, 2021 at 8:12
  • Yes, the serial monitor behaves properly and poses no problem for me. It's just the serial plotter that seems to have a problem. Commented Apr 14, 2021 at 5:48

1 Answer 1


The serial plotter expects you to send numbers, and only numbers. If it reads any other text, like for example

“The distance is equal to 9.88cm”

It assumes these are the names of the columns of data that are to follow. So it chooses one color for each column and prints the color key on top of the graph.

What do I do??

Just remove the prose and print only the numbers. You may print something like “distance(cm)” in setup() if you want to have the key displayed, but that is not required.

  • Ok thanks a lot, I will try that. Commented Apr 14, 2021 at 3:06
  • Yes, it works now, thanks. Commented Apr 14, 2021 at 5:57
  • @unibeam Then mark this answer as correct. Commented Apr 14, 2021 at 10:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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