-
Can you tell me how to send Array to Firebase from NodeMCU ESP8266? I'm totally new at this |
Beta Was this translation helpful? Give feedback.
Answered by
mobizt
Jul 5, 2021
Replies: 3 comments 10 replies
-
Here the basic usage example of array. FirebaseData fbdo;
FirebaseJsonArray arr; // you can add or set the array data
arr.add(123); //index 0
arr.add(true);
arr.add("test");
arr.add(456.789); //index 3
//arr.set("/[5]", "hello"); //index 5 assigned with path, now index 4 which never assigned will be null value.
//arr.set(7, 999); //index 7 assigned with number, now index 6 will be null value.
//arr.set("/[8]/car/[2]/xyz", true); //index 8 assigned with nested array and json object inside.
if (Firebase.setArray(fbdo, "path/to/node", arr)) //or Firebase.set(fbdo, "path/to/node", arr)
{
Seril.println("set array ok");
}else{
Seril.println("set array failed");
Seril.println(fbdo.errorReason());
}
if (Firebase.getArray(fbdo, "path/to/node")) // or Firebase.get(fbdo, "path/to/node"))
{
Seril.println("get array ok");
printResult(fbdo); //See https://github.com/mobizt/Firebase-ESP8266/blob/f902eca7a8cc09977880058575e4f12030d1575e/src/addons/RTDBHelper.h#L20
}else{
Seril.println("get array failed");
Seril.println(fbdo.errorReason());
}
|
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
giservin
-
Thank you so much Sir, it worked
Pada tanggal Sen, 5 Jul 2021 pukul 17.00 mobizt ***@***.***>
menulis:
… Here the basic usage example of array.
FirebaseData fbdo;
FirebaseJsonArray arr; // you can add or set the array data
arr.add(123); //index 0
arr.add(true);
arr.add("test");
arr.add(456.789); //index 3//arr.set("/[5]", "hello"); //index 5 assign with path, now index 4 which never assigned will be null value.//arr.set(7, 999); //index 7 assign with number, now index 6 will be null value.//arr.set("/[8]/car/[2]/xyz", true); //index 8 with nested array and json object inside.
if (Firebase.setArray(fbdo, "path/to/node", arr)) //or Firebase.set(fbdo, "path/to/node", arr)
{
Seril.println("set array ok");
}else{
Seril.println("set array failed");
Seril.println(fbdo.errorReason());
}
if (Firebase.getArray(fbdo, "path/to/node")) // or Firebase.get(fbdo, "path/to/node"))
{
Seril.println("get array ok");
printResult(fbdo); //See https://github.com/mobizt/Firebase-ESP8266/blob/f902eca7a8cc09977880058575e4f12030d1575e/src/addons/RTDBHelper.h#L20
}else{
Seril.println("get array failed");
Seril.println(fbdo.errorReason());
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUJVYH32VDCKMLRFYMBT22DTWF7CBANCNFSM472KUZMQ>
.
|
Beta Was this translation helpful? Give feedback.
6 replies
-
I want the esp8266 could send like this |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here the basic usage example of array.