Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rogerw-gh opened this issue Feb 1, 2024 · 2 comments

Comments

@rogerw-gh
Copy link

rogerw-gh commented Feb 1, 2024

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
Copy link
Author

So I've closed the issue, hoping that Google etc. will pick up the necessary change to platformio.ini as a fix when building this code for an Arduino Nano ESP32.

@pro-bowl
Copy link

Hi, I'm using a ESP32-S3. Could you please explain in detail what and where to add or change in the platformio.ini and the TelnetSpy.cpp to make the lib compile?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants