1. Differences between Rd-03-V2 and Rd-03H
Rd-03-V2 and Rd-03H use the same chip, equipped with Silicon Micro's S1KM0000 chip, which can sense in real time whether there is a stationary, moving or slightly moving human body in the area.
The serial communication protocol used (click to view the serial communication protocol) is the same as that of the host computer (click to download the host computer), but the hardware package and size are different. The figure below shows the difference between the two packages and sizes.
Pinout of Rd-03-V2 / Rd-03H
Pin | Name | Description |
1 | 3.3 V | Power input |
2 | GND | Ground |
3 | OT1 | UART TX (from radar) |
4 | RX | UART RX (to radar) |
5 | IO | Detection output: HIGH = detected, LOW = none |
2. Use CubeMX with HAL library configuration for STM32F103C8T6
Open CubeMX, select STM32F103C8T6, check serial port 1 and serial port 2, select asynchronous communication, and check interrupt enable. Then serial port 1 is used to communicate with the radar, PA9 is TX, PA10 is RX, serial port 2 is used as the debug port, and PA12 is selected as the GPIO output to control the LED light.
3. STM32F103C8T6 CubeMX Setup
- Open STM32CubeMX → select STM32F103C8T6.
- Enable USART1 (async + interrupt) for radar communication.
- Enable USART2 (debug) and configure PA12 as GPIO to drive an LED.
STM32 Pin | Connects To |
3.3 V | Rd-03 3.3 V |
GND | Rd-03 GND |
PA9 (TX) | Rd-03 UART_RX |
PA10 (RX) | Rd-03 UART_TX |
PA12 | LED (with common ground) |
4. STM32 uses Rd-03V2/Rd-03H
Rd-03V2/Rd-03H has a built-in MCU to process data. It uses the serial port driver and will print "OFF" and "distance: distance" in the running mode.
Therefore, STM32 only needs to judge the ON and distance: characters in the serial port callback function.
// Check if it contains "distance" (someone -> turn on the light)
if (strstr(RX_BUF, "distance") != NULL) {
LED_ON;
}
// Check if it contains "OFF" (no one -> turn off the light)
if (strstr(RX_BUF, "OFF") != NULL) {
LED_OFF;
}
Of course, you can also write related functions according to the serial port protocol to configure the parameters of Rd-03-V2/Rd-03H, such as the maximum detection threshold distance and the detection delay time, etc. In this tutorial, for your convenience, a function is written according to the Rd-03-V2/Rd-03H protocol to initialize the driver of Rd-03 by inputting two parameters. The following is the function name. Call this function to configure the corresponding parameters before entering the whilie loop. The source code address is attached at the end of the textbook.
//parameter is the name of the debugging parameter
//roiMin, roiMax, delay can be filled in
//corresponds to the minimum detection distance gate, the maximum detection distance gate, and the target disappearance delay time
//distance is the input parameter, one distance gate represents 0.1m
RD_03_Write_cmd(roiMax,distance); //Radar data initialization write
5. Demo & Source Code
Repository (clone with Git):
https://e.coding.net/axk/stm32_rd-03/STM32-RD-03-V2.git
(Browser access unavailable; use Git to clone.)
Ai-Thinker