Microwave Doppler Radar Sensor
The microwave motion sensor is a microwave moving object detector designed using the Doppler radar principle. Unlike general infrared detectors, microwave sensors detect the motion status of objects by detecting the microwaves reflected from objects. The detection objects are not limited to the human body; many other things can also be detected. Microwave sensors are not affected by ambient temperature, have a long detection distance and high sensitivity. They are widely used in industrial, transportation, and civil applications, such as vehicle speed measurement, automatic doors, induction lights, parking radar, and so on. Since the detection objects of microwave sensors are universal, in practical applications, another sensor will be paired for targeted detection. For example, a microwave sensor + infrared pyroelectric sensor can effectively determine whether a person has passed by, will not be interfered with by sunlight or clothing color, and will not react to other objects.
Module Source
Purchase link: https://item.taobao.com/item.htm?spm=a1z10.3-c-s.w4002-19589090137.12.706136b40EmwBc&id=643727489100 Materials download link: https://pan.baidu.com/s/110NZE7hM3ifS1ho53fxmoA Extraction code: 2cz6
Specifications
Operating voltage: 5V±0.25V Operating current: 30~50mA Detection distance: 2-16m continuously adjustable Size: R=30.6mm Output method: GPIO Number of pins: 3 Pin
View Materials
Since the detection objects of microwave sensors are universal, that is, as long as there is any object motion, it can be detected. Therefore, you only need to detect the high and low level changes of the OUT pin.
Porting Process
Pin Selection
Port to Project
Our goal is to port the example to the ESP32-S3 dev board. Complete driver code has been provided for you. Follow the steps below to complete the porting. For detailed instructions on creating folders and new .c and .h files, refer to section 1.4.2 in the [DHT11 Temperature and Humidity Sensor] chapter; we will not repeat it here. However, here we change the file names bsp_dht11.c and bsp_dht11.h to bsp_mh100x.c and bsp_mh100x.h, and rename the folder to MH100X.
Write Code
In the file bsp_mh100x.c, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-02 LCKFB-lp first version
*/
#include "bsp_mh100x.h"
#include "stdio.h"
void delay_ms(unsigned int ms)
{
vTaskDelay(ms / portTICK_PERIOD_MS);
}
/******************************************************************
* Function Name: MH100X_GPIO_Init
* Function Description: MH100X initialization
* Function Parameters: none
* Function Return: none
* Author: LC
* Notes: none
******************************************************************/
void MH100X_GPIO_Init(void)
{
gpio_config_t OUT_config = {
.pin_bit_mask = (1ULL<<OUT_IN), //Configure pin
.mode =GPIO_MODE_INPUT, //Input mode
.pull_up_en = GPIO_PULLUP_ENABLE, //Enable pull-up
.pull_down_en = GPIO_PULLDOWN_DISABLE, //Disable pull-down
.intr_type = GPIO_INTR_DISABLE //Disable pin interrupt
};
gpio_config(&OUT_config);
}
/******************************************************************
* Function Name: OUTPIN_Scanf
* Function Description: Return OUT pin level state
* Function Parameters: none
* Function Return: 1 = no object motion detected 0 = object motion detected
* Author: LC
* Notes: none
******************************************************************/
char OUTPIN_Scanf(void)
{
return OUT_IN;
}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
In the file bsp_mh100x.h, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-02 LCKFB-lp first version
*/
#ifndef _BSP_MH100X_H_
#define _BSP_MH100X_H_
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_log.h"
#include "freertos/queue.h"
#include <inttypes.h>
#include "sdkconfig.h"
#include "driver/gpio.h"
#include "esp_log.h"
#include "rom/ets_sys.h"
#include "esp_system.h"
#include "driver/gpio.h"
#define PIN_OUT 1
#define OUT_IN gpio_get_level(PIN_OUT)
void delay_ms(unsigned int ms);
void MH100X_GPIO_Init(void);//Pin initialization
char OUTPIN_Scanf(void);//Microwave radar input status
#endif2
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
Porting Verification
In the main function of your own project, write the following code.
/*
* LCSC-Openkits (LCKFB) software and hardware materials and related expansion board software and hardware materials are all open source on the official website.
* Dev board official website: www.lckfb.com
* Technical support resides on the forum; any technical questions are welcome for exchange and learning at any time.
* LCKFB Forum: club.szlcsc.com
* Follow our Bilibili account: [LCSC-Openkits (LCKFB)] to keep up with our latest updates!
* We do not make money by selling boards; we take cultivating engineers as our mission.
* Change Logs:
* Date Author Notes
* 2024-01-02 LCKFB-lp first version
*/
#include <stdio.h>
#include "bsp_mh100x.h"
void app_main(void)
{
uint8_t flag = 0;
uint16_t time = 0;
MH100X_GPIO_Init();
printf("demo start\r\n");
while(1)
{
//Object motion detected
if( OUTPIN_Scanf() == 0 )
{
flag = 1;
}
if( flag == 1 )
{
if( time == 0 ) //Open door
{
printf("open\r\n");
}
time++;
if( time >= 2000 )//Close door after more than two seconds
{
time = 0;
flag = 0;
printf("close\r\n");
}
delay_ms(1);//Time base
}
}
}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
Power-on effect:
Driver code:
File Download
📌 Materials Download Center (click to jump)
📌 In the Materials Download Center -> Module Porting Materials Download, inside the compressed package of this chapter.