Project Gem - Panic button with ESP8266 & OpenWrt Linux
Branimir Valentić | 19.10.2015.Gem is an ESP8266 based panic button pendant that triggers sending of notifications (e-mail,SMS) over a base station device. I will post updates, this project is still work in progress, and it’s
only a segment of a bigger project, but here’s a picture of the first working version:
How does it work:
Gem has implemented MQTT client that sends its state to a base station(access point running Linux and MQTT) when it detects a button press and periodically(every hour) to make sure everything is in working order.
In short steps:
1. Connect to wifi base station
2. Ping base station over MQTT
3. Check panic pin input
4. Set panicPin to OUTPUT && LOW to discharge button circuit and set panicPin to LOW
5. Set panicPin back to INPUT
6. Go to deep sleep for an hour
7. On panic button press (interrupt deep sleep)
-Put logic level HIGH on panicButton gpio via hardware
-Ground the reset pin and trigger step 1
When active ESP will consume around 80 mA, and in deepsleep around 80uA.
Parts needed:
2x 1n4007 Diodes
1x 35V 330uF Capacitor, can try different values
1x 68kOhm resistor for panicPin PULLDOWN, can try different values
1x DPDT DIP 2 pole pushbutton momentary , I hacked together mine for the first version
1x ESP8266
1x 3.3V power source
4x 10k resistors (not indicated in the scheme) are also needed for stable work of bare minimum ESP setup: 3 for pullup on CH_PD, RESET and GPIO0 and one pulldown on gpio15
Setup:
Deep sleep delay switch:
The circuit is designed to hold voltage level for digitalRead HIGH on panicPin after button press and is needed to distinguish between waking up on timer and button press.
ESP Code:
https://github.com/VBranimir/Gem-Panic-button
Base code:
In the current state of the project i use TP-link tlwr703n with OpenWrt, but I’ll describe what needs to be done in order for this project to work in next post, here’s a few details upfront:
1. Flash OpenWrt on the device and enable extroot.
2. install mosquito:
opkg update
opkg install mosquitto mosquitto-client libmosquitto nano
You can now subscribe to a topic with command from terminal with command:
mosquitto_sub -d -t /sensors/panicbutton -h
3. The simplest way to send mail from OpenWrt is mailsend so install it and try it:
opkg install mailsend
echo “Panic button presed” > /tmp/body
mailsend -f your_name@email.com -t reciever@mail.com -smtp smtp-mail.com -port 587 -starttls -auth -user your_name@email.com -pass password -sub “It works!!” -msg-body /tmp/body
4. ignore last two steps and make it all work with python. I’ll keep you posted!