Every night, your doorstep is being occupied by noisy drunks. This situation can be disruptive, uncomfortable, and even unsafe for your household.
What about a device capable of detecting people seated at the doorstep, notifying updates to an indoor unit, playing a loud recording to clear the area, notifying the family group through Telegram, updating vía OTA and... maintaining a detailed log?
Outside Unitparts
- Beetle ESP32C3
- Ultrasonic sensor
- 5v Power Supply
IndoorUnit parts
- Unihiker
- 2 x Led Switch
- Relay
- Speaker
- 3 watts PAM8403 AMP
- 3d printed case
- Switch
- Power Supply 5V
For people detection, mmWave sensors were tried and discarded due to interference and false positives. Computer Vision was also tried and discarded since the board I had available (Xiao ESP32) could not reach the router.
Finally I have decided to use a DFRobot Beetle ESP32C3 with an Ultrasonic distance sensor. This device wasplaced above the doorstep. Whenever a presence is detected notifications aresent to the family Telegram group and also to a private data channel queried by the Indoor Unit.
Indoor UnitThe Indoor Unit is based on a Unihiker board. A Python code is executed at start and to monitorthe Telegram data channel. Whenever a new message is received, it willtrigger one of 3 sounds:
1. Small ring for regular in-out
2. A “Clear the entry” recorded message
3. A horn with an annoying sound
The Indoor Unit has two LED buttons connected to GPIO for sounds customizations.
Audio is played through a small USB sound board connected to a 3 watts amp. A relay, also connected to GPIO, is used to power the amp right before the playback.
All Indoor Unit operations are recorded in a text log and presented in the Unihiker screen.
For outdoor unit, just 4 female jumper cables to connect the Ultrasonic sensor.
- Sensor echo to Beetle D8
- Sensor trig to Beetle D9
- Sensor vcc to Beetle 3.3v
- Sensor gnd to Beetle GND
Unihiker buttons and relay use the cables that comes with the hardware.
- Relay to P23
- White Button to P22
- Green Button to P21
For USB Sound Board, make sure that you connect the board with lights to the back.
There is a simple cable connection to be made in order to power up the amp with the relay and use the same power source to the USBC cable.
Code settingsOutdoor unit has the following settings
const char* host = "ESP32C3"; // host name for OTA programming
const int trigPin = 9; // Ultrasonic sensor
const int echoPin = 8; // Ultrasonic sensor
#define BOT_TOKEN "" // Telegram Token
String chatOperativo=""; // Telegram group for indoor-outdoor communications
String chatNotification=""; // Telegram group for familiy notifications
#define WIFI_SSID "" // Router SSID
#define WIFI_PASSWORD "" // Router Pass
String img_url = "YOURSERVERHERE.COM/stepguard.png"; // place stepguard.png in a web server and edit host name
Also edit OTA password here
if(form.userid.value=='admin' && form.pwd.value=='123456')"
Inside unit has the following settings
api_id = "" #Telegram API id
api_hash = "" # Telegram API has
myDelay = 5 # Delay in seconds after actions
relay = Pin(Pin.P23, Pin.OUT) # pin settings
buttonWhite = Pin(Pin.P21, Pin.IN) # green boton, used to disable sounds
buttonGreen = Pin(Pin.P22, Pin.IN) # white button
EnclosureFor the external unit a generic waterproof case was used. For the Indoor Unit I have designed a custom enclosure with Fusion 360.
Unihiker SetupConnect the USBC Cable from the PC to the Unihiker. Connect with SSH to the assigned IP 192.168.1.39
The user is root. The password is dfrobot
Run
$ pip install telethon pandas nltk
Using SFTP with the same SSH credentials, upload server.py /images /sounds
For Autorun, you are not able to use cronjobs or rc.local, the trick for Unihiker is to run the Python script using the touch screen utility and enable "auto boot"
Telegram SetupGo to the Telegram API website https://my.telegram.org/appsand log in with your Telegram account.
Click on the “API development tools” link.
Create a new application by filling out the form. You’ll receive an API ID and API hash. Replace the placeholders in the server.py script with your actual API ID and API hash.
Go to Telegram App, search botfather, send /start send /newbot
Send also /setprivacy disable
Go to t.me/botNameHereand get your token
Create 2 groups, one for notification and other for control, search the name of the bot created
and add it to the groups.
Load https://api.telegram.org/botXXXXXXX:YYYYYYY/getUpdates
Extract the ID of each group, like id: -1234567890
Enter that info in the.ino script
Remote CommandsBy sending these commands from your Phone to the communications Telegrams group, you will be able to
- ring: manually playback the ring sound
- despeje: manually playback the “clear the doorstep” in Spanish, sorry
- horn: manually playback the horn sound
- disable: disable all sounds
- enable: enable all sounds
Since a ladder is required to reach the Outside Unit, any code update through Arduino IDE and USB Cable is complicated, so I’ve decided to use install the code for Over the Air Programming. So for updates, I just connect to the units web server and upload a.bin file.
Procedure: Sketch, Export compiled Binary. Then connect to the External Unit ESP32 IP using a web browser and upload the bin file.
Beta testersThe good part is you don’t have to ask for beta testers.
In certain countries, a system like this might seem unnecessary and somewhat extreme. However, in Argentina, we are often closer to barbarism than civilization.
If you have a direct door to the street in Buenos Aires, you are exposed to groups of drunk people (which is not the worst case scenario). Additionally, you are vulnerable to bronze thieves (individuals who will remove any piece of bronze from your doors and windows without facing any penalty or prison time). There are also “trapitos” gangs (people who extort drivers just to allow them to park on the street, without actually taking care of the cars). And let’s not forget the prevalence of regular thieves.
Nevertheless, even if you don’t truly require a system like this, it could be an interesting and fun project.
Demo
Comments
Please log in or sign up to comment.