mobizt / Firebase-ESP32

[DEPRECATED]🔥 Firebase RTDB Arduino Library for ESP32. The complete, fast, secured and reliable Firebase Arduino client library that supports CRUD (create, read, update, delete) and Stream operations.
MIT License
415 stars 118 forks source link

Floating Point Values in JSON #100

Closed PrateekGoyal18 closed 3 years ago

PrateekGoyal18 commented 3 years ago

I have some sensor data in float values. Is there some way by which I can add it to the JSON object?

mobizt commented 3 years ago

Library has the built-in JSON builder and parser class.

Declare the FirebaseJson object and use the method add to add new value or use set to replace or create new value.


FirebaseJson json;

//Hard code
json.add("/node1", 123.456f);
//or
json.set("/node2", 0.123f); //this also creates the node2 if it does not existed.

//From variable
json.add("/node3", myVal); // myVal is the float variable. 

The supported variables are bool, int, float, and double. The supported object are String, FirebaseJson and FirebaseJsonArray. Unsupported variables are short, byte, uint8_t, uit16_t, uint32_t, long and so on.

Please check these examples to learn how to use the FirebaseJson object.

PrateekGoyal18 commented 3 years ago

Getting this error: C:\Users\Prateek\AppData\Local\Temp\ArduinoServer\MW\sketch\final_code.ino.cpp.o:(.literal._Z4loopv+0x40): undefined reference to `FirebaseJson& FirebaseJson::add(String const&, float)'

C:\Users\Prateek\AppData\Local\Temp\ArduinoServer\MW\sketch\final_code.ino.cpp.o: In function `loop()':

C:\Users\Prateek\OneDrive\Documents\Arduino\SCD30 Sensor Setup\OLED\final_code/final_code.ino:237: undefined reference to `FirebaseJson& FirebaseJson::add(String const&, float)'

collect2.exe: error: ld returned 1 exit status

mobizt commented 3 years ago

You should update the library.

mobizt commented 3 years ago

Recommend to update to v 3.8.0 (GitHub download is only available due to it updated 30 minutes ago)

PrateekGoyal18 commented 3 years ago

Thanks, @mobizt. It's working flawlessly now.