This is an IoT project that sends alerts to configured recipients using Twilio and SendGrid when a physical button is pressed. The device uses an ESP8266 and Arduino.
You need to have the following installed:
- Arduino IDE
- Python 3
- OpenSSL
- ESP8266 board package in Arduino IDE
- ESP8266FS plugin for Arduino IDE
- Following Arduino Libraries: ESP8266WiFi, WiFiManager, ESP8266HTTPClient, WiFiClientSecure
- Clone the repository.
git clone https://github.com/RAHB-REALTORS-Association/panic-button-esp.git
cd panic-button
- Run the Python script that fetches root CA certificates used by Twilio and SendGrid and saves them to the SPIFFS data directory.
python generate_certificates.py
This will generate twilio.crt
and sendgrid.crt
files in the data
directory inside your Arduino project.
-
Prepare your Twilio API key by concatenating your Twilio SID and Auth token with a colon in between (
SID:Auth token
), and then base64 encoding the result. This will be your TWILIO_API_KEY. -
Modify the
panic-button.ino
file inside thepanic-button
folder to use your actual Twilio and SendGrid API keys and recipient details. Please remember to base64 encode your Twilio SID and Auth token and use this as your TWILIO_API_KEY. -
In the Arduino IDE, select your ESP8266 board and the correct COM port.
-
Go to "Sketch" -> "Show Sketch Folder".
-
In the opened window, navigate up a level and then into the
data
directory. -
You should see
twilio.crt
andsendgrid.crt
files here. These are the root CA certificates fetched by our Python script. -
Return to Arduino IDE, go to "Tools" -> "ESP8266 Sketch Data Upload". This will upload the contents of the data directory (the CA certificates) to your ESP8266's filesystem.
-
After uploading the certificates, go to "Sketch" -> "Upload" to compile and upload the sketch to the ESP8266.
Once the device starts up, it will try to connect to the WiFi network. If it can't connect to a known network, it will start an access point called "AutoConnectAP". You can connect to this AP and configure your WiFi credentials.
When you press the panic button, the device will send alerts to all configured recipients via Twilio and SendGrid.
If you want to change the WiFi credentials, keep the reset button pressed for 5 seconds. This will reset the stored WiFi credentials and restart the device. After restart, you can configure new WiFi credentials as described above.