icon

mmWave Radar Alarm with Telegram Notifications

1 27127 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 <DFRobot_mmWave_Radar.h> 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 <DFRobot_mmWave_Radar.h>

#include <UniversalTelegramBot.h>

 

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