I'm trying to set LED light data in Firebase RTDB through the userID, it works but the light keeps ON, it wont turn OFF when i change it to OFF!?
I have used Strings values and int values but still the same result!?
Looked at the examples from the Firebase_client package and now added this line of code: fireStatus = Firebase.RTDB.getInt("pump");
After all it returned this error: no matching function for call to 'FB_RTDB::getInt(const char [5])'
userID according to the documentation is saved in Firebase.ready() but it seems like in the new version if you used it or not it dosen't matter it will still set data with userID.
So what i have done now in the code i removed the Firebase.ready(), but unfortunately, the same issue stills appear but in backwards when i change from 0 to 1 it keeps changing to 0 after 1 second, here is the code:
void loop()
{
if(fireStatus == 1){
String path = "/users/";
path += auth.token.uid.c_str(); //<- user uid of current user that sign in with Email/Password
path += "/pump";
Serial.printf("Led Turned ON", Firebase.RTDB.setInt(&fbdo, path.c_str(), fireStatus) ? "ok" : fbdo.errorReason().c_str());
digitalWrite(D1, HIGH);
}
else if (fireStatus == 0){
String path = "/users/";
path += auth.token.uid.c_str(); //<- user uid of current user that sign in with Email/Password
path += "/pump";
Serial.printf("Led Turned OFF", Firebase.RTDB.setInt(&fbdo, path.c_str(), fireStatus) ? "ok" : fbdo.errorReason().c_str());
digitalWrite(D1, LOW);
}
Hello,
I have removed the comma but the same issue stills appear, so for the Firebase.ready() it seems like in the new version if it has been used or not it's okay it will still set data with userID.
Overall i removed it but unfortunately the same problem appeared but now in backwards the 0 value keeps running but when i change to 1 it will get back to 0.
So in firebase it appears, when i change the 0 to 1 in firebase it will get back to 0.
Here is the code:
void loop()
{
if(fireStatus == 1){
String path = "/users/";
path += auth.token.uid.c_str(); //<- user uid of current user that sign in with Email/Password
path += "/pump";
Serial.printf("Led Turned ON", Firebase.RTDB.setInt(&fbdo, path.c_str(), fireStatus) ? "ok" : fbdo.errorReason().c_str());
digitalWrite(D1, HIGH);
}
else if (fireStatus == 0){
String path = "/users/";
path += auth.token.uid.c_str(); //<- user uid of current user that sign in with Email/Password
path += "/pump";
Serial.printf("Led Turned OFF", Firebase.RTDB.setInt(&fbdo, path.c_str(), fireStatus) ? "ok" : fbdo.errorReason().c_str());
digitalWrite(D1, LOW);
}
changed it to this
fireStatus = Firebase.RTDB.getInt(&fbdo, "/users/pump");
it worked
But also it returns the same issue sorry guys for headache you but it's been around 48 hours for me trying to figure out this issue but no use! anyway i'm not giving up, hope someone could help and i will keep searching.
I don't understand what you're trying to do. You read the status from firebase and light the LED accordingly. Why do you then set the status to the same thing you just read?
@wildbill
Actually after a deep analysis of the code you were right I can do what you referred to, which is turn the light ON & OFF from firebase Rtdb & what is really happening its not getting data from user uid through this:
firebaseStatus = Firebase. RTDB.get(&fbdo, path.c_str());
The problem is in: path.c_str();
path.c_str() - - > refers to - - >
String path = "/users";
path += auth.token.uid.c_str();
path += "/pump" ;
Is there any other way to get data through user uid than this one!