Problem with WiFiNINA and Firebase

Hey, guys,

I have an Arduino uno Wifi rev 2.

I have such a problem, I am using a BME280 sensor which records some values (temperature, humudity, air pressure) and I am also using wifi to send this data to Firebase database. Everything works more or less fine, the data are updated in the database except for some moments when the data is not sent to the database and the message "Error: connection lost" appears on the serial monitor or it happens that only one of the original 3 values is sent.

This happens terribly irregularly, out of some 10 sends it happens maybe 2x. I've tried connecting to 2 different wifins, I've also tried it on mobile data. Both with the same result.

I have also updated the WifiNINA firmware, currently I have version 1.5.0.

I can't think of anything else to try, please if you can think of anything let me know, I would be grateful for any advice. Thank you

#include <SPI.h>
#include <WiFiNINA.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <Firebase_Arduino_WiFiNINA.h>

//Values for connection
#define FIREBASE_HOST "*******"
#define FIREBASE_AUTH "*******"
#define WIFI_SSID "*****"
#define WIFI_PASSWORD "*****"

//Firebase
FirebaseData firebaseData;
String path = "/IMU_LSM6DS3";
String jsonStr;

//BME280 inicialization
Adafruit_BME280 bme; // I2C

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

//Wifi connection
  Serial.print("Connecting to WiFi...");
  int status = WL_IDLE_STATUS;
  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 inicialization
  Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH, WIFI_SSID, WIFI_PASSWORD);
  Firebase.reconnectWiFi(true);

  //BME280 setup
unsigned bme_status;
bme_status = bme.begin(0x76);  
    if (!bme_status) {
        Serial.println("There is the problem with BME280 sensor.");
    }else{
        Serial.println("BME280 sensor is working.");
    }
}

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

//read data and save them 
 x = bme.readTemperature();
 y=  bme.readHumidity();
 z=  bme.readPressure();

    // 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(3000);
}

Hi, I am not of much help as I have almost the same issues.
Did you ever see a refused connection error? how did you solve it

Hi, I have the same problem ( connection refused ) , is there any updates about how to fix it? Thank you

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.