Serial Plotter not showing Values

Good Evening,

I am hoping that you can help. As part of my degree in Instrumentation, Measurement and Control, I have been asked to design a simple system using the Arduino Sensor Kit and a breadboard with an additional LED.

I am using the Potentiometer to mimic a hydraulic test pump. The green LED comes on when the test is good, the red LED comes on when test fails. The temperature is also to be monitored and recorded.

The pressure and temperature are showing fine on the serial monitor, but I cannot get them to show on the serial plotter.

Apologies if this is considered a basic concept, but I am a complete novice with this. Any help or advice would be very much appreciated.

Here is a copy of my sketch thus far......

#include "Arduino_SensorKit.h"
#define Environment Environment_I2C

const int potPin = A0;
const int redLEDPin = 6;
const int greenLEDPin = 9;
const int buzzerPin = 5;
const int pressureMin = 0;
const int pressureMax = 250;
const int pressureThreshold1 = 200;
const int pressureThreshold2 = 220;
const int DHTPIN = 3;  // Define the pin to which the DHT20 sensor is connected

DHT20 dht20(DHTPIN);  // Initialize DHT20

void setup() {
  Wire.begin();
  Serial.begin(9600);
  Oled.begin();
  Oled.setFlipMode(true); // Sets the rotation of the screen
  pinMode(redLEDPin, OUTPUT);
  pinMode(greenLEDPin, OUTPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  // Read the analog value from the potentiometer
  int potValue = analogRead(potPin);

  // Map the analog value to the pressure range
  int pressure = map(potValue, 0, 1023, pressureMin, pressureMax);

  // Display pressure and temperature on the OLED screen
  Oled.setFont(u8x8_font_chroma48medium8_r);
  Oled.setCursor(0, 0);
  Oled.print("Press: ");
  Oled.print(pressure);
  Oled.println(" Bar");

  Oled.setCursor(0, 30);
  Oled.print("Temp: ");
  Oled.print(Environment.readTemperature());
  Oled.println(" C");

  Oled.display();

// Print pressure and temperature on the same line in the Serial Monitor
  Serial.print("Pressure: ");
  Serial.print(pressure);
  Serial.print(" Bar, Temperature: ");
  Serial.print(Environment.readTemperature()); 
  Serial.println(" C");


  // Control the LEDs and buzzer based on pressure
  if (pressure < pressureThreshold1) {
    digitalWrite(redLEDPin, HIGH);
    digitalWrite(greenLEDPin, LOW);
    noTone(buzzerPin);
  } else if (pressure >= pressureThreshold1 && pressure < pressureThreshold2) {
    digitalWrite(redLEDPin, LOW);
    digitalWrite(greenLEDPin, HIGH);
    noTone(buzzerPin);
  } else if (pressure >= pressureThreshold2 && pressure <= pressureMax) {
    digitalWrite(redLEDPin, HIGH);
    digitalWrite(greenLEDPin, LOW);
    tone(buzzerPin, 1000);
  }

  // You can perform additional actions or send the pressure and temperature values to other devices here

  delay(3000);
}

Regards
Daryl

It needs to be in a certain format. In the past only numbers and commas were allowed. Multiple channels are separated by commas.

For example three channels:

x = 123;
y = 457;
z = 789;
Serial.print(x);
Serial.print(",");
Serial.print(y);
Serial.print(",");
Serial.print(z);
Serial.println();

Or use sprintf to create the format, or the numbers as text: Serial.println("123,456,789");

It is possible to give a name to the channels: https://docs.arduino.cc/software/ide-v2/tutorials/ide-v2-serial-plotter

If it does not work, try a single channel without name first.
Do you use the newest Arduino IDE ?

I didn't test it. Is a space allowed here: Serial.print("Pressure: ");, try without a space after the ':'.
Your " Bar" breaks the format.

1 Like

AFAIK if you need to show multiple values over serial plotter you must use the syntax:
name: value, name: value, ...
Your output includes measure units like "Bar" and "C" after the value and that isn't allowed (and unnecessary for a basic plotter output) so you need to change the serial print.
Get rid of the units, something like this could work:

  Serial.print("Pressure: ");
  Serial.print(pressure);
  Serial.print(", Temperature: ");
  Serial.print(Environment.readTemperature()); 
  Serial.println();

or if you still need units:

  Serial.print("Pressure_Bar: ");
  Serial.print(pressure);
  Serial.print(", Temperature_C: ");
  Serial.print(Environment.readTemperature()); 
  Serial.println();

But if your final goal is to send such data to another program (to be acquired somewhere else) you could avoid also the names, and use a "CSV-like" format with fixed fields:

  Serial.print(pressure);
  Serial.print(",");
  Serial.print(Environment.readTemperature()); 
  Serial.println();

HTH

There must not be a space after the label-value separator:

<label>:<value>

You're absolutely right, it's because of my typing habit of separating operators and values with a space in programs... :wink:
The correct code is:

Serial.print("Pressure:");
  Serial.print(pressure);
  Serial.print(",Temperature:");
  Serial.print(Environment.readTemperature()); 
  Serial.println();
1 Like

Afternoon All,

Just quick message to say thank you very much for the prompt feedback and help with this......I tried it a few minutes ago and it worked!!!! :grinning:

Thanks again, this will make my project so much better!!

Regards
Daryl

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