Compiler error rosserial on XIAO ESP32-S3

Hello everyone,

I have this compiling error on the XIAO ESP32-S3 (sense) board, and I can’t figure out how to solve it. This code worked fine with a generic ESP32 dev module as it did not use HWCDC.h.

In constructor 'ArduinoHardware::ArduinoHardware()':
       error: cannot convert 'HWCDC*' to 'HardwareSerial*' in assignment
              iostream = &Serial;
                          ^~~~~~

Those are the settings used:

I will appreciate any help, thank you!

Hi there,
The Esp32S3 has it Built in, maybe that’s why the error
On mi, I have this.


HTH
GL :slight_smile: PJ

Thanks PJ, but after compiling I have the same error with or without PSRAM.
Another thing, if I try to compile for a ESP32S3 Dev Module works without error (the compiling). Should be something related to the declaration of serial pins? If so, where I can find the file with all pin configuration for the XIAO ESP32S3?

Also, if someone wants to reproduce the error, in the ros.h should be commented as in the following code:

#ifndef _ROS_H_
#define _ROS_H_

#include "ros/node_handle.h"

//#if defined(ESP8266) or defined(ESP32) or defined(ROSSERIAL_ARDUINO_TCP)

#if defined(ROSSERIAL_ARDUINO_TCP)
  #include "ArduinoTcpHardware.h"
#else
  #include "ArduinoHardware.h"
#endif

Because by default, on esp32, it tries to run on internet not serial.

Hi there,
was worth a shot, Yes must Pins file in arduino BSP files, Which BSP are you using?
something like this: "C:\Users\xxxx\AppData\Local/Arduino15/packages/Seeeduino/hardware/mbed/2.9.0/cores/arduino/pinDefinitions.h "
locate you BSP and the MCU your using.
HTH
GL :slight_smile: PJ
you could just define the Pins you want in the code also. probably D6(rx) & D7(tx) on the Xiao that’s
off , Do you have the pinout or model # of the current board your using? (dev brd) I can look
a picture wouldn’t hurt either. :+1:

I have only esp32 in the packages folder, and in the cores/esp32 there is no Definitions.h or something pin related, but there is actually the HWCDC.h that throws the error.
In the “C:\Users\xxxx\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.14\variants\XIAO_ESP32S3” is pins_arduino.h where I have all the pins defined. Redefining the pins dosen t change the error … I’ll come back on this error in the weekend.

The dev board used, that run the code until now, is this one:


it s not an s3 board so dosen’t even enters the HWCDC.h file. And I as I said above, compiling for this one or for the s3 dev version works fine, only the s3 XIAO has problems.

Thank you for the support so far :slight_smile:

I think it’s the drivers , That’s a CH340C USB serial,
The Seeed Xiao is NOT. Have you used Zadig?
https://zadig.akeo.ie/#
HTH
GL :slight_smile: PJ

Also Have you tried o roll it back , Use BSP 2.0.8 and see what you get Error wise.

But it’s not about the driver as it is something about compiling. Like I don’t need to connect my esp32 to the pc in order to compile the code.
Also the XIAO board works, as I used with edge impulse for object detection … now I just need to send the object detected via rosserial.
Do you think that by using Zadig the rosserial library would start working on the XIAO esp? Because I don’t see how it can help but maybe I am wrong.


It must be something with the rosserial library as the other esp32 example codes compile and work, like this one in the screenshot with RX FIFO Full. I’m not that good of a programmer to understand how the library works but maybe that s the sign that I need to start learning :))

Hi there,
I see now, No the CH340 driver maybe would be needed for that dev board.
You do realize they are NOT the same ?
The code I don’t think will work on a Xiao, Serial1 is the Second Uart D6, D7
on an ESP32S3 Xiao and same on an ESP32C3
Softserial would need to be used for the Pin 4 & 5 to be used.
HTH
GL :slight_smile: PJ

I would recommend posting the ACTUAL code you are trying to run on a XIAO.

One question, this code works on a dev module s3 and also dev module c3 … Why would not work also on the XIAO esp32s3?
Here is the actual code that I try o run:

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

char hello[20]; 

void setup() {
  nh.initNode();
  nh.advertise(chatter);
  pinMode(LED_BUILTIN, OUTPUT); 
}

void loop() {
  
  digitalWrite(LED_BUILTIN, HIGH); 

  static int count = 0; 
  sprintf(hello, "hello world %d!", count); 
  str_msg.data = hello;
  chatter.publish(&str_msg);
  nh.spinOnce();
  delay(1000); 
  count++; 
  
  digitalWrite(LED_BUILTIN, LOW); 
  delay(1000);
}

Hi there,
What does the compiler output look like?
The first 3 lines & the last 20 line b4 upload?

Well, Not even Seeed Xiao ESP’s the S3 or the C3 are the same, S3 has additional pins (bottom)
USB bridge built in, Ram and Flash types and sizes differ also.
Considering that point and in Arduino you have to select the correct board to have a complete successful development session, including upload.
ONLY when you want to test a compile for basic compilation, You can you pick a generic DEV board and wouldn’t expect meaning ful results, just LIB hits to see what you need.
YMMV
What is the goal in this effort? Robot Operating System?
you want to make a server or create a topic ?
Did you follow the installation for Arduino.ide for ros?
HTH
GL :slight_smile: PJ

You have seen the note about the NODE_handles? have you made those changes?
https://wiki.ros.org/rosserial_arduino/Tutorials/Arduino%20IDE%20Setup

