Tired the new FirebaseClient library. Got errors for my code which I don't even know the origin of.
My code
#include <FirebaseClient.h>
#include <WiFiNINA.h>
#include <Arduino_MKRENV.h>
#define WIFI_SSID ""
#define WIFI_PASSWORD ""
#define API_KEY ""
#define USER_EMAIL ""
#define USER_PASSWORD ""
#define DATABASE_URL "https://nasahunch-174c5-default-rtdb.firebaseio.com/"
void asyncCB(AsyncResult &aResult);
DefaultNetwork network; // Initilize with boolean parameter to enable/disable network reconnection
UserAuth user_auth(API_KEY, USER_EMAIL, USER_PASSWORD);
FirebaseApp app;
#include <WiFiSSLClient.h>
WiFiSSLClient ssl_client;
// In case the keyword AsyncClient using in this example was ambigous and used by other library, you can change
// it with other name with keyword "using" or use the class name AsyncClientClass directly.
using AsyncClient = AsyncClientClass;
AsyncClient aClient(ssl_client, getNetwork(network));
RealtimeDatabase Database;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
Serial.print("Connecting to Wifi");
unsigned long ms = millis();
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(300);
}
Serial.println();
Serial.print("Connected with IP: ");
Serial.println(WiFi.localIP());
Serial.println();
// Initialize environmental sensor
if (!ENV.begin()) {
Serial.println("Failed to initialize ENV sensor!");
while (1);
}
Serial.println("ENV sensor initialized");
Serial.println();
Firebase.printf("Firebase Client v%s\n", FIREBASE_CLIENT_VERSION);
Serial.println("Initializing app...");
app.setCallback(asyncCB);
initializeApp(aClient, app, getAuth(user_auth));
ms = millis();
while (app.isInitialized() && !app.ready() && millis() - ms < 120 * 1000)
;
app.getApp<RealtimeDatabase>(Database);
Database.url(DATABASE_URL);
Serial.println("Asynchronous Push... ");
}
void loop() {
// put your main code here, to run repeatedly:
app.loop();
int temperature_C = ENV.readTemperature();
int temperature_F = ENV.readTemperature(FAHRENHEIT);
int humidity = ENV.readHumidity();
int pressure = ENV.readPressure();
int luminosity = ENV.readIlluminance();
Database.push<int>(aClient, "/humid", humidity, asyncCB);
}
void asyncCB(AsyncResult &aResult)
{
// To get the UID (string) from async result
// aResult.uid();
if (aResult.appEvent().code() > 0)
{
Firebase.printf("Event msg: %s, code: %d\n", aResult.appEvent().message().c_str(), aResult.appEvent().code());
}
if (aResult.isDebug())
{
Firebase.printf("Debug msg: %s\n", aResult.debug().c_str());
}
if (aResult.isError())
{
Firebase.printf("Error msg: %s, code: %d\n", aResult.error().message().c_str(), aResult.error().code());
}
if (aResult.available())
{
if (aResult.to<RealtimeDatabaseResult>().name().length())
Firebase.printf("name: %s\n", aResult.to<RealtimeDatabaseResult>().name().c_str());
Firebase.printf("payload: %s\n", aResult.c_str());
}
}
Describe the bug After reading all of the documentation and following it exactly as it wanted, I tried to write the code for my needs and I was getting a bunch of errors that have nothing to do with my code.
Errors: Arduino: 1.8.19 (Windows Store 1.8.57.0) (Windows 10), Board: "Arduino MKR WiFi 1010"
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h: In instantiation of 'typename std::enable_if<(((((ValueConverter::v_number
C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/database/RealtimeDatabase.h:645:9: required from 'void RealtimeDatabase::push(AsyncClientClass&, const arduino::String&, T, AsyncResultCallback, const arduino::String&) [with T = int; AsyncResultCallback = void (*)(AsyncResult&)]'
C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:89:58: required from here
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: ambiguous overload for 'operator=' (operand types are 'arduino::String' and 'char')
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:97:11: note: candidate: arduino::String& arduino::String::operator=(const arduino::String&)
String & operator = (const String &rhs);
^~~~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:97:11: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: conversion from 'char' to 'const arduino::String' is ambiguous
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:74:2: note: candidate: arduino::String::String(const arduino::__FlashStringHelper*)
String(const __FlashStringHelper *str);
^~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:74:2: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:70:2: note: candidate: arduino::String::String(const char*)
String(const char *cstr = "");
^~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:70:2: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:98:11: note: candidate: arduino::String& arduino::String::operator=(const char*)
String & operator = (const char *cstr);
^~~~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:98:11: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:99:11: note: candidate: arduino::String& arduino::String::operator=(const arduino::__FlashStringHelper*)
String & operator = (const __FlashStringHelper *str);
^~~~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:99:11: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:100:11: note: candidate: arduino::String& arduino::String::operator=(arduino::String&&)
String & operator = (String &&rval);
^~~~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:100:11: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: conversion from 'char' to 'arduino::String' is ambiguous
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:74:2: note: candidate: arduino::String::String(const arduino::__FlashStringHelper*)
String(const __FlashStringHelper *str);
^~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:74:2: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const arduino::__FlashStringHelper*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
In file included from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/IPAddress.h:24:0,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/ArduinoAPI.h:30,
from C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/Arduino.h:23,
from sketch\sketch_apr06a.ino.cpp:1:
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:70:2: note: candidate: arduino::String::String(const char*)
String(const char *cstr = "");
^~~~~~
C:\Users\vkali\Documents\ArduinoData\packages\arduino\hardware\samd\1.8.14\cores\arduino/api/String.h:70:2: note: conversion of argument 1 would be ill-formed:
In file included from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\asyncresult.h:27:0,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\authconfig.h:31,
from c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\firebaseapp.h:29,
from C:\Users\vkali\Documents\Arduino\libraries\FirebaseClient\src/FirebaseClient.h:36,
from C:\Users\vkali\Downloads\sketch_apr06a\sketch_apr06a.ino:1:
c:\users\vkali\documents\arduino\libraries\firebaseclient\src\core\asyncresult\Value.h:217:17: error: invalid conversion from 'char' to 'const char*' [-fpermissive]
buf = '\"';
~~~~^~~~~~
exit status 1
Error compiling for board Arduino MKR WiFi 1010.
I tried to look over the errors but I cannot even get close to understanding where the error is being caused.
API_KEY:
- Project Overview (gear) -> Project Settings -> Web API KEY
USER_EMAIL:
- Build -> Authentication -> Add User -> Email
USER_PASSWORD:
- Build -> Authentication -> Add User -> Password
These are the steps I took toward the following parts of the code. I followed exactly what the README.md mentioned and got the values from there.
You have to update the library to latest version.
The version 1.0.7 or 1.0.8 has the compilation error issue, you have to update to v1.0.9.
I updated it and tried to compile it again. The same issue persists.
@mobizt I've tried to look over all of the errors but none of them make any sense. Were you able to find the root of this issue? Sorry if I'm bothering you too much.
You are welcome. The error related to the Arduino IDE compiler build options.
I fixed this issue already which you can update library to v1.0.10.
You can now download zip file and install library manually or you can wait the Library Manager to update.
I will try the new version of the library and let you know the progress. Thank you so much!
It works! Thank you so much! But I have one last thing I want to ask you.
Currently, the program is creating new names under the /humidity but I want it to update the value of humidity with the new values instead of creating new instances under the new variable under /humidity like this:
Is it possible to just update the value rather than create new names under that path?
If you are new to Firebase, you should learn the concept and its supported API, authentication and security from Firebase documentation or post your question in community forum for the Google Firebase technology and feature.
You also can try all examples which are ready to run to learn what you can do with Firebase Realtime database.
Asking such a basic question is not an effective way for you to learn and for me to support.
I read through the documentation and understood what I needed to do. I got it to function the way I wanted it to. But now, I am getting this error in my Serial Monitor: Error msg: operation was cancelled, code: -118
I don't recall this being mentioned anywhere.
The queue is full.
What will be happen to your device when plenty requests are stored in queue without limiting the amount?
If you don't understand the concept of async operation, use sync function instead.
@mobizt First thanks for creating this excellent library!
Regarding the error message Error msg: operation was cancelled, code: -118,
you mentioned queue was full. Which queue you were mentioning?
To control the flow rate, how do we qurery the queue, whether its full or empty, so we donot receive any error msg and our application would be error free.
@ankit-thealchemist
Please read the documentation thoroughly.
The queue was managed internally, and you can stop and clear it but you can't manage it because it is designed based on resource constraints and it is the task based instead of event/message based as in another library e.g. async MQTT and async web server.