DIY Pocket Size Emergency Button Notifier for Elderly With WiFi -- Personal Alarm (IoT)

7.8K336

Intro: DIY Pocket Size Emergency Button Notifier for Elderly With WiFi -- Personal Alarm (IoT)

This is a DIY Internet-Connected (IoT) Personal Alarm that sends out the GPS coordinates via Email to your relatives or the police when he emergency button is pressed.

Say, you fell down the stairs and hurt yourself and you could not move. This is a one push button notifier that alerts other people, relatives or the police (depending on how you change the programming) that you have been injured or are in danger.

There are countless use cases for this button. For example, if you're walking back home late at night and encounter some 'resistance,' you can just push this button covertly and it can alert 911 for you. It is especially convenient compared to a phone, since you can notify people at just one push, a necessity in some emergencies.

STEP 1: Circuit

Follow the table below for a concise guide in wiring the sensors to the ESP32 Development Board.

I/OI/O Pin #Wire Colour Arduino pin#Push Button1Blue and RedD5 and 3.3V2OrangeGNDBuzzer1BlackD42Ground RailGND

STEP 2: Code

#define BLYNK_PRINT Serial
/* Set this to a bigger number, to enable sending longer messages */
//#define BLYNK_MAX_SENDBYTES 128

#include "WiFi.h"
#include "WiFiClient.h" #include "BlynkSimpleEsp32.h" // replace"" with <>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "YourAuthToken";
// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "YourNetworkName";
char pass[] = "YourPassword";
void emailOnButtonPress()
{
  // *** WARNING: You are limited to send ONLY ONE E-MAIL PER 15 SECONDS! ***
  // Let's send an e-mail when you press the button
  // connected to digital pin 2 on your Arduino
  int isButtonPressed = !digitalRead(4); // Invert state, since button is "Active LOW"
  if (isButtonPressed) // You can write any condition to trigger e-mail sending
  {
    Serial.println(""); // This can be seen in the Serial Monitor
    BLYNK_WRITE(V1) {
    GpsParam gps(param);
   Blynk.email("Subject: URGENT EMERGENCY Emergency Button has been pressed! GPS Coordinates: %d latitude, %d longitude", gps.getLat(), gps.getLon);
   tone (5, 10000);
  }
}
void setup()
{
  // Debug console
  Serial.begin(9600);
  Blynk.begin(auth, ssid, pass);    // get this from your phone
  // You can also specify server:
  //Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 8442);
  //Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8442);
  // Send e-mail when your hardware gets connected to Blynk Server
  // Just put the recepient's "e-mail address", "Subject" and the "message body"
  Blynk.email("your_email@mail.com", "Subject", "My Blynk project is online.");
!
  // Setting the button
  pinMode(4, INPUT_PULLUP);
  // Attach pin 2 interrupt to our handler
  attachInterrupt(digitalPinToInterrupt(2), emailOnButtonPress, CHANGE);
}
void loop()
{
  Blynk.run();
}

STEP 3: Enjoy and Stay Safe!

Enjoy your build and Stay Safe!!

4 Comments

Code does not compile. I get the following error:

Arduino: 1.8.5 (Windows 10), Board: "ESP32 Dev Module, QIO, 80MHz, 4MB (32Mb), 921600, None"

C:\Users\school\Desktop\workspace\EmergencyButton\emergency_button\emergency_button.ino: In function 'void emailOnButtonPress()':

emergency_button:25: error: a function-definition is not allowed here before '{' token

BLYNK_WRITE(V1) {

^

emergency_button:32: error: a function-definition is not allowed here before '{' token

{

^

emergency_button:49: error: a function-definition is not allowed here before '{' token

{

^

emergency_button:51: error: expected '}' at end of input

}

^

Multiple libraries were found for "WiFi.h"
Used: C:\Users\school\Documents\Arduino\hardware\espressif\esp32\libraries\WiFi
Not used: C:\Program Files (x86)\Arduino\libraries\WiFi
exit status 1
a function-definition is not allowed here before '{' token