ESP32

Rd-03D mmWave Radar: Multi-Human Tracking with Distance, Speed & Positioning

Rd-03D mmWave Radar with ESP32:

Rd-03D mmWave Radar With ESP32: Multi-Human Tracking with Distance, Speed & Positioning- The RD-03D mmWave Human Detection Sensor by Ai-Thinker is truly amazing. This small and affordable millimeter-wave radar sensor can do things that even expensive high-end human detection sensors cannot.

Personally, I believe this mmWave sensor will soon replace most human detection sensors. That’s because, with this sensor, you can not only detect humans but also measure their distance accurately. And it’s not just about one target; this mmWave Radar can detect up to 3 targets at the same time and measure their distances with great accuracy.

Rd-03D mmWave Radar

allpcb circuit

And the best part is, you have full control over to choose whether you want to use this sensor for detecting a single target or multiple targets. If you want to detect just one target, you can use the single-target detection command. And if you want to detect up to 3 targets, you can use the multi-target detection command.

Rd-03D mmWave Radar




This sensor doesn’t just stop there! It can also measure the angle of moving targets in addition to detecting them and calculating their distances.

Rd-03D mmWave Radar human distance with position tracking

This capability opens up a whole new world of possibilities for advanced tracking systems.

For example,

  • It can be used to intelligently recognize and track how a person moves within an area.
  • It can follow the path of their movement,
  • Understand where they are heading, and
  • Keep track of their position over time.

This makes it highly useful for monitoring human activity, and identifying motion patterns.

Rd-03D mmWave Radar human distance speed and angle tracking

Another impressive feature is;

  • Its ability to calculate the speed of a moving human by analyzing motion data.

This is incredibly useful for projects like automatic door systems, where you might want the door to respond faster if a person is running versus walking.

Additionally, with its ability to track the movement path and positions using X and Y coordinates, this sensor can play a critical role in home automation and load-controlling projects.

Rd-03D mmWave Radar human tracking fan

For instance, you could program it to turn on lights or appliances only when a person is detected in a specific area, saving energy and improving convenience.



In security projects, this mmWave radar sensor is a game-changer. It can not only detect intruders but also track their movements within the protected area in real time.

Rd-03D mmWave Radar security system intruder detection

You can set it up to trigger alarms, activate cameras, or even send notifications when unauthorized movement is detected. Its ability to monitor multiple targets simultaneously ensures no movement goes unnoticed, making it perfect for advanced surveillance systems.

Overall, this millimeter-wave radar sensor is packed with features that make it ideal for various applications, from

  • Smart homes and automation to
  • Security and
  • Tracking projects.

It’s small, affordable, and incredibly powerful; everything you would want in a modern detection system.

Rd-03D mmWave Radar vs pir sensor

Compared to a traditional PIR (Passive Infrared) sensor, the RD-03D mmWave Human Detection Sensor is in a completely different league.

While a PIR sensor can only detect motion and struggles with accuracy in distance or direction, the mmWave sensor goes far beyond. It can measure the precise distance, angle, and even speed of moving targets, something a PIR sensor simply cannot do.

Plus, it can track multiple targets at the same time, while a PIR sensor is limited to detecting general motion in its field of view and can only be used indoors.

This makes the mmWave sensor a far more versatile and reliable choice for advanced automation and security systems. Because the mmWave sensor is not affected by light, you can use it both outdoors and indoors.



Now, my question is:

Will you still use a PIR sensor?

Let me know in the comments.

Today, we are going to use this powerful mmWave radar sensor with the ESP32 and let me tell you; the information and data I am going to share with you; you cannot find it anywhere else. Because, until today, no one has used this sensor with Arduino, ESP32, or ESP8266. So, do not waste your time looking for its Arduino library; just sit back, relax, and read this article.

We will practically detect single and multiple targets, and based on the measured distance and direction of movement, we will control a specific load.

So, without any further delay, let’s get started!

Amazon Links:

ESP32 WiFi + Bluetooth Module (Recommended)

Rd-03D mmWave Radar

*Please Note: These are affiliate links. I may make a commission if you buy the components through these links. I would appreciate your support in this way!



Rd-03D Radar Overview:

The Rd-03D is a radar module made by Shenzhen Ai-Thinker Technology Co., Ltd., using the “Artificial Internet of things” AIoT S5KM312CL chip from Iclegend.

Rd-03D mmWave Radar

It is a millimeter wave sensor SoC “System on a chip” based on Frequency Modulated Continuous Wave “FMCW” radar transceiver technology. It works in the 24GHz K-band with a maximum sweep bandwidth of 0.25GHz.

This module uses FMCW waveform and advanced signal processing technology combined with built-in intelligent positioning and tracking algorithm to detect multiple targets in a specific area. The Rd-03D can accurately sense human motion and other activity in the area, track movement paths, and measure the speed and distance of targets.

It can intelligently distinguish the human body in the form of movement, micro-movement, and rest. The module has good resistance to external interference and is not affected by wireless signals such as WIFI.

Rd-03D Characteristics:

Rd-03D mmWave Radar

Some of its key characteristics are

  • It supports 24 GHz ISM frequency band.
  • Features a high-performance microstrip antenna with one transmitter and two receiver “1T2R”.
  • Offers accurate target tracking and positioning.
  • Maximum sensing distance is 8 meters.
  • The range resolution is 0.75m and the ranging accuracy is 0.15m.
  • Detection range covers ±60° horizontally and ±30° vertically.
  • Supports UART communication, enabling easy adjustment of radar settings via the serial port.
  • Operates on a single 5V power supply.
  • Suitable for wall mounting.
  • Includes a tool to adjust detection range, data reporting time, and target retention.
  • Compact size: 15 x 44 mm.
  • Plug-and-play with default settings.
  • Adopts standard 1*4P-1.25mm socket connector

Typical application scenarios are

  • Smart home appliances
  • Intelligent business
  • Smart Security and
  • Smart lighting




Rd-03D Main Parameters:

Rd-03D mmWave Radar

The Rd-03D model comes with a standard socket connector and features an onboard PCB antenna. It operates in the frequency range of 24G to 24.25GHz. The module is designed to work in temperatures ranging from -40°C to 85°C and can be stored at temperatures between -40°C and 125°C with less than 90% relative humidity. It requires a 5V power supply with a current of at least 200mA. The module uses a UART interface with a default data rate of 256,000 bps.

Rd-03D mmWave Radar

Model: Rd-03D

Package: Standard 1*4P-1.25mm socket connector

Size: 15.0*44.0(±0.2)mm

Antenna: on-board PCB antenna

Frequency: Frequency 24G-24.25GHz

Working Temperature: -40℃~85℃

Storage Temperature: -40°C~125°C, <90%RH

Power Supply: Support voltage 5V, supply current ≥200mA

Interface: UART

UART Rate: Default 256000 bps



Rd-03E Installation and Orientation:

Rd-03D mmWave Radar

For the precise human detection, distance measurement, direction of movement, and speed measurement. It should be installed 1.5 to 2 meters above the floor.

Rd-03D mmWave Radar

The radar installation azimuth is shown in Figures (a) or (b),  positive and negative directions are azimuth angles, up and down directions are pitch angles, and the radar antenna plane normal direction is 0°.

Rd-03D mmWave Radar

The range for detecting moving humans covers ±60° horizontally and ±30° vertically, the maximum detection distance in the normal direction is 8m



Rd-03D Pin Definition:

Rd-03D mmWave Radar

On the backside, you can see that it has a standard socket connector, which allows us to easily connect it to any controller board without soldering any wires. Unfortunately, they forgot to send the connector, so now I will have to solder the wires to the RX, TX, GND, and 5V contacts. We are going to use only four wires to connect this sensor to the ESP32. And let me tell you:

The Operating range of TX and RX pins is 0 to 3.3 Volts; so you can safely use this Radar module with 3.3V compatible controller boards.

Rd-03D mmWave Radar interfacing with esp32

All the 4 wires have been soldered and now I can use these 4 wires to connect it to the ESP32.

Rd-03D Interfacing with ESP32:

Connect the 5V and GND pins of the ESP32 to the VCC and GND pins on the millimeter-wave Radar module.

Connect the TX and RX to the ESP32 GPIOs 16 and 17 respectively; I am using Serial Port 1 on the ESP32. For the connections, you can follow this circuit diagram.

Rd-03D mmWave Radar with esp32 circuit

About the ESP32 Development boards:

Rd-03D mmWave Radar
ESP32 Development Board

I performed my initial experiments on a breadboard. But since I also need to control a load automatically, I realized I would need a relay for that. So, I decided to create my own ESP32-based development board using Altium Designer. On this board, I added a 5V 3A power supply and a 5V SPDT relay. After designing the PCB and Generating Gerber files. I opened the ALLPCB official website and ordered 5 PCBs. For the order placement watch the video tutorial given at the end of this article. 

Rd-03D mmWave Radar
Special Offers

Allpcb is not just one of the fastest PCB manufacturing companies in the world, but it also has high quality and amazing prices. For only 5 dollars, you can get single or double-sided PCBs up to 150 x 100mm in size. This is great because most companies only offer sizes up to 100x100mm. With Allpcb’s 150x100mm size, you can make multiple PCBs on one board, saving money by paying just 5 dollars!

ESP32 Development Board

Rd-03D mmWave Radar
PCB manufactured by ALLPCB

After a few days, I got 5 high-quality PCBs and I am really thankful to ALLPCB for sponsoring such high-quality PCBs. The traces are clean and precise, and the silkscreen is clear and easy to read. It’s impressive how well they have managed to capture the detailed design.



Rd-03D Arduino Library:

When I reached this point, I got stuck for a while. That’s because no one had used the RD-03D mmWave Radar Module with Arduino, ESP32, ESP8266, or Raspberry Pi Pico before. I could not find any Arduino library for this sensor, not on the product’s official page and not by searching in the Arduino IDE library manager.

Then I tried searching on Google, but I still couldn’t find a library for it. So, as always, I decided to write my own code.

What I am about to explain is something you need to read and understand because it’s not guaranteed that you will always find a ready-made library for every sensor you work with. Sometimes you will come across sensors that don’t have a library available anywhere. That’s when this knowledge will really help you. So, let me explain how I tackled this.

I started off by downloading all the PDF files from the Ai-thinker product’s official page. In the datasheet I went to the communication protocol section where I confirmed the default baud rate of the Radar Serial port which is 256000 bps. I also carefully studied the Data Frame Format including information about the Frame Header, Intra-frame data, and Frame Tail.

Rd-03D mmWave Radar

And closely observed how the Radar outputs the detected target information, including X and Y coordinates, Target Speed, and Distance Value.

Rd-03D mmWave Radar frame data

Data example: AA FF 03 00 OE 03 B1 86 10 00 68 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 55 CC

Target 1x coordinate: OxOE+Ox03*256= 782

0-782=-782 mm;

Target 1y coordinate: OxB1+Ox86*256 = 34481

34481-2^15= 1713 mm;

Target 1 speed: 0x10 + OxO0 * 256= 16

0-16=-16cm/s;

Target 1 Distance Resolution: Ox68+Ox01*256= 360 mm

This is an example of the data that the RD-03D radar sends when it detects a target. Now, this data might look complicated, but it’s just a set of numbers that tell us what the radar is seeing.

Here’s what the radar is saying:

It found one target, which we are calling Target 1 (that’s the blue part in the example).

For Target 2 and Target 3 (red and black), the radar didn’t detect anything, so their data is all zeros.

Now, let’s see what information we can get about Target 1:

Target 1 X Coordinate:

The X coordinate tells us how far left or right the target is.

The radar gives the value as 0x0E + 0x03 * 256.

We multiply by 256 because the data is stored in two bytes (or two numbers) for each value.

Lower byte is 0x0E (14 in decimal).

Higher byte is 0x03 (3 in decimal).

To get the full X coordinate:

Value = (3 × 256) + 14 = 782

Since it’s 0-782, the result is -782 mm, which means it’s 782 mm to the left.

Target 1 Y Coordinate:

The Y coordinate tells us how far forward or backward the target is.

The radar gives 0xB1 + 0x86 * 256, which equals 34481.

But because the radar uses a specific format, we subtract 2^15 (or 32768), and we get 1713 mm. So, the target is 1713 mm forward.

Target 1 Speed:

This is how fast the target is moving.

The radar gives 0x10 + 0x00 * 256, which equals 16.

Since it’s 0-16, the speed is -16 cm/s. A negative value just means the target is moving backward.

Target 1 Distance Resolution:

This tells us how precisely the radar measured the distance.

The radar gives 0x68 + 0x01 * 256, which equals 360 mm.

Next, using the X and Y coordinate values, we can find the target distance, and angle. I will explain this in the programming. So, this is how we take the raw data and turn it into useful information!

Before, you start the programming, make sure you have installed the ESP32 board in the Arduino IDE. You can read my getting started article on the ESP32 WiFi + Bluetooth Module.




Reading the Rd-03D data frame:

I wrote a simple program to check the data coming from the radar. As I already explained, the Rd-03D Radar module can detect either one target or multiple targets.

If you want to activate single target detection, you just need to send the Single_Target_Detection_CMD to the radar. And if you want to switch to detecting multiple targets, you send the Multi_Target_Detection_CMD instead.

Right now, as you can see, I have implemented the Single_Target_Detection_CMD to test how it works.

Rd-03D Data Frame Code:

This code listens for data coming from the radar sensor through Serial1 and stores it in a buffer called RX_BUF. It checks each piece of data and adds it to the buffer, keeping track of how much data has been collected using RX_count. To prevent the buffer from overflowing, it stops adding data if it reaches the buffer’s maximum size.

The code also looks for a specific pattern (0x55 followed by 0xCC) at the end of the buffer to confirm that a full message has been received. Once a complete message is detected, it calls the processRadarData() function to handle the data. There’s also a printBuffer() function that can display the collected data in a readable format for debugging purposes.



Practical Demonstration:

I have already uploaded the code. Now, you need to be mindful of the radar’s orientation when setting it up.

Rd-03D mmWave Radar

There are two ways to install the sensor, and in my case, I am going with option B. Just make sure the Ai-Thinker logo is at the top.

Rd-03D mmWave Radar installation

Alright, let’s open the Serial Monitor.

Rd-03D mmWave Radar

As you can see, we have successfully read the complete data frame from the radar.

RX_BUF: 0xAA 0xFF 0x03 0x00 0x38 0x00 0x11 0x82 0x00 0x00 0x68 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x55 0xCC

Right now, it’s only detecting one target, so the data for the other two targets shows as 0. You can see how responsive the radar is. I have already explained this data frame in detail, so I am sure there is no confusion at this point.



Multiple Targets Detection:

Next, I activated the multi-target detection mode, and the radar successfully detected two targets.

RX_BUF: 0xAA 0xFF 0x03 0x00 0x05 0x01 0x19 0x82 0x00 0x00 0x68 0x01 0xE3 0x81 0x33 0x88 0x20 0x80 0x68 0x01 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x55 0xCC

For now, I am going to focus on single target detection, because right now I am alone in my studio. And honestly, I don’t even need to detect multiple targets because my work can easily be done with single target detection. That’s because I am mainly interested in the target’s distance and angle.

Looking at this data, it’s hard to understand what’s going on.

Rd-03D mmWave Radar

That’s because all the values are in hexadecimal format. So, let’s first convert this data into a format that’s easy for humans to read and understand!



Modified Single Target Detection Code:

So, as you can see, I have made a few changes to the previous code.

This time, I have also defined some variables specifically for the target, which will help us work with the data more easily.

This code extracts and calculates information about a target from a data buffer (RX_BUF). It combines two bytes to get the X and Y coordinates, then adjusts them: the X coordinate is shifted by 0x200 to center it around zero, and the Y coordinate is shifted by 0x8000 to handle negative values. The speed is calculated similarly, adjusted by 0x10 for an offset. The distance resolution is read as-is, while the total distance is found using the Pythagorean theorem to combine X and Y. Finally, the angle is calculated using the atan2 function, converting the position into degrees for easier interpretation.




Finally, using these instructions,

We send data to the Serial Monitor.

Practical Demonstration:

Rd-03D mmWave Radar

Now, you can easily see the distance, angle, and other data. It might look a bit overwhelming because I am sending a lot of data to the Serial Monitor. I did this just to show you that everything is working perfectly. But let’s simplify it by not printing the X-axis, Y-axis, speed, and distance resolution.

Rd-03D mmWave Radar human distance and angle measuring

Now it’s looking much cleaner and easier to understand. Focus on the distance and angle because this test will give us a full picture of the radar’s capabilities. Honestly, this radar isn’t just responsive – it’s impressively accurate. I have personally tested it, and it can measure distances up to 8 meters with precision while also calculating the angle accurately.

