0

I would like to push two values at the same time (to the same node) from arduino to firebase. I tried to create an array and push the array to firebase, however, that is not working.

Here are the two values that I'm pushing, but I would like to push them to the same unique key:

temp1 = sensors.getTempCByIndex(0);
 StaticJsonBuffer<50> jsonBuffer;
JsonObject& timeStampObject = jsonBuffer.createObject();
timeStampObject[".sv"] = "timestamp";

Firebase.push("Sensors/20/temperatures/001", temp1);
Firebase.push("Sensors/20/temperatures/001", timeStampObject);

How it should look like in Firebase

Thanks in advance!

5
  • does firebase allow what you are trying to do?
    – jsotola
    Aug 13 '20 at 14:33
  • I believe so, because you can push an array of values to Firebase.
    – Nina
    Aug 13 '20 at 15:12
  • i think that you have to push properly formatted JSON data ... push only once
    – jsotola
    Aug 13 '20 at 16:54
  • I tried pushing it only once using an array. However, I don't know how to add a json object to an array.
    – Nina
    Aug 14 '20 at 7:27
  • JsonObject::crateNestedArray() example may be able to help you.
    – hcheung
    Aug 14 '20 at 13:55
0

@hcheung thanks for your help! It solved the problem. This is my code now:

StaticJsonBuffer<256> jsonBuffer;
JsonArray& array = jsonBuffer.createArray();
array.add(timeStampObject);
array.add(temp1);
Firebase.push("Sensors", array);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.