".0
.0
.0
WiFi connected
Device ID - 84:F3:EB:AF:56:51
Try to connect
Try to connect
Exception (29):
epc1=0x4000e1b2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: cont
sp: 3fff11c0 end: 3fff1650 offset: 01a0
>>stack>>>
3fff1360: 01000100 00ff0000 ff000000 40203d54
3fff1370: 3fff71a4 3fff301c 3fff79fc 40222fb6
3fff1380: 00000001 3fff79e0 3fff2fc4 00000000
3fff1390: 3fff301c 3fff972c 3fff696c 402246ef
3fff13a0: 00000000 3fff2fc4 3fff972c 401004d8
3fff13b0: 40203448 00000708 3fff0630 3fff049c
3fff13c0: 3fff972c 3fff2fc4 3fff696c 40203a9a
3fff13d0: 000001bb 3fff78cc 3fff2fc4 40202ec6
3fff13e0: 5561c923 00000000 3fff1420 3fff51d8
3fff13f0: 000001bb 3fff2fc4 3fff972c 40203e2d
3fff1400: 3ffe98a0 5561c923 3ffe98a0 5561c923
3fff1410: 3fff8f3c 00000000 3fff8f44 402066d0
3fff1420: 00000000 00000252 00000252 40208088
3fff1430: fffffffd 00000001 3fff8f44 40206ea0
3fff1440: 3ffe947c 00000052 3ffe91bf 402047cb
3fff1450: 3fff3204 3fff14c0 3fff8f3c 40204824
3fff1460: 3fff3210 00000000 00000000 3ffe91bc
3fff1470: 3fff8f3c 3fff14a0 3ffe91bc 3ffe91bc
3fff1480: 3fff8f3c 3fff0504 3fff1560 402057ee
3fff1490: 3fff04e4 3fff0504 3fff1560 40204209
3fff14a0: 3fff3210 3fff1584 3fff8dc4 40224440
3fff14b0: 3fff0504 3fff0504 3fff0504 3fff1600
3fff14c0: 3fff71e8 3fff1584 3fff1584 00000001
3fff14d0: 00000000 3fff159c 3fff1570 3fff04e0
3fff14e0: 3fff1598 00000000 402057d8 40208088
3fff14f0: 3fff1534 3fff15df 3ffe90b8 3fff159c
3fff1500: 3fff1598 3fff1520 3fff1560 402045a3
3fff1510: 3fff1520 00000000 3fff1560 402054df
3fff1520: 3fff8f3c 3fff718c 3fff1584 3fff1600
3fff1530: 3fff04e0 3fff04e4 3fff67cc 4020480c
3fff1540: 3fff15a0 3ffe8f54 3fff15d0 3fff1600
3fff1550: 3fff1590 3fff1584 3fff04e0 402055b4
3fff1560: 3ffe9270 3fff8f3c 3fff718c 00000000
3fff1570: 3fff0504 3fff0504 00000000 00000000
3fff1580: 00000014 3fff67cc 0000000f 00000001
3fff1590: 3fff8f3c 3fff718c 3fff51d8 3fff6920
3fff15a0: 00000020 3fff1600 3fff1600 402076d4
3fff15b0: 3fff15e0 00000001 3fff1600 402079bd
3fff15c0: 00000056 00000051 3fff1600 3ffe8f54
3fff15d0: 3fff04e0 3fff0480 3fff05f4 40205618
3fff15e0: 00000004 00000001 3fff1600 40207ab5
3fff15f0: 3fff04e0 3fff0480 3fff05f4 402023a2
3fff1600: 3fff2f9c 0000001f 0000001e 3fff51a4
3fff1610: 0000001f 00000011 feefeffe feefeffe
3fff1620: feefeffe feefeffe feefeffe 3fff0620
3fff1630: 3fffdad0 00000000 3fff0619 402082d0
3fff1640: feefeffe feefeffe 3fff0630 40100718
<<<stack<<<
ets Jan 8 2013,rst cause:2, boot mode:(1,6)
ets Jan 8 2013,rst cause:4, boot mode:(1,6)
wdt reset"
My nodemcu Sketch Code
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <time.h>
#include <FirebaseArduino.h>
#define PIN_LED 16 // D0
#define PIN_OUT 5 //D1 - connect to Relay
#define PIN_BUTTON 0 //D3 - for smart configure
#define STANDART_DELAY 200
#define MIN_TIME_FOR_SEND 200
#define LED_ON() digitalWrite(PIN_LED, HIGH)
#define LED_OFF() digitalWrite(PIN_LED, LOW)
#define LED_TOGGLE() digitalWrite(PIN_LED, digitalRead(PIN_LED) ^ 0x01)
//Defile Firebase
#define FIREBASE_HOST "myfirebase.host" // here i am enter my host details
#define FIREBASE_AUTH "my secret key" // here i am enter my firebase key
int current_on;
int current_off;
Ticker ticker;
void tick()
{
//toggle state
int state = digitalRead(PIN_LED); // get the current state of GPIO1 pin
digitalWrite(PIN_LED, !state); // set pin to the opposite state
}
bool in_smartconfig = false;
void enter_smartconfig()
{
if (in_smartconfig == false) {
in_smartconfig = true;
ticker.attach(0.1, tick);
WiFi.beginSmartConfig();
}
}
bool longPress()
{
static int lastPress = 0;
if (millis() - lastPress > 3000 && digitalRead(PIN_BUTTON) == 0) {
return true;
} else if (digitalRead(PIN_BUTTON) == 1) {
lastPress = millis();
}
return false;
}
void exit_smart()
{
ticker.detach();
LED_ON();
in_smartconfig = false;
}
void setup() {
delay(1000);
Serial.begin(115200);
pinMode(16, OUTPUT);
pinMode(PIN_OUT, OUTPUT);
WiFi.mode(WIFI_AP_STA);
delay(500);
WiFi.beginSmartConfig();
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
Serial.println(WiFi.smartConfigDone());
}
Serial.println("");
Serial.println("WiFi connected");
Serial.print("\nDevice ID - "+WiFi.macAddress()+"\n");
do{
Firebase.begin(FIREBASE_HOST, FIREBASE_AUTH);
Firebase.setInt(("device"+WiFi.macAddress()+"/online"), 1);
Firebase.setInt(("device"+WiFi.macAddress()+"/running"), 0);
Serial.println("Try to connect");
delay(500);
} while (Firebase.failed());
Serial.println("Device online");
}
String url = "/device" + WiFi.macAddress();
void loop() {
// Check Smart Config:
if (longPress()) {
enter_smartconfig();
Serial.println("Enter smartconfig");
}
//Runing:
//0 - Waiting
//1 - Turn on
//2 - Turn Off
//3 - Repeat
//4 - ........
//Check Event----------------------------------------------
if (WiFi.status() == WL_CONNECTED)
{
exit_smart();
switch (Firebase.getInt(url+"/running"))
{
case 0: // do nothing waiting
break;
case 1: // Turn On
Serial.print("Turn On\n");
digitalWrite(PIN_OUT,HIGH);
Firebase.setInt(("device"+WiFi.macAddress()+"/state"), 1);
Firebase.setInt(("device"+WiFi.macAddress()+"/running"), 0);
current_on = Firebase.getInt("device"+WiFi.macAddress()+"/turnon");
current_on= current_on+1;
Firebase.setInt(("device"+WiFi.macAddress()+"/turnon"), current_on);
break;
case 2: // Turn Off
Serial.print("Turn Off\n");
digitalWrite(PIN_OUT,LOW);
Firebase.setInt(("device"+WiFi.macAddress()+"/state"), 0);
Firebase.setInt(("device"+WiFi.macAddress()+"/running"), 0);
current_off = Firebase.getInt("device"+WiFi.macAddress()+"/turnoff");
current_off= current_off+1;
Firebase.setInt(("device"+WiFi.macAddress()+"/turnoff"), current_off);
break;
case 3: // Repeat
Serial.println("Repeat");
int timer;
int repeat;
timer = Firebase.getInt("device"+WiFi.macAddress()+"/timer");
repeat = Firebase.getInt("device"+WiFi.macAddress()+"/repeat");
if(timer == -1){
timer = STANDART_DELAY;
}
Serial.println("Timer: "+ timer);
if(timer >= MIN_TIME_FOR_SEND){
for (int i = 0; i < repeat; i++){
//Repeat On ----------------------------
uint32_t prSendTime = millis();
Firebase.setInt(("device"+WiFi.macAddress()+"/state"), 1);
digitalWrite(PIN_OUT,HIGH);
Serial.print("Repeat_Turn ON\n");
int send_time;
send_time = millis() - prSendTime;
if(send_time < timer){
delay(timer-send_time);
Serial.println(timer-send_time);
}
//Repeat Off---------------------------
prSendTime = millis();
Firebase.setInt(("device"+WiFi.macAddress()+"/state"), 0);
digitalWrite(PIN_OUT,LOW);
Serial.print("Repeat_Turn OFF\n");
send_time = millis() - prSendTime;
if(send_time < timer){
delay(timer-send_time);
Serial.println(timer-send_time);
}
}
}
else {
for (int i = 0; i < repeat; i++){
digitalWrite(PIN_OUT,HIGH);
delay(timer);
digitalWrite(PIN_OUT,LOW);
delay(timer);
}
}
Firebase.setInt(("device"+WiFi.macAddress()+"/running"), 0);
current_on = Firebase.getInt("device"+WiFi.macAddress()+"/turnon");
current_on= current_on+repeat;
current_off = Firebase.getInt("device"+WiFi.macAddress()+"/turnoff");
current_off= current_off+repeat;
Firebase.setInt(("device"+WiFi.macAddress()+"/turnoff"), current_off);
Firebase.setInt(("device"+WiFi.macAddress()+"/turnon"), current_on);
break;
case 4://Check online state
Serial.print("Checking online:\n");
Firebase.setInt(("device"+WiFi.macAddress()+"/online"), 1);
Firebase.setInt(("device"+WiFi.macAddress()+"/running"), 0);
Serial.print("-->Device online:\n");
break;
}
//Check Firebase -----------------------------------------------
Serial.println(Firebase.getInt(url+"/running"));
if (Firebase.success()){
Serial.print("setting /number success:");
Serial.print(Firebase.error());
}
if (Firebase.failed())
{
Serial.print("setting /number failed:");
Serial.print(Firebase.error());
return;
}
delay(10);
}
}
Please tell me how to solve this issues