Electronics Microcontrollers Sensors "/>

Fix for ESP32 serial device not working when recompiling

14 September 2025 at 8:10 pm

Article image for Fix for ESP32 serial device not working when recompiling

I just published the first major firmware update for my radar sensor and while doing that, I stubled upon what seems like a significant change in the Arduino-esp32 integration. This took me some time to figure, so time to post it for others to find.

My sensor is based around the LD2410 millimeter radar sensor from Hi-link in China. I'm controlling it via an ESP32-C3 using the second builtin UART as Serial1. In general, I develop all my software using VSCode with PlatformIO, but I also maintain a repository for those using the Arduino IDE.

After spending the weekend updating, I had what I thought was a really solid release that worked perfectly in PlatformIO. Then I uploaded it using the Arduino IDE and now the ESP32-C3 was unable to connect to the radar via the serial port? Puzzled, I tried downgrading both the “Arduino-esp32” plugin in Arduino and using older versions of the IDE itself, but this all failed.

After some fiddling it struck me that maybe the RX and TX pins are not set by the Serial1.begin method? That was it… Digging further, it seems that when you're using HardwareSerial with the default pins, they're initialized as input/output. If you change the default pins (as I have), you have to explicitly set the pins to either INPUT or OUTPUT using pinMode. Might be good to know.