Healthcare IoT
30 min read
Patient Vital Signs Remote Monitoring System
Build a HIPAA-compliant wearable device for continuous heart rate, SpO2, temperature monitoring with real-time alerts for healthcare providers.
Table of Contents
- 1. Project Overview
- 2. HIPAA Compliance Requirements
- 3. Hardware Components
- 4. Wearable Device Design
- 5. Sensor Integration
- 6. Firmware Development
- 7. Data Security & Encryption
- 8. Cloud Infrastructure
- 9. Healthcare Dashboard
- 10. Emergency Alert System
- 11. Mobile App Integration
- 12. Clinical Testing
1. Project Overview
Remote patient monitoring reduces hospital readmissions by 38% and enables early intervention for deteriorating patients. This project builds a complete healthcare IoT system for continuous vital signs monitoring.
Monitored Parameters:
- Heart Rate (40-200 bpm)
- Blood Oxygen Saturation (SpO2: 70-100%)
- Body Temperature (35-42Β°C)
- Respiratory Rate (8-40 breaths/min)
- Activity Level (accelerometer)
2. HIPAA Compliance Requirements
Critical Requirements:
- Encryption: AES-256 for data at rest, TLS 1.3 for data in transit
- Authentication: Multi-factor authentication for providers
- Audit Logs: Complete access trail for all PHI
- Access Control: Role-based access (RBAC)
- Data Integrity: Checksums and digital signatures
- BAA: Business Associate Agreement with cloud providers
3. Hardware Components
ESP32-WROOM-32Low-power WiFi/BT microcontroller
MAX30102Pulse oximeter & heart rate sensor
MLX90614Non-contact IR temperature sensor
ADXL3453-axis accelerometer for activity
LiPo Battery500mAh rechargeable (24h life)
TP4056Battery charging module
4. Wearable Device Design
// Wearable Form Factor Options
βββββββββββββββββββ¬βββββββββββββββ¬ββββββββββββββ¬βββββββββββββββ
β Form Factor β Battery Life β Comfort β Accuracy β
βββββββββββββββββββΌβββββββββββββββΌββββββββββββββΌβββββββββββββββ€
β Wristband β 24-48 hours β High β Good β
β Chest Patch β 5-7 days β Medium β Excellent β
β Finger Clip β 12-24 hours β Medium β Best (SpO2) β
β Smart Watch β 2-3 days β High β Good β
βββββββββββββββββββ΄βββββββββββββββ΄ββββββββββββββ΄βββββββββββββββ
5. Sensor Integration
// ESP32 MAX30102 Interface
#include <Wire.h>
#include "MAX30105.h"
#include "heartRate.h"
MAX30105 particleSensor;
const byte RATE_SIZE = 4;
byte rates[RATE_SIZE];
byte rateSpot = 0;
long lastBeat = 0;
float beatsPerMinute = 0;
void setup() {
Serial.begin(115200);
// Initialize sensor
if (!particleSensor.begin(Wire, I2C_SPEED_FAST)) {
Serial.println("MAX30102 not found!");
while(1);
}
// Configure for heart rate
particleSensor.setup();
particleSensor.setPulseAmplitudeRed(0x0A);
particleSensor.setPulseAmplitudeGreen(0);
}
void loop() {
long irValue = particleSensor.getIR();
if (checkForBeat(irValue)) {
long delta = millis() - lastBeat;
lastBeat = millis();
beatsPerMinute = 60 / (delta / 1000.0);
rates[rateSpot] = (byte)beatsPerMinute;
rateSpot = (rateSpot + 1) % RATE_SIZE;
// Calculate average
float avg = 0;
for(byte x=0; x
6. Firmware Development
// Low-power BLE implementation
#include <BLEDevice.h>
#include <BLEUtils.h>
#include <BLEServer.h>
#define SERVICE_UUID "4fafc201-1fb5-459e-8fcc-c5c9c331914b"
#define CHARACTERISTIC_UUID "beb5483e-36e1-4688-b7f5-ea07361b26a8"
BLEServer *pServer = NULL;
BLECharacteristic *pCharacteristic = NULL;
void sendVitalData(float hr, float spo2, float temp) {
StaticJsonDocument<128> doc;
doc["hr"] = hr;
doc["spo2"] = spo2;
doc["temp"] = temp;
doc["ts"] = millis();
char jsonBuffer[256];
serializeJson(doc, jsonBuffer);
pCharacteristic->setValue(jsonBuffer);
pCharacteristic->notify();
// Deep sleep between readings
enterDeepSleep(60000); // 1 minute interval
}
void enterDeepSleep(uint64_t time_ms) {
esp_sleep_enable_timer_wakeup(time_ms * 1000);
esp_deep_sleep_start();
}
7. Data Security & Encryption
// End-to-end encryption
#include <mbedtls/aes.h>
#include <mbedtls/entropy.h>
#include <mbedtls/ctr_drbg.h>
// AES-256 encryption for PHI
void encryptPHI(uint8_t* data, size_t len, uint8_t* key) {
mbedtls_aes_context aes;
mbedtls_aes_init(&aes);
mbedtls_aes_setkey_enc(&aes, key, 256);
uint8_t iv[16] = {0}; // Use random IV in production
mbedtls_aes_crypt_cbc(&aes, MBEDTLS_AES_ENCRYPT, len, iv, data, data);
mbedtls_aes_free(&aes);
}
// TLS 1.3 for transmission
WiFiClientSecure client;
client.setCACert(rootCACertificate);
client.setCertificate(clientCertificate);
client.setPrivateKey(clientPrivateKey);
8. Cloud Infrastructure
AWS HIPAA-eligible services:
# AWS Architecture
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β IoT Core βββββββΆβ Lambda βββββββΆβ DynamoDB β
β (Device β β (Processing) β β (Encrypted) β
β Gateway) β β β β β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ
β
βΌ
ββββββββββββββββ
β SNS/SQS β
β (Alerts) β
ββββββββββββββββ
# CloudFormation (HIPAA-compliant)
Resources:
VitalSignsTable:
Type: AWS::DynamoDB::Table
Properties:
TableName: PatientVitalSigns
SSESpecification:
SSEEnabled: true
SSEType: KMS
PointInTimeRecoverySpecification:
PointInTimeRecoveryEnabled: true
9. Healthcare Dashboard
- Real-time vital signs display
- Historical trend charts (24h, 7d, 30d)
- Patient list with status indicators
- Alert history and acknowledgments
- Care team communication tools
10. Emergency Alert System
// Clinical alert rules
const ALERT_RULES = {
BRADYCARDIA: { hr: { min: 40 }, priority: "HIGH" },
TACHYCARDIA: { hr: { max: 120 }, priority: "HIGH" },
HYPOXIA: { spo2: { min: 90 }, priority: "CRITICAL" },
FEVER: { temp: { max: 38.5 }, priority: "MEDIUM" },
HYPOTHERMIA: { temp: { min: 35.5 }, priority: "HIGH" }
};
function evaluateAlerts(vitals) {
const alerts = [];
if (vitals.hr < 40 || vitals.hr > 120) {
alerts.push({
type: "HEART_RATE_ABNORMAL",
priority: "HIGH",
message: `HR: ${vitals.hr} bpm`,
action: "Notify nurse station"
});
}
if (vitals.spo2 < 90) {
alerts.push({
type: "HYPOXIA",
priority: "CRITICAL",
message: `SpO2: ${vitals.spo2}%`,
action: "Immediate intervention required"
});
sendPagerDutyAlert();
}
return alerts;
}
11. Mobile App Integration
// React Native patient app
import PushNotification from 'react-native-push-notification';
function VitalMonitor({ patientId }) {
const [vitals, setVitals] = useState(null);
useEffect(() => {
const subscription = mqtt.subscribe(
`patients/${patientId}/vitals`,
(message) => {
const data = JSON.parse(message);
setVitals(data);
// Local alert
if (data.spo2 < 90) {
PushNotification.localNotification({
title: 'Low Oxygen Alert',
message: `SpO2: ${data.spo2}%`,
priority: 'high'
});
}
}
);
return () => subscription.unsubscribe();
}, []);
return (
<View>
<Text>HR: {vitals?.hr} bpm</Text>
<Text>SpO2: {vitals?.spo2}%</Text>
<Text>Temp: {vitals?.temp}Β°C</Text>
</View>
);
}
12. Clinical Testing
Regulatory Requirements:
- FDA 510(k): Required for medical device classification
- IEC 60601: Electrical safety for medical equipment
- ISO 13485: Quality management for medical devices
- ISO 14971: Risk management for medical devices
- Clinical Validation: Comparison with reference devices
Next Steps
Expand your healthcare IoT system:
- Add ECG monitoring capability
- Integrate with EMR systems (Epic, Cerner)
- Implement fall detection algorithm
- Add medication adherence tracking
- Deploy telemedicine video consultation
Related Articles:
ESP32 Temperature Monitoring |
MQTT Protocol Guide