safwan092

project-7701-NodeMCU-Code

Apr 28th, 2021
767
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ESP8266WiFi.h>
  2. #include <FirebaseArduino.h>
  3.  
  4. #define FIREBASE_HOST "lifeband-50524.firebaseio.com"
  5. #define FIREBASE_AUTH "U4sY0c5v5zT0wCeOzoLNv0ZJUQx9sjURJx9ceIRT"
  6. #define WIFI_SSID "network"
  7. #define WIFI_PASSWORD "123456789"
  8.  
  9. String Temp;
  10. String BPM;
  11. void setup() {
  12.   Serial.begin(115200);
  13.   WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  14.   Serial.print("connecting");
  15.   while (WiFi.status() != WL_CONNECTED) {
  16.     Serial.print(".");
  17.     delay(500);
  18.   }
  19.   Serial.println();
  20.   Serial.print("connected: ");
  21.   Serial.println(WiFi.localIP());
  22.   Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  23. }
  24.  
  25. int n = 0;
  26.  
  27. void loop() {
  28.   if (Serial.available() > 0) {
  29.     BPM  = Serial.readStringUntil(',');
  30.     Serial.read();
  31.     Temp = Serial.readStringUntil(',');
  32.     Serial.read();
  33.     String tmp = Serial.readStringUntil('\0');
  34.     Serial.println(BPM);
  35.     Serial.println(Temp);
  36.     Firebase.setString("BPM", BPM);
  37.     if (Firebase.failed()) {
  38.       Serial.print("setting /number failed:");
  39.       Serial.println(Firebase.error());
  40.       return;
  41.     }
  42.     Firebase.setString("Temp", Temp);
  43.     if (Firebase.failed()) {
  44.       Serial.print("setting /number failed:");
  45.       Serial.println(Firebase.error());
  46.       return;
  47.     }
  48.     delay(1000);
  49.   }
  50. }// end of LOOP
RAW Paste Data