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, 2020 at 14:33
  • I believe so, because you can push an array of values to Firebase.
    – Nina
    Aug 13, 2020 at 15:12
  • i think that you have to push properly formatted JSON data ... push only once
    – jsotola
    Aug 13, 2020 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, 2020 at 7:27
  • JsonObject::crateNestedArray() example may be able to help you.
    – hcheung
    Aug 14, 2020 at 13:55

1 Answer 1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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