This firmware runs on an ESP32-C3 device with MAX30102 sensor for heart rate and SpO2 monitoring.
- Heart Rate Monitoring: Collects heart rate data every 60 seconds
- SpO2 Monitoring: Collects blood oxygen saturation data every 120 seconds
- Fall Detection: Uses MPU6050 accelerometer for fall detection
- WiFi Connectivity: Connects to WiFi and uploads data to API
- Bulk Data Upload: Efficiently uploads batches of sensor data
The device alternates between heart rate and SpO2 collection to avoid sensor conflicts:
- Heart Rate: Every 60 seconds (40s collection + 20s idle)
- SpO2: Every 120 seconds (40s collection + 80s idle)
This ensures the MAX30102 sensor is not being used simultaneously for both measurements.
- Collects 30 samples over 40 seconds
- Samples taken every 1 second
- Valid range: 30-180 BPM
- Uploads to
/api/v1/heart-rate/bulk/
- Collects 32 samples over 40 seconds
- Samples taken every 1 second
- Valid range: 70-100%
- Focuses only on blood oxygen saturation data
- Uploads to
/api/v1/spo2/bulk/
POST /api/v1/heart-rate/bulk/- Bulk heart rate uploadPOST /api/v1/spo2/bulk/- Bulk SpO2 upload (SpO2 values only)POST /api/v1/alerts/- Device-originated alerts (fall detection, etc.)POST /api/v1/locations/- Location updates
Heart Rate Bulk Upload:
{
"device": "device-uuid",
"readings": [
{
"value": 75,
"timestamp": "2025-01-15T14:45:00Z",
"metadata": {"spo2": 98}
}
]
}SpO2 Bulk Upload:
{
"device": "device-uuid",
"readings": [
{
"value": 98,
"timestamp": "2025-01-15T14:45:00Z"
}
]
}Device Alert:
{
"device": "device-uuid",
"message": "Fall detected by device sensors",
"details": "Accelerometer threshold exceeded"
}- ESP32-C3 development board
- MAX30102 heart rate and SpO2 sensor
- MPU6050 accelerometer
- WiFi connectivity
Before building and flashing, update the following constants in src/main.cpp:
// WiFi Configuration (replace with your network details)
const char* defaultSSID = "YOUR_WIFI_SSID";
const char* defaultPassword = "YOUR_WIFI_PASSWORD";
// API Configuration (replace with your backend server)
const char* apiBaseUrl = "https://your-api-server.com/api/v1/";// Hardware pins (adjust if using different pins)
#define SDA_PIN 6
#define SCL_PIN 7
#define I2C_ADDRESS 0x57
#define BATTERY_PIN 0-
Install PlatformIO:
pip install platformio
-
Configure your settings in
src/main.cpp(see Configuration section above) -
Connect ESP32-C3 via USB
-
Build and upload:
pio run --target upload
-
Monitor serial output at 115200 baud:
pio device monitor
The device includes a WiFi Manager that will:
- First attempt to connect using the configured credentials
- If connection fails, create a WiFi Access Point named
CareTether_XXXX - Connect to the AP (password:
config123) and visit192.168.4.1 - Configure your WiFi credentials through the web interface
The device provides detailed logging via serial monitor:
[MAIN]- Main program events[HR]- Heart rate collection events[SpO2]- SpO2 collection events[API]- API communication events[WiFi]- WiFi connection events