Trouble in serial communication with Platform Espressif 32 3.1 or Higher


I have problem in communication between ESP32 and a Modem SIMCOM When i upgrade Platform Espressif 32. If i use the version 3.0, everythings is OK. If i Upgrade to a higher version, problem occur.

exemple from the serial :
with the platform 3.0. if i send this command “—> AT+CCLK?”
i receive the response : +CCLK: “21/12/06,21:06:20+04”
so everything is OK

But if i upgrade, i receive +CCLK: “” and the rest comes later.
every command is bad.

I Have defined serial with the le library #include <HardwareSerial.h>

thanks for support

Your code is likely dependent on the exact Arduino core implementation. Looking at Releases · platformio/platform-espressif32 · GitHub, Platform version 3.1 is the first one that uses Arduino core 1.0.5, with the latest PlatformIO-supported version being 1.0.6.

Can you show the code you’re using for reading out responses? Is there a little delay / timeout waiting for characters logic in the code? There’s no reason why it shouldn’t be generally possible to do serial communication with the latest espressif32 platform.

Thanks for your help.
I Use this code :

#include <Arduino.h>
#include <HardwareSerial.h>

#define SIMCOM_TX 27 
#define SIMCOM_RX 26 

HardwareSerial SIMCOM(1);



then i read the response from the modem with this function :slight_smile:

while (SIMCOM.available())
      char c =;
      if (c == '\r')
      if (c == 0xA)
        if (replyidx == 0) // the first 0x0A is ignored
        if (!multiline)
          timeout = 0; // the second 0x0A is the end of the line
      replybuffer[replyidx] = c;
      ATresponse = ATresponse + char(replybuffer[replyidx]);

But when you send the command with

and then directly after check if there are bytes available for reading with

The processor might be too fast and checking the serial at a time when there aren’t any bytes sent back yet. You should try and insert a piece of code there to wait for at least one character with a timeout, e.g.g

//wait for data with 5 tries and 50ms delay in between (=>250ms max)
int tries = 5;
while(!SIMCOM.available() && tries != 0) {

//original code
while(SIMCOM.available()) { /* ... */ }


Thanks for your help. I will try but i dont understand why everything works fine with version 3.0.0 and after upgrade problem occur ?

Internal optimizations of the Serial functions may have occurred making the execution of them faster and thus leading to this time-race to occurr.

OK thanks
I will try it tommorrow