Cannot compile on Lolin S2 Mini with USBCDC

  • I am trying to build a button sensor on a Lolin S2 mini board. I am using the Binary Switch Sleep Sensor example code from the MySensors library.
    When I attempt to compile the code I get an error message:

    In file included from c:\Users\Rick\Documents\Arduino\libraries\MySensors/MySensors.h:61,
    from C:\Users\Rick\Documents\Arduino\S2 mini BinarySwitchSensor\S2 mini BinarySwitchSensor.ino:44:
    c:\Users\Rick\Documents\Arduino\libraries\MySensors/hal/architecture/ESP32/MyHwESP32.cpp: In function 'bool hwInit()':
    c:\Users\Rick\Documents\Arduino\libraries\MySensors/hal/architecture/ESP32/MyHwESP32.cpp:30:48: error: no matching function for call to 'USBCDC::begin(long unsigned int, int)'
    In file included from C:\Users\Rick\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32/USB.h:21,
    from C:\Users\Rick\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32/HardwareSerial.h:193,
    from C:\Users\Rick\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32/Arduino.h:174,
    from C:\Users\Rick\AppData\Local\Temp\arduino-sketch-A4C2CB8DD1162638CC7D73951F564058\sketch\S2 mini BinarySwitchSensor.ino.cpp:1:
    C:\Users\Rick\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32/USBCDC.h:70:10: note: candidate: 'void USBCDC::begin(long unsigned int)'
    void begin(unsigned long baud=0);
    C:\Users\Rick\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.5\cores\esp32/USBCDC.h:70:10: note: candidate expects 1 argument, 2 provided

    exit status 1

    Compilation error: exit status 1

    If I disable "USB CDC On Boot" under Tools, the code will compile and upload but then I am unable to use serial monitor to debug as there is no port to connect to.

    The exact same code compiles and runs just fine on a Lolin D32.

    I am using Arduino IDE 2.0.2 running on Windows 10. Board library is esp32 2.0.5. The radio is an RFM69CW.
    I found a reference that suggested adding a Serial.begin() statement to the setup to initiate a serial port after the restart but this did not work.
    I also found it odd that I could compile and run a simple program that reported the SPI pin assignments via serial monitor and it worked fine!
    Any suggestions appreciated.

  • Mod

    Welcome to the forum @Gibber

    Unfortunately, esp32 usage is not that common in MySensors so you might be the first person to try the S2 with this combination of version.

    One thing that could be worth trying is to downgrade thr esp32 library to 1.0.4 which was the active version when MySensors 2.3.2 was released. Similar downgrades have been necessary for esp8266 lately.

  • Hi, and thanks for the quick response.
    I tried the roll back but found that the Lolin S2 Mini was not an option in that version. I tried the Wemos D1 ESP32 and it would compile but the upload failed "Chip is unknown ESP32".
    I am going to try and use an external FTDI to avoid issues with USBCDC. If that does not work I will just use the D32 module.
    Thanks for the great body of work and support. I cannot even imagine how much work it must be to try and cover all the different chips and modules.
    The integration with Home Assistant makes this a breeze!

Log in to reply

Suggested Topics

  • 3
  • 2
  • 3
  • 2
  • 10
  • 2