#include <stdio.h>
#include <WiFi.h>
#include <FirebaseESP32.h>

#define WIFI_SSID "WIFI_AP"
#define WIFI_PASSWORD "WIFI_PASSWORD"

#define FIREBASE_HOST "PROJECT_ID.firebaseio.com"
#define FIREBASE_AUTH "DATABASE_SECRET"


FirebaseData fbdo;

FirebaseJson json;

float Rh= 30.30;
float Rt= 31.30;
float Tp1=32.30;
float Tp2=33.30;

char buf[64];

void setup()
{
  Serial.begin(115200);

  WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
  Serial.print("Connecting to Wi-Fi");
  while (WiFi.status() != WL_CONNECTED)
  {
    Serial.print(".");
    delay(300);
  }
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
  Firebase.reconnectWiFi(true);
  Firebase.setReadTimeout(fbdo, 1000 * 60);
  Firebase.setwriteSizeLimit(fbdo, "tiny");
  Firebase.setFloatDigits(2);
  Firebase.setDoubleDigits(6);


String   path = "/TEST/Rh";
 
  Firebase.setFloat(fbdo, path,Rh);
     path = "/TEST/Rt";
  Firebase.setFloat(fbdo, path,Rh);
     path = "/TEST/Tp1";
  Firebase.setFloat(fbdo, path,Tp1);
     path = "/TEST/Tp2";
  Firebase.setFloat(fbdo, path,Tp2);

 
  json.clear();
  sprintf(buf,"%2.02f",Rh);
  json.add("Rh",String(buf));
 
  sprintf(buf,"%2.02f",Rt);
  json.add("Rt",String(buf));
 
  sprintf(buf,"%2.02f",Tp1);
  json.add("T1",String(buf));
 
  sprintf(buf,"%2.02f",Tp2);
  json.add("T2",String(buf));
   
  path="TEST/graph";
  Firebase.pushJSON(fbdo, path, json);
}

void loop()
{
 
}

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

Async IOT

csv to firebase