Skip to content

Quick Start Guide

Get your ESP32C6 + BCGMCU device connected and streaming data in minutes.

  • ESP32C6 device with BCGMCU module
  • Network connectivity (WiFi)
  • Provisioning token from cloud service
  • HTTPS client library

Register your device to obtain authentication credentials:

// ESP32 Arduino example
HTTPClient https;
https.begin("https://api.endpoint.com/api/v1/device/register");
https.addHeader("Content-Type", "application/json");
https.addHeader("Authorization", "Bearer " + provisioning_token);
String payload = "{\"device_info\":{"
"\"device_id\":\"BCGMCU_001\","
"\"mac_address\":\"" + WiFi.macAddress() + "\","
"\"firmware_version\":\"1.0.0\","
"\"bcgmcu_serial\":\"BCG123456789\""
"}}";
int httpCode = https.POST(payload);

Extract and store the device token from registration response:

if (httpCode == 200) {
String response = https.getString();
// Parse JSON and extract device_token
// Store in secure storage (NVS/SPIFFS)
}

Begin sending real-time biomonitoring data:

void streamBCGData() {
HTTPClient https;
https.begin("https://api.endpoint.com/api/v1/data/stream");
https.addHeader("Content-Type", "application/json");
https.addHeader("Authorization", "Bearer " + device_token);
// Read BCGMCU data
int pulse = bcgmcu.getPulseRate();
int breathing = bcgmcu.getBreathingRate();
String payload = "{\"device_id\":\"BCGMCU_001\","
"\"timestamp\":\"" + getCurrentTimestamp() + "\","
"\"sequence_number\":" + seq_num++ + ","
"\"bcg_data\":{"
"\"pulse_rate\":" + pulse + ","
"\"respiratory_rate\":" + breathing +
"}}";
int httpCode = https.POST(payload);
}
// Call every second (1Hz)
void loop() {
streamBCGData();
delay(1000);
}

Send periodic health checks:

void sendStatusUpdate() {
String payload = "{\"device_id\":\"BCGMCU_001\","
"\"status\":{"
"\"bcgmcu_online\":" + bcgmcu.isOnline() + ","
"\"wifi_signal\":" + WiFi.RSSI() + ","
"\"free_memory\":" + ESP.getFreeHeap() + ","
"\"uptime\":" + millis()/1000 +
"}}";
// Send every 5 minutes (300 seconds)
https.POST(payload);
}

Add retry logic with exponential backoff:

bool sendWithRetry(String endpoint, String payload) {
int retries = 0;
int delay_ms = 1000;
while (retries < 3) {
int httpCode = https.POST(payload);
if (httpCode == 200) {
return true;
}
if (httpCode == 429 || httpCode >= 500) {
delay(delay_ms);
delay_ms *= 2; // Exponential backoff
retries++;
} else {
return false; // Don't retry on client errors
}
}
return false;
}
sequenceDiagram
participant D as Device
participant C as Cloud API
D->>C: Register Device
C-->>D: Device Token
loop Every 1 second
D->>C: Stream Data
C-->>D: Acknowledgment
end
loop Every 5 minutes
D->>C: Status Update
C-->>D: Configuration Check
end