Serial Plotter $ Serial monitor

When I input data (commands) using the Serial Monitor it is working ok. But when I switch to the Serial plotter the data is not arriving into the application and I can not find the issue. I dit put a long delay(10000) but that is not helping arduino version 1.8.13

Maybe the problem is with the code you didn't post

Maybe you can place the code and how can we try to replicate the issue!

Ok here is the code

I can input a value (command 1 letter and a number) "A1" into the input field of the monitor and this is reflected into the x and y. When I switch to the plotter it has no effect on the output

class CommandInput {
//Input signals from the USB keyboard and bluetooth connection and set the STATS accordingly
private :
int BUFFER_SIZE = 10;
public :
bool avail;
CommandInput( ) { }
void commandInput (char &c, int &arg, char buffer, long &deltaTime) {
long oldT = micros();
avail = false;
if (Serial1.available() > 0) {
avail = true;
c = Serial1.read();
int size = Serial1.readBytesUntil('\n', buffer, BUFFER_SIZE);
arg = 0;
//size is corrected becouse it include CR
for (int i = 0 ; i < (size - 1) ; i++) {
// Serial.print ("Power="); Serial.print (pow(10,((size - 2) - i)));
arg = arg + ( buffer[i] - '0' );
// Serial.print(" arg="); Serial.print(arg);
}
// Serial.print("class c="); Serial.print(c); Serial.print(" arg="); Serial.print(arg);Serial.print(" size="); Serial.print(size);Serial.print (" deltaTime="); Serial.println (deltaTime);
}
if (Serial.available()) {
avail = true;
c = Serial.read();
int size = Serial.readBytesUntil('\n', buffer, BUFFER_SIZE);
arg = 0;
for (int i = 0 ; i < size ; i++) {
// Serial.print ("Power="); Serial.print (pow(10,((size - 1) - i)));
arg = arg + ((buffer[i] - '0')
(pow(10,((size - 1) - i))));
}
// Serial.print("class c="); Serial.print(c); Serial.print(" arg="); Serial.print(arg);Serial.print(" size="); Serial.print(size);Serial.print (" deltaTime="); Serial.println (deltaTime);
}
deltaTime = micros() - oldT;
}
};

/*

*/

#define BUF_SIZE 5
char buf[BUF_SIZE];
char c;
int arg;
long delTime;
int x=100;
int y=200;
CommandInput CIn = CommandInput ();

void setup() {
// initialize both serial ports:
Serial.begin(9600);
Serial1.begin(9600);
}

void loop() {
CIn.commandInput ( c, arg, buf, delTime );
if (CIn.avail) {
Serial.print ("loop c="); Serial.print (c); Serial.print (" arg="); Serial.print (arg); Serial.print (" deltaTime="); Serial.println (delTime);
}
x=arg;
y=arg+10;
delay(100);
Serial.print(" x: "); Serial.print(x);
Serial.print(" y: "); Serial.println(y);
delay(10);
}

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