Serial2 Don't compile

  • I have recently changed to using in the boards manager now any application using serial2 wont comple. I get an error Error compiling for board M5Stack-Core-ESP32.


    David Ardis

  • @ardisd Can you post a screenshot of the error ouput from arduino?

  • Enclosed screen shot as requested

    I get the same error when compiling Serial2.ino and my own code


  • Are you running arduino 1.8.7?
    Thats not all the error.

  • Upgraded to 1.8.7 was on 1.8.5

    This is the error now


  • I first thought is to tell you to Backup and delete the SD folders in dropbox and
    and then try again.

    Can I see your source code?

  • Just the standard serial2 sketch

    #include <M5Stack.h>

    HardwareSerial Serial2(2);

    void setup() {



    // Serial2.begin(unsigned long baud, uint32_t config, int8_t rxPin, int8_t txPin, bool invert)
    Serial2.begin(115200, SERIAL_8N1, 16, 17);

    void loop() {

    if(Serial.available()) {
    int ch =;

    if(Serial2.available()) {
    int ch =;

  • I got the same problem.
    I changed the rename of Serial2 and fixed it.

    HardwareSerial Serial2(2);
    →HardwareSerial Serial2_(2);

  • @nnnSerial2 Don't compile 中说:

    HardwareSerial Serial2_(2)


    That worked for me

    David Ardis

Log in to reply

Looks like your connection to M5Stack Community was lost, please wait while we try to reconnect.