C4001 mmWave Presence Sensor – Human Detection Up to 25 meter with ESP32/Arduino
Last Updated on November 8, 2025 by Engr. Shahzada Fahad
Table of Contents
Description:
C4001 mmWave Presence Sensor – Human Detection Up to 25 meters with ESP32/Arduino- So far, out of all the mmWave sensors I have tested, this one has the longest detection range. Just imagine, it can detect a human target up to 25 meters away. This is the DFRobot C4001 mmWave Presence Sensor, the 25-meter version.
Now, if you do not need such a long detection distance, the 12-meter version of this same sensor is also incredibly impressive. I have already tested this model in a full dedicated video and article. It works with I2C and UART, supports Arduino, ESP32, ESP8266, Raspberry Pi, and it can detect human presence up to 8 meters and motion up to 12 meters. In that article, I demonstrated smart home automation, speed and distance detection, Blynk monitoring, performance under a ceiling fan, and even detection through Hardboard sheets, glass, curtains, and doors.
Anyway, both sensors look completely different in design, size, and construction. The 12-meter version supports both I2C and UART, while the 25-meter version supports UART only.
The number of transmitting and receiving antennas is also different in both versions. The 25-meter model has more antennas, which means a stronger signal, better sensitivity, and a much longer detection range. More antennas allow it to pick up weaker reflections from distant targets, especially humans, even when the movement is minimal. This is one of the key reasons why the 25-meter version can outperform the 12-meter version so easily.
Their working principle is the same, and both sensors use the same library. I have already explained the library installation process in the 12-meter version article.
Both sensors are capable of monitoring:
- Number of targets
- Target speed
- Target distance
- Target energy
Programming is also around 70 to 80 percent similar, although the 25-meter version has a few small differences that I will show you shortly.
To get the best performance and avoid false triggering, make sure to install the sensor away from WiFi routers and metal surfaces.
Let me tell you there is a big difference between human presence detection and human motion detection. To make this clear, let me walk you through some of the key features of this sensor.
Features:
The C4001 mmWave Presence Sensor offers serious performance for both indoor and outdoor applications.
It can detect human presence up to 16 meters and track motion as far as 25 meters.
It also supports distance measurement from 1.2 meters all the way up to 25 meters and can detect movement speeds between 0.1 and 10 meters per second.
Thanks to its strong anti-interference capability, it continues working reliably even in snow, haze, high or low temperatures, humidity, dust, bright light, or noisy environments. It supports both high and low-level I/O control signals, as well as full serial communication for advanced functions.
Traditional PIR sensors fail when a person stops moving, which leads to lights turning off while someone is still in the room. The C4001 mmWave radar solves this problem. It can detect subtle human presence even when the person is completely still. This means truly smart automation that feels seamless and never relies on you moving just to keep the lights on. We will practically test this.
This comparison really tells the story. PIR sensors are blind to still people, they cannot measure distance or speed, they cannot see through obstacles, and they are easily affected by heat or air movement. The C4001 mmWave radar checks every box where PIR fails.
It detects static humans, provides distance and velocity, works through materials like glass and acrylic, and delivers rock-solid stability even in tough environments. Now the key test: the 12-meter version didn’t detect anything behind drywall. That’s why I am really excited to try the 25-meter model.
Here are the technical specifications. You can pause the video and take your time to read through them.
Specification
Operating Voltage: 3.3V / 5V
Operating Frequency: 24GHz
Modulation Mode: FMCW
Maximum Motion Detection Range: 25m
Human Presence Detection Range: 16m
Distance Measurement Range: 1.2m to 25m
Velocity Measurement Range: 0.1 m/s to 10 m/s
Beam Angle: 100° x 40°
Communication: I/O, UART
Default Baud Rate: 9600
Operating Temperature: -40℃ to 85℃
Dimensions: 26mm x 30mm
Characteristics
Human detection: Detection range up to 16 meters and motion detection range up to 25 meters.
Distance detection: Range from 1.2 meters to 25 meters.
Velocity detection: Range from 0.1 meters per second to 10 meters per second.
Strong anti-interference capability, unaffected by snow, haze, temperature, humidity, dust, light, noise, etc.
High and low level output control through I/O ports.
Input and output control via serial port.
Small size, easy to integrate.
C4001 mmWave Sensor Pinout:
Let’s quickly take a look at the interface pins. The sensor has a very simple pin layout.
- VIN is used to power the module and you can use either 3.3V or 5V.
- GND is ground.
- Then we have RX and
- TX which are used for UART communication with microcontrollers like Arduino or ESP32. Finally, there is an
- OUT pin that provides a voltage output. You can directly use this output to control LEDs, buzzers, relays, or trigger automation even without writing a single line of code. This gives you the flexibility to use the sensor in both microcontroller-based and standalone systems.
Amazon Links:
C4001 mmWave Sensor 12 meters version
C4001 mmWave Sensor 25 meter Version
C4001 mmWave Sensor Product Official Page
Other Tools and Components:
ESP32 WiFi + Bluetooth Module (Recommended)
Arduino Nano USB C type (Recommended)
*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!
C4001 mmWave Sensor Interfacing with the ESP32:
Connect the VIN and GND pins to the ESP32 3.3V and GND. Then connect the TX and RX pins to the ESP32 Serial1 interface, which uses GPIO 16 for RX and GPIO 17 for TX. That’s all you need for hardware connections.
Now let’s move on to the programming and see how we can read distance, motion, and presence data from this powerful radar sensor.
C4001 mmWave 25m Version Programming:
As you can see here, I have two programs opened. Which one you upload depends entirely on your use case. With the 12-meter version, one program was enough for everything. With the 25-meter version, you need to choose.
If you want accurate distance measurement and speed detection, then upload the code you can see on the left side. It runs the radar in Speed Mode, which gives us real-time distance and velocity data.
Speed Mode Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
#include "DFRobot_C4001.h" //#define I2C_COMMUNICATION //use I2C for communication, but use the serial port for communication if the line of codes were masked #ifdef I2C_COMMUNICATION /* * DEVICE_ADDR_0 = 0x2A default iic_address * DEVICE_ADDR_1 = 0x2B */ DFRobot_C4001_I2C radar(&Wire ,DEVICE_ADDR_0); #else /* --------------------------------------------------------------------------------------------------------------------- * board | MCU | Leonardo/Mega2560/M0 | UNO | ESP8266 | ESP32 | microbit | m0 | * VCC | 3.3V/5V | VCC | VCC | VCC | VCC | X | vcc | * GND | GND | GND | GND | GND | GND | X | gnd | * RX | TX | Serial1 TX1 | 5 | 5/D6 | D2 | X | tx1 | * TX | RX | Serial1 RX1 | 4 | 4/D7 | D3 | X | rx1 | * ----------------------------------------------------------------------------------------------------------------------*/ /* Baud rate cannot be changed */ #if defined(ARDUINO_AVR_UNO) || defined(ESP8266) SoftwareSerial mySerial(4, 5); DFRobot_C4001_UART radar(&mySerial ,9600); #elif defined(ESP32) DFRobot_C4001_UART radar(&Serial1 ,9600 ,/*rx*/16 ,/*tx*/17); #else DFRobot_C4001_UART radar(&Serial1 ,9600); #endif #endif void setup() { Serial.begin(115200); while(!Serial); while(!radar.begin()){ Serial.println("NO Deivces !"); delay(1000); } Serial.println("Device connected!"); // speed Mode radar.setSensorMode(eSpeedMode); sSensorStatus_t data; data = radar.getStatus(); // 0 stop 1 start Serial.print("work status = "); Serial.println(data.workStatus); // 0 is exist 1 speed Serial.print("work mode = "); Serial.println(data.workMode); // 0 no init 1 init success Serial.print("init status = "); Serial.println(data.initStatus); Serial.println(); /* * min Detection range Minimum distance, unit cm, range 0.3~20m (30~2000), not exceeding max, otherwise the function is abnormal. * max Detection range Maximum distance, unit cm, range 2.4~20m (240~2000) * thres Target detection threshold, dimensionless unit 0.1, range 0~6553.5 (0~65535) */ if(radar.setDetectThres(/*min*/11, /*max*/2000, /*thres*/10)){ Serial.println("set detect threshold successfully"); } // set Fretting Detection radar.setFrettingDetection(eON); // get confige params Serial.print("min range = "); Serial.println(radar.getTMinRange()); Serial.print("max range = "); Serial.println(radar.getTMaxRange()); Serial.print("threshold range = "); Serial.println(radar.getThresRange()); Serial.print("fretting detection = "); Serial.println(radar.getFrettingDetection()); } void loop() { Serial.print("target number = "); Serial.println(radar.getTargetNumber()); // must exist Serial.print("target Speed = "); Serial.print(radar.getTargetSpeed()); Serial.println(" m/s"); Serial.print("target range = "); Serial.print(radar.getTargetRange()); Serial.println(" m"); Serial.print("target energy = "); Serial.println(radar.getTargetEnergy()); Serial.println(); delay(100); } |
Let’s go ahead and upload this program.
Right now, you can see all the values are zero because there is no one in front of the sensor.
The moment I move into its detection zone, it will immediately start reporting the target count, speed, distance, and energy. This behavior is similar to what we saw with the 12-meter version, and I have already explained these parameters in detail in that article.
|
1 2 3 |
// speed Mode radar.setSensorMode(eSpeedMode); |
In Speed Mode, the radar does more than just detect presence. It can also measure the distance and speed of a moving target. This mode is useful when you want motion tracking with actual range data in centimeters or meters. The target must be moving for the radar to calculate speed and distance, so it is not ideal for detecting someone standing still.
Now let’s take a closer look at the other code.
Exist / Presence Mode Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
#include "DFRobot_C4001.h" //#define I2C_COMMUNICATION //use I2C for communication, but use the serial port for communication if the line of codes were masked #ifdef I2C_COMMUNICATION /* * DEVICE_ADDR_0 = 0x2A default iic_address * DEVICE_ADDR_1 = 0x2B */ DFRobot_C4001_I2C radar(&Wire ,DEVICE_ADDR_0); #else /* --------------------------------------------------------------------------------------------------------------------- * board | MCU | Leonardo/Mega2560/M0 | UNO | ESP8266 | ESP32 | microbit | m0 | * VCC | 3.3V/5V | VCC | VCC | VCC | VCC | X | vcc | * GND | GND | GND | GND | GND | GND | X | gnd | * RX | TX | Serial1 TX1 | 5 | 5/D6 | D2 | X | tx1 | * TX | RX | Serial1 RX1 | 4 | 4/D7 | D3 | X | rx1 | * ----------------------------------------------------------------------------------------------------------------------*/ /* Baud rate cannot be changed */ #if defined(ARDUINO_AVR_UNO) || defined(ESP8266) SoftwareSerial mySerial(4, 5); DFRobot_C4001_UART radar(&mySerial ,9600); #elif defined(ESP32) DFRobot_C4001_UART radar(&Serial1 ,9600 ,/*rx*/16 ,/*tx*/17); #else DFRobot_C4001_UART radar(&Serial1 ,9600); #endif #endif #define RELAY_PIN 13 // Timer variables unsigned long relayTimer = 0; const unsigned long holdTime = 5000; // 5 seconds void setup() { Serial.begin(115200); pinMode(RELAY_PIN, OUTPUT); digitalWrite(RELAY_PIN, LOW); while(!Serial); while(!radar.begin()){ Serial.println("NO Deivces !"); delay(1000); } Serial.println("Device connected!"); // exist Mode radar.setSensorMode(eExitMode); sSensorStatus_t data; data = radar.getStatus(); // 0 stop 1 start Serial.print("work status = "); Serial.println(data.workStatus); // 0 is exist 1 speed Serial.print("work mode = "); Serial.println(data.workMode); // 0 no init 1 init success Serial.print("init status = "); Serial.println(data.initStatus); Serial.println(); /* * min Detection range Minimum distance, unit cm, range 0.3~20m (30~2000), not exceeding max, otherwise the function is abnormal. * max Detection range Maximum distance, unit cm, range 2.4~20m (240~2000) * trig Detection range Maximum distance, unit cm, default trig = max */ if(radar.setDetectionRange(/*min*/30, /*max*/2000, /*trig*/2000)){ Serial.println("set detection range successfully!"); } // set trigger sensitivity 0 - 9 if(radar.setTrigSensitivity(1)){ Serial.println("set trig sensitivity successfully!"); } // set keep sensitivity 0 - 9 if(radar.setKeepSensitivity(2)){ Serial.println("set keep sensitivity successfully!"); } /* * trig Trigger delay, unit 0.01s, range 0~2s (0~200) * keep Maintain the detection timeout, unit 0.5s, range 2~1500 seconds (4~3000) */ if(radar.setDelay(/*trig*/100, /*keep*/4)){ Serial.println("set delay successfully!"); } /* * pwm1 When no target is detected, the duty cycle of the output signal of the OUT pin ranges from 0 to 100 * pwm2 After the target is detected, the duty cycle of the output signal of the OUT pin ranges from 0 to 100 * timer The value ranges from 0 to 255, corresponding to timer x 64ms * For example, timer=20, it takes 20*64ms=1.28s for the duty cycle to change from pwm1 to pwm2. */ if(radar.setPwm(/*pwm1*/50, /*pwm2*/0, /*timer*/10)){ Serial.println("set pwm period successfully!"); } /* * Serial module valid * Set pwm polarity * 0:Output low level when there is a target, output high level when there is no target * 1: Output high level when there is a target, output low level when there is no target (default) */ if(radar.setIoPolaity(1)){ Serial.println("set Io Polaity successfully!"); } // get confige params Serial.print("trig sensitivity = "); Serial.println(radar.getTrigSensitivity()); Serial.print("keep sensitivity = "); Serial.println(radar.getKeepSensitivity()); Serial.print("min range = "); Serial.println(radar.getMinRange()); Serial.print("max range = "); Serial.println(radar.getMaxRange()); Serial.print("trig range = "); Serial.println(radar.getTrigRange()); Serial.print("keep time = "); Serial.println(radar.getKeepTimerout()); Serial.print("trig delay = "); Serial.println(radar.getTrigDelay()); Serial.print("polaity = "); Serial.println(radar.getIoPolaity()); sPwmData_t pwmData; pwmData = radar.getPwm(); Serial.print("pwm1 = "); Serial.println(pwmData.pwm1); Serial.print("pwm2 = "); Serial.println(pwmData.pwm2); Serial.print("pwm timer = "); Serial.println(pwmData.timer); } void loop() { if(radar.motionDetection()){ Serial.println("Motion detected"); digitalWrite(RELAY_PIN, HIGH); // Reset countdown timer relayTimer = millis(); } // Keep relay ON for 5 seconds after last motion if(millis() - relayTimer >= holdTime){ digitalWrite(RELAY_PIN, LOW); } delay(50); } |
If you want accurate motion detection up to 25 meters, then upload this code. It runs the radar in exist Mode. The Exist / Presence mode, is excellent for far-distance detection, but this mode does NOT provide distance measurement. It only tells you whether motion exists in the monitored area.
In this mode, beating the C4001 mmWave sensor is almost impossible, because it can perfectly detect even completely still humans. I am going to take this test to an extreme level, so stay tuned; you definitely don’t want to miss this.
|
1 2 3 4 5 6 7 8 9 |
// exist Mode radar.setSensorMode(eExitMode); So yes, the sensor can detect you from long range with this configuration, but to get distance in meters, you must switch to a mode that reports target range. if(radar.setDelay(/*trig*/100, /*keep*/4)){ Serial.println("set delay successfully!"); } |
Anyway; to control false triggering, you can adjust the Trigger and Keep values based on your requirements. These values directly affect the radar sensor’s response time.
Trigger (trig)
This is the confirmation window. It defines how long motion must be continuously detected before the radar reports it as motion.
Unit: 0.01 seconds
In my setup:
trig = 100
100 × 0.01 s = 1.00 s
That means motion must remain valid for 1 second before the radar flips to “motion detected.”
If you increase this value, the radar will take longer to confirm the motion, which helps reduce false triggers or alarms.
Keep (hold time)
This is the timeout window. It defines how long the radar will continue reporting motion after motion actually stops.
Unit: 0.5 seconds
In my setup:
keep = 4
4 × 0.5 s = 2.0 s
So, after motion stops, the radar will still report motion for 2 seconds before clearing the status.
Relay Timing Logic to Avoid Unwanted Switching
To ensure smooth operation, I have also implemented a 5-second timer for the relay. Whenever motion is detected, the relay immediately turns ON for 5 seconds. If motion is detected again within those 5 seconds, the timer automatically resets.
This means the relay will never switch OFF as long as a person or any moving object remains in that detection area. The moment motion stops completely, only then the countdown will continue, and the relay will turn OFF after 5 seconds.
This smart timer approach prevents rapid ON/OFF switching of the relay, protects connected loads, and ensures reliable motion-based automation.
So, that’s all about the most important things. I have already uploaded the program and now let’s watch this in action.
Practical Demonstration:
For testing purposes, I have placed the sensor on the table. Although it works perfectly fine for demos, the best performance comes when you install it at the recommended mounting height, which is about 1.2 to 1.8 meters above the floor. This height allows the radar waves to properly detect human presence and motion in a realistic environment.
I want you to see a real, practical demo. So I connected a bulb to the relay. Whenever the sensor detects someone, the bulb will turn on. Think of it as if the sensor is installed in your hallway, kitchen, bathroom, or lawn. Let’s start the testing and see how smart this sensor really is.
Range test:
Right now, you can see I am very far away from the sensor, and since I am standing completely still behind this pillar, it is not detecting me. This is the maximum distance where I can practically test this sensor. Anyway, now I am going to step in front of the sensor and let’s see if the bulb turns ON.
This is mind-blowing. Detecting human motion from such a long distance is seriously incredible. This is the highest detection range I have ever witnessed from any sensor. Range test successfully passed.
Limiting the Range:
In this mode; we have full control over the maximum detection range. We can set it to whatever we want.
For example, if I don’t want the bulb to turn ON when there’s movement outside the room; as you can see, the light is still ON because right now the maximum detection range is set to its maximum value which is 25 meters; simply open the program, change the max value, and re-upload it. That’s it.
Now, as you can see, after setting the range, the light doesn’t turn ON even though I am moving in front of the sensor. It only turns ON when I enter its detection area.
This is absolutely mind-blowing. As long as I stay in this area, the light will remain ON.
Once I step out, the light will automatically turn OFF.
Still Human Detection Test:
Now it is time for the real presence test. I will remain completely still. This will prove whether this is actually a human presence sensor or not. I will fast-forward the video a little. “Watch video tutorial given at the end of this article”.
As you can see, I have been standing here for quite a while. I am still far from the sensor, but even without motion, it continues to detect me. I stayed as still as possible and this sensor truly impressed me. It is a real human presence detection sensor. For motion detection and human presence, this thing is absolutely top-notch.
Now, when I step out of the monitored area, this bulb will automatically turn off.
Let’s push this to the extreme. I am going to sit on the floor and remain still. Let’s see if it can still detect me.
I have been sitting here for a long time and the bulb did not turn OFF even once. Now you can confidently decide that this mmWave sensor is not like ordinary sensors. You can use it in advanced security systems and smart automation projects where reliability actually matters.
Behind the Curtain:
It even detected me perfectly through the curtain. I have already tested all of this with the 12-meter C4001 version, and if that smaller module can handle it, then this 25-meter version should have no problem at all. This one is a beast.
Human Detection Behind Wall:
Now comes the real challenge; human detection behind a wall, because the 12-meter version failed in this scenario. So let’s find out whether this 25-meter module can detect a person through a solid wall or not.
Unfortunately, even this sensor was not able to detect me behind the wall. That’s totally fine, because I don’t plan to use it for human detection behind walls. For that purpose, I already have another dedicated sensor from DFRobot, the Gravity Digital Microwave Sensor V2.0, and I have covered that one in great detail in my previous videos.
So now tell me in the comments, what do you think about the 25-meter version of the C4001 mmWave Sensor? Is it something you would use in your smart home or security projects?
C4001 mmWave sensor with Blynk:
Now this final example is for those who want to monitor the C4001 mmWave sensor through the internet using the Blynk application. I am using the same Blynk setup that I used with the 12-meter version, so the virtual pin remains V0. Here is the code you will need to upload to your ESP32 Dev Module.
Blynk Code:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 |
#define BLYNK_PRINT Serial #define BLYNK_TEMPLATE_ID "TMPL6AzrMkP00" #define BLYNK_TEMPLATE_NAME "My Home" #define BLYNK_AUTH_TOKEN "jyApREy2G_dr8J1nBXR92idqQr__90JQ" #include <WiFi.h> #include <WiFiClient.h> #include <BlynkSimpleEsp32.h> #include <Wire.h> #include "DFRobot_C4001.h" //#define I2C_COMMUNICATION //use I2C for communication, but use the serial port for communication if the line of codes were masked #ifdef I2C_COMMUNICATION /* * DEVICE_ADDR_0 = 0x2A default iic_address * DEVICE_ADDR_1 = 0x2B */ DFRobot_C4001_I2C radar(&Wire ,DEVICE_ADDR_0); #else /* --------------------------------------------------------------------------------------------------------------------- * board | MCU | Leonardo/Mega2560/M0 | UNO | ESP8266 | ESP32 | microbit | m0 | * VCC | 3.3V/5V | VCC | VCC | VCC | VCC | X | vcc | * GND | GND | GND | GND | GND | GND | X | gnd | * RX | TX | Serial1 TX1 | 5 | 5/D6 | D2 | X | tx1 | * TX | RX | Serial1 RX1 | 4 | 4/D7 | D3 | X | rx1 | * ----------------------------------------------------------------------------------------------------------------------*/ /* Baud rate cannot be changed */ #if defined(ARDUINO_AVR_UNO) || defined(ESP8266) SoftwareSerial mySerial(4, 5); DFRobot_C4001_UART radar(&mySerial ,9600); #elif defined(ESP32) DFRobot_C4001_UART radar(&Serial1 ,9600 ,/*rx*/16 ,/*tx*/17); #else DFRobot_C4001_UART radar(&Serial1 ,9600); #endif #endif char ssid[] = "fahad"; char pass[] = "fahad123"; unsigned long lastMotionTime = 0; const unsigned long holdTime = 5000; // 5 seconds hold time void setup() { Serial.begin(115200); while(!Serial); while(!radar.begin()){ Serial.println("NO Deivces !"); delay(1000); } Serial.println("Device connected!"); // exist Mode radar.setSensorMode(eExitMode); sSensorStatus_t data; data = radar.getStatus(); // 0 stop 1 start Serial.print("work status = "); Serial.println(data.workStatus); // 0 is exist 1 speed Serial.print("work mode = "); Serial.println(data.workMode); // 0 no init 1 init success Serial.print("init status = "); Serial.println(data.initStatus); Serial.println(); /* * min Detection range Minimum distance, unit cm, range 0.3~20m (30~2000), not exceeding max, otherwise the function is abnormal. * max Detection range Maximum distance, unit cm, range 2.4~20m (240~2000) * trig Detection range Maximum distance, unit cm, default trig = max */ if(radar.setDetectionRange(/*min*/50, /*max*/600, /*trig*/2000)){ Serial.println("set detection range successfully!"); } // set trigger sensitivity 0 - 9 if(radar.setTrigSensitivity(1)){ Serial.println("set trig sensitivity successfully!"); } // set keep sensitivity 0 - 9 if(radar.setKeepSensitivity(2)){ Serial.println("set keep sensitivity successfully!"); } /* * trig Trigger delay, unit 0.01s, range 0~2s (0~200) * keep Maintain the detection timeout, unit 0.5s, range 2~1500 seconds (4~3000) trig = 200 → 200 * 0.01s = 2s of confirmed motion keep = 6 → 6 * 0.5s = 3s of timeout */ if(radar.setDelay(/*trig*/100, /*keep*/4)){ Serial.println("set delay successfully!"); } /* * pwm1 When no target is detected, the duty cycle of the output signal of the OUT pin ranges from 0 to 100 * pwm2 After the target is detected, the duty cycle of the output signal of the OUT pin ranges from 0 to 100 * timer The value ranges from 0 to 255, corresponding to timer x 64ms * For example, timer=20, it takes 20*64ms=1.28s for the duty cycle to change from pwm1 to pwm2. */ if(radar.setPwm(/*pwm1*/50, /*pwm2*/0, /*timer*/10)){ Serial.println("set pwm period successfully!"); } /* * Serial module valid * Set pwm polarity * 0:Output low level when there is a target, output high level when there is no target * 1: Output high level when there is a target, output low level when there is no target (default) */ if(radar.setIoPolaity(1)){ Serial.println("set Io Polaity successfully!"); } // get confige params Serial.print("trig sensitivity = "); Serial.println(radar.getTrigSensitivity()); Serial.print("keep sensitivity = "); Serial.println(radar.getKeepSensitivity()); Serial.print("min range = "); Serial.println(radar.getMinRange()); Serial.print("max range = "); Serial.println(radar.getMaxRange()); Serial.print("trig range = "); Serial.println(radar.getTrigRange()); Serial.print("keep time = "); Serial.println(radar.getKeepTimerout()); Serial.print("trig delay = "); Serial.println(radar.getTrigDelay()); Serial.print("polaity = "); Serial.println(radar.getIoPolaity()); sPwmData_t pwmData; pwmData = radar.getPwm(); Serial.print("pwm1 = "); Serial.println(pwmData.pwm1); Serial.print("pwm2 = "); Serial.println(pwmData.pwm2); Serial.print("pwm timer = "); Serial.println(pwmData.timer); WiFi.mode(WIFI_STA); WiFi.begin(ssid, pass); unsigned long startAttemptTime = millis(); while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 15000) { Serial.print("."); delay(200); } if(WiFi.status() == WL_CONNECTED){ Serial.println("\nWiFi connected!"); } else { Serial.println("\nWiFi failed. Rebooting..."); ESP.restart(); } Blynk.config(BLYNK_AUTH_TOKEN); Blynk.connect(); } void loop() { Blynk.run(); // Check for motion if (radar.motionDetection()) { Serial.println("Motion detected"); lastMotionTime = millis(); // reset timer } // Keep V0 ON for 5 seconds after last motion if (millis() - lastMotionTime <= holdTime) { Blynk.virtualWrite(V0, 1); } else { Blynk.virtualWrite(V0, 0); } delay(100); } |
With this setup, I can now monitor human presence from anywhere in the world through my phone. That means even if I am not at home, I can still know whether someone is moving inside the monitored area. Pretty awesome for smart security systems.
So, that’s all for now.
Watch Video Tutorial:
Discover more from Electronic Clinic
Subscribe to get the latest posts sent to your email.




















