A compact, wearable safety system designed to monitor biometric data in real-time and trigger emergency alerts. It connects via Bluetooth to compatible smartwatches to track vital metrics and detect potential distress patterns, aiming to enhance personal safety, particularly for women.
- Real-time Health Monitoring: Tracks heart rate, step count, and battery status.
- Emotion Detection: Analyzes biometric data to classify emotional states.
- Emergency Alert System: Sends automatic SMS alerts via Twilio.
- Watch Removal Detection: Identifies unexpected device removal.
- Bluetooth Device Discovery: Scans and connects to BLE-supported smartwatches.
- Location Tracking: Includes GPS coordinates in alerts.
- Historical Data: Stores and displays past sensor readings.
- Web Dashboard: Centralized dashboard for real-time monitoring and device management.
women-safety-system/
├── backend/ # Flask API server
│ ├── app.py # Main Flask application
│ └── app/
│ ├── alerts/ # SMS and emergency alert services
│ ├── routes/ # API endpoints
│ └── services/ # Core logic for sensor/emotion handling
├── frontend/ # React-based monitoring dashboard
│ └── src/
│ └── components/ # UI components
├── scripts/ # Bluetooth + sensor utilities
│ ├── watchdetails.py # BLE smartwatch connector
│ ├── discover_devices.py # Bluetooth scanning tool
│ └── detectemotion.py # Emotion classification
└── README.md
- Python 3.8+
- Node.js 16+
- Bluetooth-enabled device
- Twilio account
- BLE-compatible smartwatch
pip install flask flask-cors bleak twilio geocoder
cd backend
python app.py # Runs at http://localhost:5000cd frontend
npm install
npm run dev # Runs at http://localhost:5173cd scripts
python discover_devices.py # Find your watch
python watchdetails.py # Connect and start readingUpdate the MAC_ADDRESS in watchdetails.py accordingly.
- Mi Band series
- Honor Band
- Samsung Galaxy Watch
- Fitbit
- Generic BLE fitness trackers
BLE UUIDs:
- Heart Rate:
0000180d - Battery:
0000180f - Step Counter: Custom UUIDs
| Endpoint | Method | Description |
|---|---|---|
/scan |
GET | Discover Bluetooth devices |
/connect/<device_id> |
POST | Connect to a smartwatch |
/history |
GET | Fetch past sensor data |
/api/alerts |
GET | View recent emergency alerts |
/check_health |
POST | Analyze sensor readings |
- High HR: >120 BPM → Stress signal
- Low HR: <60 BPM → Medical risk
- Rapid Step Count: Running or fleeing
- Watch Removed: Disconnected unexpectedly
- Inactivity: Long pause with high HR
- Evaluate biometric data
- Trigger SMS via Twilio
- Attach GPS location
- Log incident in SQLite database
- Notify via frontend dashboard
sensor_data
CREATE TABLE sensor_data (
id INTEGER PRIMARY KEY AUTOINCREMENT,
timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
heart_rate INTEGER,
step_count INTEGER,
battery_level INTEGER,
device_id TEXT,
emotion TEXT
);alerts
CREATE TABLE alerts (
id INTEGER PRIMARY KEY AUTOINCREMENT,
message TEXT NOT NULL,
timestamp TEXT NOT NULL,
status TEXT NOT NULL
);- Stressed: HR > 120 BPM
- Anxious: HR > 90 + low activity
- Energetic: HR > 90 + high activity
- Relaxed: HR < 60 BPM
- Neutral: 60–90 BPM normal
- Encrypted Storage: Protects biometric and alert logs
- Location Sharing: Only during alerts
- Secure API Access: Role-based endpoint control
- Local-First Design: Stores data on device unless opted otherwise
Modify thresholds in backend/app/alerts/smsalert.py:
HR_THRESHOLD_HIGH = 140
HR_THRESHOLD_LOW = 50
STEP_THRESHOLD = 50
WATCH_TIMEOUT = 10 # secondsSet your Twilio credentials:
TWILIO_SID = "your_sid"
TWILIO_AUTH_TOKEN = "your_token"
TWILIO_PHONE = "+1234567890"
EMERGENCY_CONTACT = "+91XXXXXXXXXX"- Bluetooth Issues: Ensure device is BLE-capable and MAC is correct
- No Data: Verify UUID support on your smartwatch
- SMS Failures: Check Twilio config and phone verification
- Debugging: Enable logging with
logging.DEBUG
- ML-based anomaly detection
- Native Android/iOS app
- Group monitoring for families
- Cloud backup options
- Geofencing & region alerts
- Voice-enabled SOS activation
Note: This system is intended to support personal safety but should be complemented with other safety practices.