This repository contains the C++ firmware developed for the Geofencing Tracker Device, a core component of the IoT Patient Surveillance System. Engineered as a wearable tracker, the device samples real-time localization and biological telemetry to enforce safety perimeters.
This project was designed and built during the peak of the COVID-19 pandemic. During the outbreak, ensuring strict quarantine compliance for active cases or asymptomatic individuals (OTG) posed massive logistical challenges for healthcare workers.
Traditional monitoring options often suffered from human fatigue or reporting gaps. This embedded tracking firmware directly solves that problem by transforming consumer microcontrollers into automated containment enforcers. By monitoring both geographical limits and continuous attachment, it ensures patients stay safely within isolation zones without requiring around-the-clock physical security guards.
The tracker device integrates the following hardware components to ensure reliable monitoring, data processing, and physical tamper protection:
| Icon | Component Name | Model / Specification | Purpose & Function |
|---|---|---|---|
| 💻 | Microcontroller & Wi-Fi Module | NodeMCU ESP8266 | Serves as the central processing unit to parse sensor outputs, compute geofence coordinates, and connect to Wi-Fi infrastructure for database sync. |
| 🛰️ | GNSS / GPS Receiver Module | u-blox SAM-M8Q | Tracks and streams high-sensitivity satellite telemetry to obtain accurate Latitude and Longitude coordinate arrays. Interfaced via UART (D7/D8). |
| 🫀 | Pulse Oximeter & Heart-Rate Sensor | MAX30102 | Monitors the biological pulse signals of the patient. Interfaced via I2C (D1/D2). A constant 0 BPM reading acts as a fail-safe trigger for device-detached alerts. |
| 🔋 | Rechargeable Battery | Lithium Polymer (Li-Po) 3.7V 1000mAh (Type 102050PL) | Provides continuous, standalone power to the wearable ankle or wrist tracking device. |
| ⚡ | Battery Management System | BMS Module & 100k Ohm Voltage Divider Resistor | Regulates battery charging parameters and scales down input voltages to allow NodeMCU's analog-to-digital converter to flag low battery drop-downs ( |
The firmware coordinates these specialized components over dynamic communication buses:
-
UART Communication Layer (Pins D7/D8): Interfaces directly with the u-blox SAM-M8Q module to decode positioning variables. Empirical testing shows high reliability with an average deviation of
$<5\text{ meters}$ against flagship mobile benchmarks. - I2C Communication Layer (Pins D1/D2): Interfaces with the MAX30102 biometric sensor. If a patient removes the device, the heartbeat drops to 0 BPM, triggering an anti-tamper panic token.
- ADC Sampling Network (Analog Pin): Monitors battery charge levels to systematically broadcast low-power parameters before system blackouts.
-
NMEA Sentence Parsing: Extracts and normalizes raw satellite sentences from the SAM-M8Q into clean floating decimal Longitude (
$\lambda$ ) and Latitude ($\varphi$ ) arrays. -
Localized Geofence Valuation: Runs local perimeter calculations using the Haversine Formula directly on the edge node before data synchronization:
$$d = \sqrt{\left((\lambda_2 - \lambda_1)\frac{\pi}{180} \cos\left(\frac{(\varphi_2 + \varphi_1)\frac{\pi}{180}}{2}\right)\right)^2 + \left((\varphi_2 - \varphi_1)\frac{\pi}{180}\right)^2} \cdot R$$ Where:
-
$d$ = Calculated distance between two points. -
$R$ = Earth's radius (6,371 km).
-
-
Instant Fault Broadcasting: Pushes an absolute trigger token to the cloud if a perimeter violation, battery dropping, or hardware detaching is recognized.
This tracking node streams metadata directly to a companion monitoring dashboard. 👉 Android Supervisor Dashboard Application: Patient-Surveillance-APPS
- Language: C++ 100%
- Framework: Arduino Framework / PlatformIO Core Ecosystem
- Core Dependencies:
paulstoffregen/Timemikalhart/TinyGPSPlusmobizt/Firebase ESP8266 Clientbblanchon/ArduinoJsonsparkfun/SparkFun MAX3010x Pulse and Proximity Sensor Library


