Hi Folks,
I’ve been playing around with the RD-03E radar sensor. I’m using a XIAO-ESP32C6 to connect to the radar module. The oddity I’m seeing with the USB serial port is as follows. I first connect my xiao to the radar module. Upon doing so I can compile and upload code to the module. From the debug info I can see that the xiao is sending the proper command string to the radar module but the radar module never responds. However, if I unplug the USB cable and plug it back in, I start to see responses from the radar module. This behavior is consistent across three separate programs that I’m using for testing (one reads the radar module firmware version, another sets the module up for distance calibration). Here is some output from the serial port monitor:
Setting Distance Calibration...
Enable Configuration ACK:
Enable Configuration ACK not received.
Setting Distance Calibration...
Enable Configuration ACK:
Enable Configuration ACK not received.
***HERE IS WHERE I DISCONNECT AND RECONNECT THE USB CABLE
Setting Distance Calibration...
Enable Configuration ACK: 0xFD 0xFB 0xFA 0x08 0x00 0xFF 0x01
Distance Calibration ACK: 0x00 0x00 0x01
Distance Calibration Command successful.
Configuration Ended.
Here is the associated code:
// RD-03E Radar Sensor Calibration code
// JCL, 10July2025
// https://www.electroniclinic.com/rd-03e-mmwave-human-detection-sensor-with-esp32-distance-measurement-hand-gesture/#Rd-03E_Arduino_Library
#define RX_PIN 17 // for ESP32C6
#define TX_PIN 16
//#define RX_PIN 44 // For ESP32S3
//#define TX_PIN 43
HardwareSerial radarSerial(1); // Use Serial1 for the RD-03E radar module
void sendCommand(uint8_t *command, size_t length) {
radarSerial.write(command, length);
}
void enableConfiguration() {
uint8_t enableCommand[] = {0xFD, 0xFC, 0xFB, 0xFA, 0x04, 0x00, 0xFF, 0x00, 0x01, 0x00, 0x04, 0x03, 0x02, 0x01};
sendCommand(enableCommand, sizeof(enableCommand));
delay(100);
}
void endConfiguration() {
uint8_t endCommand[] = {0xFD, 0xFC, 0xFB, 0xFA, 0x02, 0x00, 0xFE, 0x00, 0x04, 0x03, 0x02, 0x01};
sendCommand(endCommand, sizeof(endCommand));
delay(100);
}
void setDistanceCalibration(int32_t calibrationValue) {
// Step 1: Enable Configuration
enableConfiguration();
delay(100);
Serial.print("Enable Configuration ACK: ");
bool enableAckDetected = false;
// Check for Enable ACK (0xFF 0x01)
while (radarSerial.available()) {
uint8_t byte = radarSerial.read();
if (byte == 0xFD && radarSerial.read() == 0xFC) {
enableAckDetected = true;
Serial.printf("0x%02X ", byte);
} else if (enableAckDetected) {
Serial.printf("0x%02X ", byte);
if (byte == 0x01) break;
}
}
Serial.println();
if (!enableAckDetected) {
Serial.println("Enable Configuration ACK not received.");
return; // Exit if Enable ACK not received
}
// Step 2: Send Distance Calibration Command
uint8_t calibrationCommand[] = {
0xFD, 0xFC, 0xFB, 0xFA, // Frame Header
0x08, 0x00, // Intra-frame Data Length (8 bytes follow)
0x72, 0x00, // Command Word for Distance Calibration
0x00, 0x00, // Distance Calibration Parameter Number
(uint8_t)(calibrationValue & 0xFF), // Calibration Value byte 1
(uint8_t)((calibrationValue >> 8) & 0xFF), // Calibration Value byte 2
(uint8_t)((calibrationValue >> 16) & 0xFF), // Calibration Value byte 3
(uint8_t)((calibrationValue >> 24) & 0xFF), // Calibration Value byte 4
0x04, 0x03, 0x02, 0x01 // End of Frame
};
sendCommand(calibrationCommand, sizeof(calibrationCommand));
delay(200);
// Step 3: Read and confirm Distance Calibration Response
Serial.print("Distance Calibration ACK: ");
bool calibrationAckDetected = false;
while (radarSerial.available()) {
uint8_t byte = radarSerial.read();
Serial.printf("0x%02X ", byte);
if (byte == 0x01) { // Confirm ACK end
calibrationAckDetected = true;
break;
}
}
Serial.println();
if (calibrationAckDetected) {
Serial.println("Distance Calibration Command successful.");
} else {
Serial.println("Distance Calibration ACK not received.");
}
// Step 4: End Configuration
endConfiguration();
delay(500); // JCL: Changed from 100 to 500
Serial.println("Configuration Ended.");
}
void setup() {
Serial.begin(115200);
radarSerial.begin(256000, SERIAL_8N1, RX_PIN, TX_PIN);
delay(1000);
}
void loop() {
// Set distance calibration (example value of 100)
Serial.println("Setting Distance Calibration...");
setDistanceCalibration(100);
Serial.println("");
delay(4000);
}
Thank you!
Jim