Description
Hey everyone..
I'm getting this in serial monitor of arduino... please suggest some solutions, I'm unable to check my desired output.
Hardware
Hardware: ESP-12E
Settings in IDE
Module: Generic ESP8266 Module
Flash Size: 4MB
CPU Frequency: 80Mhz
Flash Frequency: 80Mhz
Upload Using: SERIAL
#include <ESP8266WiFi.h>
#include<Ticker.h>
#include<FirebaseArduino.h>
#define FIREBASE_HOST "mysmarthome-6d2a4.firebaseio.com" //Your Firebase Project URL goes here without "http:" , "" and "/"
#define FIREBASE_AUTH "LDDMjYXNFeDYThaDNku89iT8dNmM5tD7lGeZSDfO" //Your Firebase Database Secret goes here
#define WIFI_SSID "TDC" //your WiFi SSID for which yout NodeMCU connects
#define WIFI_PASSWORD "1357924680acebdf1111200000" //Password of your wifi network
Ticker secondTick;
volatile int watchdogcount=0;
int val1,val2,val3,val4;
void ISRwatchdog()
{
watchdogcount++;
if(watchdogcount ==5)
{
Serial.println();
Serial.println("watchdog bits...");
ESP.reset();
}
}
void setup()
{
Serial.begin(115200); // Select the same baud rate if you want to see the datas on Serial Monitor
secondTick.attach(1,ISRwatchdog);
WiFi.begin(WIFI_SSID,WIFI_PASSWORD);
Serial.print("connecting");
while (WiFi.status()!=WL_CONNECTED){
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("connected:");
Serial.println(WiFi.localIP());
Firebase.begin(FIREBASE_HOST,FIREBASE_AUTH);
Firebase.setInt("S1",0); //Here the varialbe"S1","S2","S3" and "S4" needs to be the one which is used in our Firebase and MIT App Inventor
Firebase.setInt("S2",0);
Firebase.setInt("S3",0);
Firebase.setInt("S4",0);
}
void firebasereconnect()
{
Serial.println("Trying to reconnect");
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
}
void loop()
{
while(WiFi.status()!= WL_CONNECTED)
{
watchdogcount=0;
delay(1000);
}
if (Firebase.failed())
{
Serial.print("setting number failed:");
Serial.println(Firebase.error());
firebasereconnect();
return;
}
val1=Firebase.getString("S1").toInt(); //Reading the value of the varialble Status from the firebase
if(val1==1) // If, the Status is 1, turn on the Relay1
{
Serial.println("light 1 ON");
}
else if(val1==0) // If, the Status is 0, turn Off the Relay1
{
Serial.println("light 1 OFF");
}
val2=Firebase.getString("S2").toInt(); //Reading the value of the varialble Status from the firebase
if(val2==1) // If, the Status is 1, turn on the Relay2
{
Serial.println("light 2 ON");
}
else if(val2==0) // If, the Status is 0, turn Off the Relay2
{
Serial.println("light 2 OFF");
}
val3=Firebase.getString("S3").toInt(); //Reading the value of the varialble Status from the firebase
if(val3==1) // If, the Status is 1, turn on the Relay3
{
Serial.println("light 3 ON");
}
else if(val3==0) // If, the Status is 0, turn Off the Relay3
{
Serial.println("light 3 OFF");
}
val4=Firebase.getString("S4").toInt(); //Reading the value of the varialble Status from the firebase
if(val4==1) // If, the Status is 1, turn on the Relay4
{
Serial.println("light 4 ON");
}
else if(val4==0) // If, the Status is 0, turn Off the Relay4
{
Serial.println("light 4 OFF");
}
}