This repository contains the source code and documentation for a Fall detection Smart Watch that detects falls, sends alerts to a contact person through Wi-Fi, displays multiple states or choices, and displays the current time using NTP.
Additionally, it includes a Medication Reminder Phone App developed using the Thunkable platform. The app sends notifications to the user's phone to remind them to take medication at a specific time. It also features a database that allows the user to create an account, select their watch ID, and receive GPS coordinates in the event of an emergency fall.
This project is implemented on the ESP32 microcontroller and integrates multiple advanced embedded systems concepts.
- The smartwatch continuously monitors accelerometer and gyroscope data from the MPU6050 sensor to detect sudden falls.
- When a fall is detected, the watch sends a notification to a predefined contact via Wi-Fi.
- The phone app allows users to set medication reminders, which are sent as notifications to the user's device.
- The app stores user data, including medication schedules and GPS coordinates, in a database.
- In the event of a detected fall, the app sends the user's GPS location (from the phone) to the emergency contact, allowing quick response.
This project showcases advanced embedded software concepts that are highly relevant to the automotive and healthcare industries.
- The system utilizes FreeRTOS to manage multiple tasks, such as reading sensor data, updating the display, and handling Wi-Fi communication, all running in concurrently or in parallel.
- Tasks are designed to ensure non-blocking execution, allowing smooth real-time operation.
- The system is designed using OOP principles, making the code modular and easy to extend.
- Separate classes are used for handling the MPU6050 sensor, OLED display, user inputs, and Wi-Fi notifications, etc..
- Instead of relying on
delay()(which can block other processes), we used non-blocking delays with themillis()function to ensure smooth operation while waiting for events like sensor data processing or OLED updates.
- A software watchdog timer (WDT) is implemented to ensure that the system resets in case of unexpected behavior, preventing lock-ups and ensuring reliability.
- The ESP32 communicates with a backend server via Wi-Fi, sending emergency fall notifications, user data, and medication reminders.
- The server, hosted on a Raspberry Pi, processes incoming alerts and forwards them to the contact person.
- The smartwatch displays the correct time by syncing with an NTP server over Wi-Fi.
- Notifications about falls and medication reminders are sent over Wi-Fi to a predefined contact, allowing for immediate response in case of emergencies.
- The phone app is developed using Thunkable, enabling users to:
- Set up medication reminders.
- Create an account with a unique watch ID.
- Receive GPS coordinates and fall alerts from the watch.
- The app communicates with the ESP32 via Wi-Fi, retrieving real-time information such as fall alerts and medication schedules.
- ESP32: The main microcontroller handling all processing.
- MPU6050: Accelerometer and gyroscope sensor used for detecting falls.
- I2C OLED Display: Displays real-time status, including current time, fall alerts, and other information.
- Input Buttons: Allows the user to decline false falls, activate and deacrivate excersice mode.
- Buzzer: Alerts the user in case of a detected fall.
- Raspberry Pi: Hosts the backend server that processes notifications.
- Chargable Lithium Battery: For power supply and portability.
-
ESP32 Firmware
- Clone this repository and upload the firmware to the ESP32 using the Arduino IDE .
- Install libraries such as WiFi.h, Adafruit_MPU6050.h ,Adafruit_Sensor.h, U8g2lib.h, etc..
- Ensure that the ESP32 is connected to the appropriate Wi-Fi network.
-
Raspberry Pi Server
- Set up the backend server on the Raspberry Pi using the provided Python scripts.
- The server listens for incoming notifications and forwards them to the contact person.
-
Thunkable Phone App
- Install the app on your phone and register your account with the unique watch ID.
- Set medication reminders and emergency contact details through the app.
- Bluetooth Communication: Add Bluetooth functionality to enable communication with nearby devices without needing a Wi-Fi connection.
- Machine Learning for Fall Detection: Use machine learning algorithms to improve the accuracy of fall detection by analyzing sensor data patterns.
- Battery Optimization: Implement energy-efficient power management to prolong battery life.
Contributions to this project are welcome! Feel free to open an issue or submit a pull request.