What really stands out is how reliably it measures angles. With this angle information, the possibilities are endless. For instance, you can use it to control loads in different directions based on a target’s left or right movement. Imagine automating lights, fans, or other devices just by moving in a specific direction.



To explain this,

Rd-03D mmWave Radar relay control

I am going to use this 5V SPDT type relay to control a 110/220Vac bulb. This relay is connected to the ESP32 GPIO13. For the relay connections you can follow this circuit diagram.

Rd-03D mmWave Radar 5v spdt relay driver circuit esp32

Safety:

Rd-03D mmWave Radar

Remember safety first, When the 110/220Vac supply is connected, never touch the relay contacts as it can be extremely dangerous. It is important to note that when working with mains voltage, proper safety precautions should always be taken and it is advisable to consult relevant electrical codes and standards.



Controlling a Bulb based on the Human distance:

Code Explanation:

I modified this code slightly to add relay control based on the radar’s target detection. Most of the code remains the same, but here’s what I added.

First, I defined the relay pin (Relay = 13) and a flag (RelayFlag) to track whether the relay is ON or OFF. The flag helps prevent unnecessary toggling of the relay.

I also introduced two timers (relayOnTimer and relayOffTimer) to handle delays for turning the relay ON or OFF. These timers ensure that the relay only activates after a target stays in range for 2 seconds and deactivates 5 seconds after the target moves out of range. This avoids false triggering caused by momentary detection glitches.



Here’s how it works:

when the target is within the set distance range (100–280 cm), the code starts the relayOnTimer. If the target stays in range for 2 seconds, the relay turns ON, and the RelayFlag updates to indicate the relay is active.

Similarly, if the target moves out of range (distance > 280 cm), the relayOffTimer starts. After 5 seconds, the relay turns OFF, and the flag resets.

The timers are reset if the target isn’t consistently in or out of range, ensuring smooth and accurate control. This setup keeps the system responsive and reliable for load control. Let’s watch this in action.




Practical Demonstration:

Rd-03D mmWave Radar load controlling

As you can see, the bulb is ON because my distance from the radar is within the set limit. The light will stay ON as long as I am in this area.

The radar’s algorithm is so smart that even if you are not moving, it can still detect you. This means it can sense even very small movements, called micro-movements. Some sensors fail to detect a person when they are completely still, but that’s not the case with the RD-03D mmWave radar.

It can intelligently pick up even the tiniest movements. For example, I have been in this area for a while now, and the bulb hasn’t turned OFF even once, nor has there been any false triggering.

I also tested this while sitting completely still on a chair, and the sensor worked perfectly. As I mentioned, the bulb will stay ON as long as I am in this area, whether I move forward, backward, left, or right, as long as my distance is within the set limit. The bulb will only turn OFF when my distance increases and I leave the area. For example, if I go to another room, the light will turn OFF automatically.

Rd-03D mmWave Radar home automation

As you saw, the light just turned OFF. Now it will stay OFF until I return to this room. This feature makes it perfect for automating loads in bathrooms, staircases, lawns, and even for security purposes. You can confidently use this radar both indoors and outdoors.

Now, let’s control the load based on the target’s angle!



Controlling a Bulb based on the Human angle/position:

I again modified the code and this time, the relay turns ON when the angle is between 60° and 95° and turns OFF when the target’s angle moves out of this range. Let’s watch this in action.



Practical Demonstration:

Rd-03D mmWave Radar load controlling

This time, the light will stay ON as long as I remain in this area. The light will only turn OFF if I move towards the bathroom or go to the other side of the table.

Rd-03D mmWave Radar human position tracking

For this demonstration, I am using a single bulb, but you can use multiple bulbs too.

Rd-03D mmWave Radar human trajectory tracing

For example, when you’re in the center of the area, one light can turn ON; when you move to the left side, another light can turn ON; and when you move to the right side, a different light can turn ON.

Rd-03D mmWave Radar human angle tracking

You can even control a ceiling fan or control the direction of lights on a staircase based on the target’s movement.



Multiple Targets Code:

Read my articles on

C1001 mmWave Radar Module

Rd-03E mmWave Radar Module

I will also write another article about controlling strip lights and servos based on the human position or angle. Consider subscribing if you don’t want to miss that article and video. So, that’s all for now.




Watch Video Tutorial:

Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Related Articles

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button