telnetspy icon indicating copy to clipboard operation
telnetspy copied to clipboard

Error compiling on Arduino Nano ESP32 - cannot convert USBCDC* to HardwareSerial*

Open rogerw-gh opened this issue 5 months ago • 1 comments

Had this error building synman/BME280 for an Arduino Nano ESP32 on PlatformIO.

lib/TelnetSpy/TelnetSpy.cpp:43:13: error: cannot convert 'USBCDC*' to 'HardwareSerial*' in assignment Google suggested this compile flag: platformio_options: board_build.extra_flags: - "-DARDUINO_USB_CDC_ON_BOOT=0"

Which didn't solve the problem because I put the entire section in, when it should have looked like: build_flags = -D PROJECT_NAME='"BME280 Sensor Publisher"' -D HOSTNAME='"bme280-env-sensor"' -D ELEGANTOTA_USE_ASYNC_WEBSERVER=1 -D ARDUINO_USB_CDC_ON_BOOT=0 -D BS_USE_TELNETSPY -D BME280_LOG_LEVEL_BASIC

I kept searching and found an alternative fix...

https://www.esphome.io/api/uart__component__esp32__arduino_8cpp_source

There's this small section : #if ARDUINO_USB_CDC_ON_BOOT this->hw_serial_ = &Serial0; #else this->hw_serial_ = &Serial; #endif

The build has the flag set to 0, which forces the serial value to &Serial which fails on the ESP32S3. Changing the build flag to 1 has no effect.

So I tried changing the value of usedSer = &Serial to usedSer = &Serial0, that worked, but so did the compile flag when platformio.ini was configured properly, my bad.

The compile now runs to building a firmware image :-)

rogerw-gh avatar Feb 01 '24 10:02 rogerw-gh