I would like to send strings from USB (serial) to my esp32 microcontroller (Arduino) that are larger than the apparently default 64 bytes limit of the actual Arduino or the apparently 256 byte limit for the esp32 [1].
I found the command [2] recognized by PlatformIO:
Serial.setRxBufferSize(1024);
but as soon as I enter this line of code (with any number from 10 to 1000) the following code doesn't run anymore:
void serialEvent()
{
Serial.setRxBufferSize(64); // increasing buffer size ?
while (Serial.available())
{
char inChar = (char)Serial.read();
inputString += inChar;
if (inChar == '$') // end marker of the string
{
inputStringPC = inputString;
stringCompletePC = true;
Serial.print(inputStringPC);
inChar = '0';
inputString = '0';
}
}
}
Hope anyone knows whats wrong.
Thanks!
Obviously this function
void serialEvent()
{
Serial.setRxBufferSize(64); // increasing buffer size ?
....
is called in the loop - so basiclly you try to dynamicly change the buffer size of RX- So try
#define BAUD_RATE 115200
#define SERIAL_SIZE_RX 1024 // used in Serial.setRxBufferSize()
setup(){
Serial.begin(BAUD_RATE);
Serial.setRxBufferSize(SERIAL_SIZE_RX);
....
}
The above code works without any problems in ESP8266 /ESP32 and ArduinoIDE 1.8.12 and ESP32 core 1.04 / ESP8266 core 2.6.3