*Created by Salah Uddin
#include <WiFiClientSecure.h> #include <ThingerESP32.h> #define USERNAME "YOUR_USER_NAME" #define DEVICE_ID "YOUR_DEVICE_ID" #define DEVICE_CREDENTIAL "YOUR_DEVICE_CREDENTIAL" #define SSID "YOUR_WIFI_SSID" #define SSID_PASSWORD "YOUR_WIFI_PASSWORD" ThingerESP32 thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); int bpm; int spo2; unsigned long currentMillis; //hold the current time //pulse oximeter time period #define REPORTING_PERIOD_MS 1000 PulseOximeter pox; uint32_t tsLastReport = 0; // Callback (registered below) fired when a pulse is detected void onBeatDetected() { Serial.println("Beat!"); } //pulse sensor callback function void measured_pulse(){ // Make sure to call update as fast as possible pox.update(); if (millis() - tsLastReport > REPORTING_PERIOD_MS) { bpm=pox.getHeartRate(); tsLastReport = millis(); } } void setup() { Serial.begin(115200); Serial.println("Initializing MAX30100"); // Initialize the PulseOximeter instance and register a beat-detected callback pox.begin(); pox.setOnBeatDetectedCallback(onBeatDetected); pinMode(LED_BUILTIN, OUTPUT); thing.add_wifi(SSID, SSID_PASSWORD); thing["spo2"] >> [](pson& out){out= pox.getSpO2();}; thing["bpm"] >> [](pson& out){out = bpm ;}; // more details at http://docs.thinger.io/arduino/ } void loop() { thing.handle(); currentMillis = millis(); measured_pulse(); }