-
Notifications
You must be signed in to change notification settings - Fork 0
/
firebase_params.h
44 lines (35 loc) · 1.1 KB
/
firebase_params.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include "Firebase_Arduino_WiFiNINA.h"
#include <WiFiNINA.h>
//CONFIGURATION 1: NEEDED TO WORK WITH WIFI
char ssid[] = "...";
char pass[] = "...";
//END CONFIGURATION 1
//CONFIGURATION 2: NEEDED TO WORK WITH FIREBASE
#define FIREBASE_HOST "....firebaseio.com"//Your database
#define FIREBASE_AUTH "..." //The secret
//END CONFIGURATION 2
FirebaseData firebaseData;
int status = WL_IDLE_STATUS;
void StartFirebase(){
while (status != WL_CONNECTED) {
status = WiFi.begin(ssid, pass);
delay(10000);
}
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, ssid, pass);
Firebase.reconnectWiFi(true);
}
String SendFirebase(String Path, String JsonSerialized){
Firebase.reconnectWiFi (true);
if (!firebaseData.bufferOverflow()) {
if (!Firebase.pushJSON(firebaseData, Path, JsonSerialized)) {
status = WiFi.status ();
Serial.print("Error Wifi: ");
Serial.println(status);
return firebaseData.errorReason();
} else {
return "sent";
}
} else {
return "error overflow";
}
}