mobizt/Firebase-Arduino-WiFiNINA

Issue with WiFiNINA syntax with new Firebase library

Racsabo opened this issue · 1 comments

I was using some code that was used with an older version of Firebase_Arduino-WiFiNINA, when I went to verify the code I was met with "'WL_IDLE_STATUS' was not declared in this scope" error. Please see the code below (credit to Cytron Technologies, https://www.youtube.com/watch?v=xNOk2o4iKZM).

I went through some troubleshooting and found if I replace the <Firebase_Arduino_WiFiNINA.h> library with <WiFiNINA.h> and <SPI.h> libraries I have no error with the int status (of course then I do not have a firebase library and all the firebase functions error out).

Please let me know if there is a work around!

#include <Arduino_LSM6DS3.h>
#include <Firebase_Arduino_WiFiNINA.h>


char FIREBASE_HOST[] = "host.domain.example";
char FIREBASE_AUTH[] = "firebase.secret.code.example";
char WIFI_SSID[] = "wifi.ssid.example";
char WIFI_PASSWORD[] = "wifi.password.example";



FirebaseData firebaseData;


String path = "/IMU_LSM6DS3";
String jsonStr;

void setup()
{
  Serial.begin(9600);
  delay(1000);
  Serial.println();

  Serial.print("Initialize IMU sensor…");
  if (!IMU.begin()) {
    Serial.println(" failed!");
    while (1);
  }
  Serial.println(" done");
  Serial.print("Accelerometer sample rate = ");
  Serial.print(IMU.accelerationSampleRate());
  Serial.println(" Hz");
  int status = WL_IDLE_STATUS;
  Serial.print("Connecting to WiFi…");

  while (status != WL_CONNECTED) {
    status = WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
    Serial.print(".");
    delay(300);
  }
  Serial.print(" IP: ");
  Serial.println(WiFi.localIP());
  Serial.println();

  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, WIFI_SSID, WIFI_PASSWORD);
  Firebase.reconnectWiFi(true);
}

void loop()
{
  float x, y, z;

  // Read IMU acceleration data
  if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);

    // Send data to Firebase with specific path
    if (Firebase.setFloat(firebaseData, path + "/1-setFloat/X", x)) {
      Serial.println(firebaseData.dataPath() + " = " + x);
    }
    if (Firebase.setFloat(firebaseData, path + "/1-setFloat/Y", y)) {
      Serial.println(firebaseData.dataPath() + " = " + y);
    }
    if (Firebase.setFloat(firebaseData, path + "/1-setFloat/Z", z)) {
      Serial.println(firebaseData.dataPath() + " = " + z);
    }

    // Push data using pushJSON
    jsonStr = "{\"X\":" + String(x,6) + ",\"Y\":" + String(y,6) + ",\"Z\":" + String(z,6) + "}";

    if (Firebase.pushJSON(firebaseData, path + "/2-pushJSON", jsonStr)) {
      Serial.println(firebaseData.dataPath() + " = " + firebaseData.pushName());
    }
    else {
      Serial.println("Error: " + firebaseData.errorReason());
    }

    Serial.println();
    delay(2000);
  }
}
```

You can update library to v1.2.3 that supports double and big number unsigned long long and long long or just include the SPI.h and WiFiNINA.h before include the library.