FYI, FWIW , I can compile and upload the code, But the end result is a BootLoop…

Hello,
So this one is the output from the compilation of the code I sent above (with XIAO_ESP32S3 chosen as board)
image

In file included from c:\Users\eugen\Documents\Arduino\libraries\Rosserial_Arduino_Library\src/ros.h:43,
                 from C:\Users\eugen\Documents\Arduino\esp32_ros_serial_test\esp32_ros_serial_test.ino:1:
c:\Users\eugen\Documents\Arduino\libraries\Rosserial_Arduino_Library\src/ArduinoHardware.h: In constructor 'ArduinoHardware::ArduinoHardware()':
c:\Users\eugen\Documents\Arduino\libraries\Rosserial_Arduino_Library\src/ArduinoHardware.h:84:19: error: cannot convert 'HWCDC*' to 'HardwareSerial*' in assignment
       iostream = &Serial;
                   ^~~~~~

exit status 1

Compilation error: exit status 1

I’m working on a project where I have the camera from xiao_esp32 recognising objects. And the information needs to be send to a raspberrypi running a ros master. Basically I just need to send the detected object to a topic.
As the installation, I just used the arduino IDE to download the library
image

I haven t seen something related to NODE_handles. You said you compiled the code and got a bootloop, but when you did that was the ros.h file modified like this?

#ifndef _ROS_H_
#define _ROS_H_
#include "ros/node_handle.h"
//#if defined(ESP8266) or defined(ESP32) or defined(ROSSERIAL_ARDUINO_TCP)
#if defined(ROSSERIAL_ARDUINO_TCP)
  #include "ArduinoTcpHardware.h"
#else
  #include "ArduinoHardware.h"
#endif

If you don t comment that line it s gonna run on wifi, instead of serial. And in my case it needs to be on serial.

Hi there, No.
Just the code you have with the LED,
I get it now, Rasp has the topic published and your sending a detected object to it.
What about running the Script to create the LIb , I read something to that effect.
It took a couple tries to get it to compile, Like it’s not appreciating the ROSserial…
Your close you’ll get it. (I would double check the LIB installation documentation.
HTH
GL :slight_smile: PJ

1 Like

Thank you, I will try to follow the installation documentation. I will come back with an update once I solve it.

Solved!

To be honest I’ve got lucky and just by using the HWCDC class instead of HardwareSerial, I managed to make it work. What I’ve observed is that ESP32S3 needs the option ARDUINO_USB_CDC_ON_BOOT in order to send data on the Serial but there is a conflict between the 2 classes so by just using the HWCDC the problem is solved. Might cause some problems with Serial0 Serial1 or Serial2 but I don’t even use them so I think it 's ok. :))
Those are the changes that I did in order to make it run:

#else 
  //#include <HardwareSerial.h>  // Arduino AVR
  //#define SERIAL_CLASS HardwareSerial
  #include "HWCDC.h"
  #define SERIAL_CLASS HWCDC
#endif

In ArduinoHardware.h, should be line 63 … all of this with “USB CDC On Boot Enabled” in Arduino>Tools

Thank you again PJ for the help

1 Like

Please note this is not a XIAO product it is VERY IMPORTANT you select the correct board when compiling, otherwise invisable configurations will/will not be set which are required

Please be advised the S3 chip is more advanced and not at all the same as other XIAO or ESP devices as they have different HW and SW pins

You have the ESP-32-WROOM i dont have that one loaded in my IDE

Hi there,
I always make sure to upload to the correct board. However, it seems I may not have explained myself clearly. I have a CH340C board and a recently purchased XIAO ESP32S3 Sense. And I mentioned the CH340C because I thought could be a lead information in solving the issue. Anyway, I can’t even upload the code from one board the the other as the Arduino IDE is smart and throws an error… even so, I double check when it comes to the xiao :))

Regarding the ESP-32-WROOM that I’ve used previously, it worked well with the “ESP32 Dev Module” selected as the board in the IDE. I remember reading somewhere online that this is how it’s typically done for ESP boards purchased from China/aliExpress.

Btw, the modification in ArduinoHardware.h that I made is now this one:

62.#elif ARDUINO_USB_CDC_ON_BOOT
63.  #include "HWCDC.h"
64.  #define SERIAL_CLASS HWCDC
65.#else
66.  #include <HardwareSerial.h>  // Arduino AVR
67.  #define SERIAL_CLASS HardwareSerial
68.#endif

Just added the elif with arduino usb cdc on boot so the library still works with non-s3 esp modules.

please be advised the modification to the hardware file is not necessary… that is what selecting the correct board does automaticly … by making these changes without fully understanding is probably your issue… i would say make a backup and go with the standard setup

You should understand the S3 is substantially more advanced than other ESP and each one has very different, so you are going to have to write code specific to each processor. post a picture of your setup using the XIAO

Hi there,
Outstanding, That CDC boot option is a squerly one, for sure.
Good troubleshooting. :grinning: :+1:
GL :slight_smile: PJ

1 Like

Wdym, if by standard setup means running the XIAO esp with the default settings that s already what I am doing. The only modified part is in the library from ros.h which without the modification the code dosen’t even compile. It’s not about the right board(initialy that s what I thought), it s only about CDC boot option which creates a conflict, that’s it.

This one is the setup, and as I said, it works. I had it ran for one hour and it went without problems. Maybe I’ll need a heatsink just to be extra sure.