Skip to content

shaypower/CareTether-Firmware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CareTether Firmware

This firmware runs on an ESP32-C3 device with MAX30102 sensor for heart rate and SpO2 monitoring.

Features

  • 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

Collection Schedule

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.

Data Collection

Heart Rate Collection

  • Collects 30 samples over 40 seconds
  • Samples taken every 1 second
  • Valid range: 30-180 BPM
  • Uploads to /api/v1/heart-rate/bulk/

SpO2 Collection

  • 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/

API Endpoints

  • POST /api/v1/heart-rate/bulk/ - Bulk heart rate upload
  • POST /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

Data Structure Examples

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"
}

Hardware Requirements

  • ESP32-C3 development board
  • MAX30102 heart rate and SpO2 sensor
  • MPU6050 accelerometer
  • WiFi connectivity

Configuration

Before building and flashing, update the following constants in src/main.cpp:

Required Configuration:

// 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/";

Optional Configuration:

// Hardware pins (adjust if using different pins)
#define SDA_PIN 6
#define SCL_PIN 7
#define I2C_ADDRESS 0x57
#define BATTERY_PIN 0

Building and Flashing

  1. Install PlatformIO:

    pip install platformio
  2. Configure your settings in src/main.cpp (see Configuration section above)

  3. Connect ESP32-C3 via USB

  4. Build and upload:

    pio run --target upload
  5. Monitor serial output at 115200 baud:

    pio device monitor

WiFi Configuration

The device includes a WiFi Manager that will:

  1. First attempt to connect using the configured credentials
  2. If connection fails, create a WiFi Access Point named CareTether_XXXX
  3. Connect to the AP (password: config123) and visit 192.168.4.1
  4. Configure your WiFi credentials through the web interface

Serial Output

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

About

The firmware for now retired project CareTether

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published