icon

mmWave Radar Alarm with Telegram Notifications

1 27846 Medium


Ā 

ā€œAlice opened the door and found that it led into a small passage, not much larger than a rat-hole: she knelt down and looked along the passage into the loveliest garden you ever sawā€Ā 

Alice in Wonderland


Ā 

Sometimes you need to know what is going on outside your door. Of course you can install a PIR sensor or HCSR04 distance sensor with cables and all but, wouldn't be cool to use an indoor Milimiter Wave Radar sensor instead? With a MM Wave Radar, you can detect persons up to 9 meters away, behind doors, walls, behind the bed also and you can even detect a stationary humans, like sleeping persons.


Ā 

DFRobot has an interesting MM Wave Radar with part #SEN0395 at $29.00, what can be done with it? What about an alarm with silent Telegram Notification?


Ā 

First of all, what is a milimiter Wave Radar Sensor? Is it the same as a microwave? No it is not. It has better resolution. ā€œ24GHz mm wave sensor first emits FMCW and CW radio waves to the sensing area. Next, the radio waves, reflected by all targets which are in moving, micro-moving, or extremely weak moving state in the area, are converted into electrical signals by the millimeter-wave MMIC circuit in the sensor system. After that, these signals will be sent to the processor and processed through the related signal and data algorithms. Then, the target information can be solved out. The millimeter-wave radar can sense the human presence, stationary and moving people within the detection area. Moreover, it can even detect static or stationary human presence such as a sleeping person. The sensor has a strong anti-interference ability, not to be affected by snow, haze, temperature, humidity, dust, light, noise, etc.ā€Ā 


Ā 

How is this integrated with ESP32 and Arduino?Ā 


Ā 

From electronic point of view VCC, GND and TX/RX From software side, a simple library #include and then serial communication


Ā 

HardwareSerial mySerial(1);

DFRobot_mmWave_Radar sensor(&mySerial);

mySerial.begin(115200, SERIAL_8N1, 5, 7); //RX,TXĀ 

sensor.factoryReset();Ā 

sensor.DetRangeCfg(0, howManyMeters);Ā 


Ā 

To read the sensor just useĀ 

int val = sensor.readPresenceDetection();


Ā 

The returned value will be 0-false or 1-true


Ā 

There are some settings you can touch in regards to latency. Instead of using the default sensor.OutputLatency(0, 0), you can use for example 200, 800: ā€œThe target is detected, the delay time is 5 seconds. The target disappears, the delay time is 20 secondsā€


Ā 

Code settings


Ā 

int LED_BLINK = 10; // onboard led pin for Firebeetle ESP32C

int howManyMeters=2; // until 9 meters

int loopDelay=1000; // delay for looping

int alarmDelay=10000; // delay after the notification is sent to Telegram

int lastStateWasClear=1; // not a settting, but a flag


Parts

Ā 


Ā 

ESP32C3 https://www.dfrobot.com/product-2566.html?tracking=61357a929f73eĀ 

MM Wave Radar https://www.dfrobot.com/product-2282.html?tracking=61357a929f73eĀ 

Female to female jumper cablesĀ 

USB C Power Bank

Ā 

Circuit

Ā 


Ā 

Source code

Ā 

Download mmWave Alarm source code from this link


Ā 

3d printed case

Ā 


Ā 

Download and print these 2 parts with PLA and Support.


Ā 

Arduino IDE Setup


Ā 

Open Arduino IDE and click File→PreferencesĀ 

Add to additional boards manager https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.jsonĀ 

Add ESP32, Install

Click Tools->Board: select ESP32C3 Dev Module (usually the first in the list)

Select USB CDC on boot enabled


Ā 

Then install these 2 libraries

#include

#include

Ā 

Now load the .ino fie, change your WiFi and Telegram credentials and upload to the ESP32C3

Ā 

Telegram integration

Ā 

Ā 

In order to get those credentials for Telegram bot you need to:

Go to Telegram App, search botfather, send /start send /newbot

Go toĀ t.me/sandoombotĀ and get your token

Search idBot in Telegram App

Send /getId

Send a message to the bot created searching by link

Create a Group and add the bot

Load

https://api.telegram.org/botXXXXXXX:YYYYYYY/getUpdates

Extract the ID, like id: -1234567890

Test sending a message to the group withĀ https://api.telegram.org/botXXXXXXXXX/sendMessage?chat_id=-123456789&text=WashingFinished

Ā 


Ā 

Where to go from here

Ā 

There is an interesting sensing area feature that could be added to the code. The module configures that sensing area as 128 equal parts by default, each equal part is about 15cm. The configuration parameters are selected from 0~127, as the index of the distance value in the sensing area.

Ā 

Contact

Ā 

If you need a modification to this project to fit your needs, or a specific project for your electronic parts you are welcome to contact me for a quote @RoniBandiniĀ 

HARDWARE LIST
1 mmwave
1 Firebeetle ESP32C
License
All Rights
Reserved
licensBg
1