Platformio Serial.available

Hello how can I send some data through the serial monitor on Platformio?
How can I input in the serial monitor data to read?
thanks

const int BUFFER_SIZE = 100;
char buf[BUFFER_SIZE];

void setup() {
  Serial.begin(115200); // opens serial port, sets data rate to 115200 bps
}

void loop() {
  // check if data is available
  if (Serial.available() > 0) {
    // read the incoming bytes:
    int rlen = Serial.readBytesUntil('\n', buf, BUFFER_SIZE);

    // prints the received data
    Serial.print("I received: ");
    for(int i = 0; i < rlen; i++)
      Serial.print(buf[i]);
  }
}

Did you click here after getting the program compiled and uploaded?
image

You may also need to add to platformio.ini file associated with your project:
monitor_speed = 115200

yes alreday done. but how can send in the buffer for example the data set 1 3 15 2?

Are you seeing any echo back of the characters you are typing?

platformIO serial monitor does not act the same way as Arduino, where you can select NewLine, CR or both NL and CR.

You could experiment with the following in the .ini file:

monitor_flags =
    --filter
    debug
    --filter
    send_on_enter
    --echo
    --eol
    LF

And please make sure to add the spaces/indents as listed above.
The send on enter filter should send the characters you type in after you hit enter

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