Advertisement
anoopmail

new

Mar 11th, 2022
869
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define BLYNK_TEMPLATE_ID "TMPLzRXSUQC-"
  2. #define BLYNK_DEVICE_NAME "Health Monitoring Managment System"
  3. #define BLYNK_AUTH_TOKEN "awMKSbThymp43rJCyeF-FL6ZRRTShO6o"
  4. #include <BlynkSimpleEsp8266.h>
  5. #include <Wire.h>
  6. #include "MAX30100_PulseOximeter.h"
  7. #include <ESP8266WiFi.h>
  8. #include <SPI.h>
  9. #include <DHT.h>
  10. #define SS 15
  11. #define RST 16
  12. #define DIO0 2
  13. #define DHTPIN 14      
  14. #define DHTTYPE DHT11  
  15. #define REPORTING_PERIOD_MS     1000
  16.  
  17.  
  18. // PulseOximeter is the higher level interface to the sensor
  19. // it offers:
  20. //  * beat detection reporting
  21. //  * heart rate calculation
  22. //  * SpO2 (oxidation level) calculation
  23. PulseOximeter pox;
  24. DHT dht(DHTPIN, DHTTYPE);
  25. uint32_t tsLastReport = 0;
  26.  
  27. String apiKey = "LNQNRVDTZWELV3QI";
  28. const char* ssid = "tan5000_2.4GHz@unifi";
  29. const char* password = "0122435000";
  30. const char* server = "api.thingspeak.com";
  31. char auth[] = BLYNK_AUTH_TOKEN;
  32. BlynkTimer timer;
  33.  
  34. WiFiClient client;
  35. void onBeatDetected()
  36. {
  37.     Serial.println("Beat!");
  38. }
  39.  
  40. void setup()
  41. {
  42.     Serial.begin(115200);
  43.     Serial.print("Initializing pulse oximeter..");
  44.     dht.begin();
  45.     WiFi.begin(ssid, password);
  46.     while (WiFi.status() != WL_CONNECTED)
  47.      {
  48.             delay(500);
  49.             Serial.print(".");
  50.      }
  51.       Serial.println("");
  52.       Serial.println("WiFi connected");
  53.     if (!pox.begin()) {
  54.         Serial.println("FAILED");
  55.         for(;;);
  56.     } else {
  57.         Serial.println("SUCCESS");
  58.     }
  59.    
  60.     Blynk.begin(auth, ssid, pass);
  61.     pox.setOnBeatDetectedCallback(onBeatDetected);
  62.  
  63. }
  64.  
  65. void loop()
  66. {
  67.     Blynk.run();
  68.     // Make sure to call update as fast as possible
  69.     pox.update();
  70.      float hum=0; //Stores value
  71.      float temp=0; //Stores value
  72.  
  73.   temp = dht.readTemperature();
  74.   hum = dht.readHumidity();
  75.  
  76.     if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
  77.         Serial.print("Heart rate:");
  78.         Serial.print(pox.getHeartRate());
  79.         Serial.print("bpm / SpO2:");
  80.         Serial.print(pox.getSpO2());
  81.         Serial.println("%");
  82.         Serial.print("Temperature:");
  83.         Serial.print(temp);
  84.         Serial.print("C");
  85.         Serial.print(" Humidity: ");
  86.         Serial.print(hum);
  87.         Serial.println("%");
  88.         Serial.println("");
  89.         tsLastReport = millis();
  90.        
  91.         Blynk.virtualWrite(V1, BPM);
  92.         Blynk.virtualWrite(V2, SpO2);
  93.         Blynk.virtualWrite(V4, temp);
  94.         Blynk.virtualWrite(V3, hum);
  95.                  
  96.     }    
  97.                  
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement