FirebaseExtended / firebase-arduino

Arduino samples for Firebase.
Apache License 2.0
943 stars 494 forks source link

Firebase Latest Fingerprint Updated. But NodeMCU gives an Exception. #481

Closed NilangiSithu closed 4 years ago

NilangiSithu commented 4 years ago

Hi,

I am trying to get parameters stored in Firebase as well as set parameters, in a Humidity/Temperature Controller using NodeMCU. Below I have mentioned the code.

Suddenly data was not uploading to Firebase by February 2020. Hence, I found that the latest fingerprint was 03:D6:42:23:03:D1:0C:06:73:F7:E2:BD:29:47:13:C3:22:71:37:1B via the website https://www.grc.com/fingerprints.htm and updated the Arduino Firebase library with that.

After changing the fingerprint, the data started uploading to Firebase.

But, the NodeMCU crashes automatically after sending data for a while.

The Serial Monitor displays an "Exception".

After decoding the exception, my understanding was that the issue was with the "Firebase.getInt" code parts. It works when put in "Void Setup", but results in an exception when it is placed in "Void Loop". I have been unable to fix the issue for more than a week now. Please help.

The code is:

include

include

include

define DHTPIN 4 //d2

define DHTTYPE DHT21

DHT dht(DHTPIN, DHTTYPE);

include

include

define ONE_WIRE_BUS 2 // DS18B20 on NodeMCU pin D4

OneWire oneWire(ONE_WIRE_BUS); DallasTemperature DS18B20(&oneWire);

define WIFI_SSID "Dialog 4G 142"//"Dialog 4G"

define WIFI_PASSWORD "2D8D37F1"//"FDL6552MG04"

define FIREBASE_HOST "slrs-iot.firebaseio.com"

define FIREBASE_AUTH "bwaDhgMWwLHpFiv4A1plexT02TUwzyHjajSyyDd5"

void setup() { dht.begin(); Serial.begin(115200); DS18B20.begin();

pinMode(D1, OUTPUT); digitalWrite(D1, LOW); pinMode(D7, OUTPUT); digitalWrite(D7, LOW); pinMode(D6, OUTPUT); digitalWrite(D6, LOW);

pinMode(0, OUTPUT); delay(1000); WiFi.begin(WIFI_SSID, WIFI_PASSWORD); //try to connect with wifi

while (WiFi.status() != WL_CONNECTED) { digitalWrite(0, digitalRead(0) ^ 1); delay(500); }

Serial.println(WiFi.localIP()); //print local IP address Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH); digitalWrite(0, 1); }

void loop() { DS18B20.requestTemperatures(); float t = DS18B20.getTempCByIndex(0); float h = dht.readHumidity();

Serial.print(t); Serial.print(","); Serial.println(h); if (isnan(h) || isnan(t)) { // Check if any reads failed and exit early (to try again). Serial.println(F("Failed to read from DHT sensor!")); return; }

Firebase.setFloat("/devices/lalan-d1/Status/Humidity", h); //setup path and send readings Firebase.setFloat("/devices/lalan-d1/Status/Temperature", t); //setup path and send readings

int ac_low = Firebase.getInt("/devices/lalan-d1/Parameters/AC_LOW"); int ac_high = Firebase.getInt("/devices/lalan-d1/Parameters/AC_HIGH"); int hum_low = Firebase.getInt("/devices/lalan-d1/Parameters/HUMIDIFIER_LOW"); int hum_high = Firebase.getInt("/devices/lalan-d1/Parameters/HUMIDIFIER_HIGH"); int dehum_low = Firebase.getInt("/devices/lalan-d1/Parameters/DEHUMIDIFIER_LOW"); int dehum_high = Firebase.getInt("/devices/lalan-d1/Parameters/DEHUMIDIFIER_HIGH"); int AC_S = Firebase.getInt("/devices/lalan-d1/Switch/AC"); int HUM_S = Firebase.getInt("/devices/lalan-d1/Switch/HUMIDIFIER"); int DEHUM_S = Firebase.getInt("/devices/lalan-d1/Switch/DEHUMIDIFIER");

if (h < hum_low ) { if (HUM_S == 1) { digitalWrite(D1, HIGH); Firebase.setFloat("/devices/lalan-d1/Status/humiditifier", 1); Serial.println("Firebase Set 1");

}
else {
  digitalWrite(D1, LOW);
  Firebase.setFloat("/devices/lalan-d1/Status/humiditifier", 0);
  Serial.println("Firebase Set 0");

}

} if (h > hum_high ) { digitalWrite(D1, LOW); Firebase.setFloat("/devices/lalan-d1/Status/humiditifier", 0); Serial.println("h > hum_high Firebase Set 0");

}

//*****

if (h > dehum_high) { if (DEHUM_S == 1) { digitalWrite(D6, HIGH); // Firebase.setFloat("/devices/lalan-d1/Status/dehumiditifier", 1);

}
else {
  digitalWrite(D6, LOW);
  Firebase.setFloat("/devices/lalan-d1/Status/dehumiditifier", 0);

}

} if (h < dehum_low) { digitalWrite(D6, LOW); Firebase.setFloat("/devices/lalan-d1/Status/dehumiditifier", 0);

}

//*****

if (t > ac_high) { if (AC_S == 1) { digitalWrite(D7, HIGH); Firebase.setFloat("/devices/lalan-d1/Status/ac", 1);

}
else {
  digitalWrite(D7, LOW);
  Firebase.setFloat("/devices/lalan-d1/Status/ac", 0);

}

} if (t < ac_low) { digitalWrite(D7, LOW); Firebase.setFloat("/devices/lalan-d1/Status/ac", 0);

}

delay(5000);

}

diipak-singh commented 4 years ago

same issue ,the NodeMCU crashes automatically after sending data for a while.

tinoschroeter commented 4 years ago

@NilangiSithu which esp8266 version you are using? try esp8266 community version: 2.5.2 this fix it for me

NilangiSithu commented 4 years ago

@tinoschroeter I was using ESP 8266 version 2.6.3. As you said, I removed it and installed version 2.5.2. and it started working! I have been testing it for about three hours now and did not get any errors yet. Thank you so much. It is working now.

NilangiSithu commented 4 years ago

same issue ,the NodeMCU crashes automatically after sending data for a while.

@diipak-singh Try ESP8266 Community Version 2.5.2 like tinoschroeter said.

diipak-singh commented 4 years ago

same issue ,the NodeMCU crashes automatically after sending data for a while.

@diipak-singh Try ESP8266 Community Version 2.5.2 like tinoschroeter said.

Thanks mate, it worked.