There's probably answer somewhere on the forum, but couldn't see it.
I don't use strings normally but appears to be popular on Arduino??
I'm using an ESP32 firebase library where I need to read back a data string (or character array).
This will normally be over 12 characters.
this is the function I'm using:
if (Firebase.get(firebaseData, "/Project/datastring"))
{
mydata = (firebaseData.stringData());
}
I want to use a container something like:
char* mydata;
char mydata[64];
I can do this with string to floats:
if (Firebase.get(firebaseData, "/Project/myfloat"))
{
myfloat = (firebaseData.stringData().toFloat());
}
I have been doing this:
display.printf("mystring: %s\n", mystring.c_str());
to display the data, but I need to put this in a container.
Is there a more simple preferred way?
Thank you
J-M-L
January 5, 2021, 6:18pm
2
what's the type of whatever is returned by Firebase.get()? which library are you using?
blh64
January 6, 2021, 4:55am
3
if you want a copy of what comes back:
char mydata[64];
if (Firebase.get(firebaseData, "/Project/datastring"))
{
strcpy(mydata,firebaseData.stringData().c_str());
}
blh64:
if you want a copy of what comes back:
char mydata[64];
if (Firebase.get(firebaseData, "/Project/datastring"))
{
strcpy(mydata,firebaseData.stringData().c_str());
}
Thankyou @blh64 that works just fine.
J-M-L:
what's the type of whatever is returned by Firebase.get()? which library are you using?
Sorry @J-M-L , I should have mentioned it's this one:
🔥 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. - GitHu...
The data type stored on Firebase is a string (generated from a json array).
I use standard GET function and sort the data when it comes in.
However this is the first time I've used Arduino, generally I use Mbed but can't program on there as the ESP32 is not an ARM core.
system
Closed
May 6, 2021, 10:06am
5
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.