Serial Monitor and plotter not working

I am using the simple code below to collect data from a mic. The serial monitor seems to be working but the plotter is not giving me any results, any advice on what I should change?

const int microphonePin = A0;

void setup() {
Serial.begin(9600);
}

void loop() {
int mn = 1024;
int mx = 0;

for (int i = 0; i < 10000; ++i) {

int val = analogRead(microphonePin);

mn = min(mn, val);

mx = max(mx, val);
}

int delta = mx - mn;

Serial.print("Min=");
Serial.print(mn);
Serial.print(' ');
Serial.print(" Max=");
Serial.print(mx);
Serial.print(' ');
Serial.print(" Delta=");
Serial.println(delta);
}

Hi @wesly9915. The problem is that your output is not formatted correctly for the Serial Plotter to be able to read it.

Replace the = with : and I think it will work correctly.

You can learn about the supported data format here:

https://github.com/arduino/Arduino/blob/master/build/shared/ArduinoSerialPlotterProtocol.md#serialplotter-protocol

Hello ptillisch,
Thank you for the quick response. I don't see which line you are referring to.

The serial data you are printing has this format:

Min=42  Max=1234  Delta=11
Min=42  Max=1234  Delta=11

This is not supported.

The Serial Plotter is not a human. It has a very specific data format it understands and you must follow that format. You made up your own random format for the data, which is why it didn't work.

The equivalent supported format looks like this:

Min:42 Max:1234 Delta:11
Min:42 Max:1234 Delta:11

So to generalize

<label>:<value><part separator><label>:<value><part separator><label>:<value><end of message>

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