Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define BLYNK_TEMPLATE_ID "TMPLzRXSUQC-"
- #define BLYNK_DEVICE_NAME "Health Monitoring Managment System"
- #define BLYNK_AUTH_TOKEN "awMKSbThymp43rJCyeF-FL6ZRRTShO6o"
- #include <BlynkSimpleEsp8266.h>
- #include <Wire.h>
- #include "MAX30100_PulseOximeter.h"
- #include <ESP8266WiFi.h>
- #include <SPI.h>
- #include <DHT.h>
- #define SS 15
- #define RST 16
- #define DIO0 2
- #define DHTPIN 14
- #define DHTTYPE DHT11
- #define REPORTING_PERIOD_MS 1000
- // PulseOximeter is the higher level interface to the sensor
- // it offers:
- // * beat detection reporting
- // * heart rate calculation
- // * SpO2 (oxidation level) calculation
- PulseOximeter pox;
- DHT dht(DHTPIN, DHTTYPE);
- uint32_t tsLastReport = 0;
- String apiKey = "LNQNRVDTZWELV3QI";
- const char* ssid = "tan5000_2.4GHz@unifi";
- const char* password = "0122435000";
- const char* server = "api.thingspeak.com";
- char auth[] = BLYNK_AUTH_TOKEN;
- BlynkTimer timer;
- WiFiClient client;
- void onBeatDetected()
- {
- Serial.println("Beat!");
- }
- void setup()
- {
- Serial.begin(115200);
- Serial.print("Initializing pulse oximeter..");
- dht.begin();
- WiFi.begin(ssid, password);
- while (WiFi.status() != WL_CONNECTED)
- {
- delay(500);
- Serial.print(".");
- }
- Serial.println("");
- Serial.println("WiFi connected");
- if (!pox.begin()) {
- Serial.println("FAILED");
- for(;;);
- } else {
- Serial.println("SUCCESS");
- }
- Blynk.begin(auth, ssid, pass);
- pox.setOnBeatDetectedCallback(onBeatDetected);
- }
- void loop()
- {
- Blynk.run();
- // Make sure to call update as fast as possible
- pox.update();
- float hum=0; //Stores value
- float temp=0; //Stores value
- temp = dht.readTemperature();
- hum = dht.readHumidity();
- if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
- Serial.print("Heart rate:");
- Serial.print(pox.getHeartRate());
- Serial.print("bpm / SpO2:");
- Serial.print(pox.getSpO2());
- Serial.println("%");
- Serial.print("Temperature:");
- Serial.print(temp);
- Serial.print("C");
- Serial.print(" Humidity: ");
- Serial.print(hum);
- Serial.println("%");
- Serial.println("");
- tsLastReport = millis();
- Blynk.virtualWrite(V1, BPM);
- Blynk.virtualWrite(V2, SpO2);
- Blynk.virtualWrite(V4, temp);
- Blynk.virtualWrite(V3, hum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement