I'm using NodeMCU and every couple of minutes I'm getting this issue: After troubleshooting, I find out that these functions are the reason but I don't why
void humidity() {
delay(2000);
float h = dht.readHumidity();
float t = dht.readTemperature();
Serial.print("Hum: ");
Serial.println(h);
Serial.print("Temp: ");
Serial.println(t);
if (isnan(h) || isnan(t)) {
Serial.println("Failed to read from DHT sensor!");
Firebase.setInt (link+"/HUMIDITY",0);
Firebase.setInt (link+"/TEMPERATURE",0);}
else{
Firebase.setInt (link+"/HUMIDITY",h);
Firebase.setInt (link+"/TEMPERATURE",t); }
valuefunc();
if(h>setvalue){pin();}
else {revpin();}
if(t>setvalue){pin();}
else{revpin();}
}
void ultrasonic(){
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
float distance= duration*0.034/2;
Serial.print("Distance: ");
Serial.println(distance);
Firebase.setInt (link+"/ULTRASONIC",distance);
valuefunc();
if(distance>setvalue){pin();}
else{revpin();}
}
void ir(){
if(digitalRead(irpin)==HIGH){Firebase.setString(link+"/IR","ON");Serial.println("IR: ON");}
else if(digitalRead(irpin)==LOW) {Firebase.setString(link+"/IR","OFF"); Serial.println("IR: OFF");}
setvalueir=Firebase.getString(link+"/VALUEIR");
Serial.print("VALUEIR: ");
Serial.println(setvalueir);
if(((setvalueir=="ON") && (digitalRead(irpin)==HIGH)) || ((setvalueir=="OFF") && (digitalRead(irpin)==LOW))){pin();}
if(((setvalueir=="ON") && (digitalRead(irpin)==LOW)) || ((setvalueir=="OFF") && (digitalRead(irpin)==HIGH))){revpin();}
}
void analog(){
float analog = analogRead(A0);
Serial.print("Analog Value:");
Serial.println(analog);
Firebase.setInt (link+"/LDR",analog);
valuefunc();
if(analog>setvalue){pin();}
else{revpin();}
delay(1000);
}
void analog1(){
float analog1 = analogRead(A0);
Serial.print("Analog 1:");
Serial.println(analog1);
Firebase.setInt (link+"/WATER",analog1);
valuefunc();
if(analog1>setvalue){pin();}
else{revpin();}
delay(1000);
}
void analog2(){
float analog2 = analogRead(A0);
Serial.print("Analog 2:");
Serial.println(analog2);
Firebase.setInt (link+"/SOIL",analog2);
valuefunc();
if(analog2>setvalue){pin();}
else{revpin();}
delay(1000);
}
void pin(){
Pin1=Firebase.getString(link+"/PIN1");
Pin2=Firebase.getString(link+"/PIN2");
if(Pin1=="HIGH"){digitalWrite(Digi1,HIGH);}
else{digitalWrite(Digi1,LOW);}
if(Pin2=="HIGH"){digitalWrite(Digi2,HIGH);}
else{digitalWrite(Digi2,LOW);}
}
void revpin(){
Pin1=Firebase.getString(link+"/PIN1");
Pin2=Firebase.getString(link+"/PIN2");
if(Pin1=="HIGH"){digitalWrite(Digi1,LOW);}
else{digitalWrite(Digi1,HIGH);}
if(Pin2=="HIGH"){digitalWrite(Digi2,LOW);}
else{digitalWrite(Digi2,HIGH);}
}
void valuefunc(){
setvalue=Firebase.getString(link+"/VALUE").toInt();
}
And the error in serial monitor is:
Exception (9):
epc1=0x4020f694 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000032d depc=0x00000000
Stack:
ctx: cont
sp: 3ffffa90 end: 3fffffc0 offset: 01a0
3ffffc30: 00000004 00000006 3fff0af0 402094b4
3ffffc40: 3ffffc90 3fffff10 3fff0af0 4020a380
3ffffc50: 3ffeeeb4 3fffff10 3ffffec0 40208cb0
3ffffc60: 3ffeeeb4 3ffffc90 3ffffc90 402073f0
3ffffc70: 00000002 3fffff10 3ffffec0 40207460
3ffffc80: 3ffeeeb4 3fffff10 3ffe8b63 40208b80
3ffffc90: 48474900 00002200 80000124 4020fc40
3ffffca0: 3fff3e7e 00000030 3ffffd88 4020b60e
3ffffcb0: 00000124 00000124 3fff0d94 00000000
3ffffcc0: 4025c4b4 00000020 3ffffd70 4020b60e
3ffffcd0: fcac040d d20e1039 8540be8b 3ffffd88
3ffffce0: 3fff12c1 4bc6a7f0 07ef9db2 00000000
3ffffcf0: 00000000 4bc6a7f0 4353f7ce 4020c84b
3ffffd00: 01860017 00000000 00000005 4020e73c
3ffffd10: 00000008 00000000 3fff0d94 4022991f
3ffffd20: 00000000 00000008 3ffffd70 4020b7c0
3ffffd30: 012aec65 4025c63c 3ffffd70 4020ba70
3ffffd40: 007a1200 3fcb2387 3ffffd00 00000001
3ffffd50: 3ffffda8 000002d8 000002d8 401007c8
3ffffd60: 000053c0 00000000 00000000 01000000
3ffffd70: 3ffffda8 00000001 3fff0d94 00000001
3ffffd80: 000000c8 40208314 00000020 40100a88
3ffffd90: 3fff12c1 00000001 3fff0d1c 4020e90b
3ffffda0: 00001610 000002c2 000002c2 4020c84b
3ffffdb0: 01860017 00000000 00000005 4020e73c
3ffffdc0: 000000c8 00000000 3fff0d94 4022991f
3ffffdd0: 3fff4c84 3fff0f64 00000001 40209e50
3ffffde0: 3fff0f00 000e000f 3ffffed0 4021892d
3ffffdf0: 007a1200 3fcb5f70 3fff0f00 402083c8
3ffffe00: 3ffffe58 00000000 00000001 40100198
3ffffe10: 000053c0 00000a78 00000a78 401007c8
3ffffe20: 3ffffe58 00000000 3fff0d94 3ffef1ec
3ffffe30: 3fffff20 3fffff40 00000020 40100a53
3ffffe40: 3fffff20 00000000 3fff0b64 4020b744
3ffffe50: 00000000 3ffe8b63 3ffffed0 4021892d
3ffffe60: 3ffe8b63 00000000 00000000 402083c8
3ffffe70: 00000000 3ffffedc 3fff0af0 402083ea
3ffffe80: 3fffff20 3fffff40 3fff0af0 40208406
3ffffe90: 3ffe8c00 3fffff40 3ffffed0 40208cb0
3ffffea0: 00000008 00000007 00000000 00000002
3ffffeb0: 3ffffc90 00000000 3fffff1c 8020bafc
3ffffec0: 4020fbd8 3fff0aec 00000000 3ffef090
3ffffed0: 3fff1108 4020fb98 3fffff1c 00000000
3ffffee0: 00000100 3ffef090 3fffff00 4020bd1e
3ffffef0: 80fe872b 3ffeee9c 3ffef070 4020b580
3fffff00: 80feee9c 3ffeee9c 3ffef070 40201540
3fffff10: 48474948 3fffff00 84ffff40 2f544f49
3fffff20: 324e4950 88000000 00000000 4020b580
3fffff30: 3fffdad0 3fffff40 00000000 40201a0b
3fffff40: 3fff0f00 000e000f 80fef0bc 4020afb8
3fffff50: 4024cf72 3ffef0bc 3ffeeed0 40201c66
3fffff60: 40240000 00000000 80001388 2f544f00
3fffff70: 534e4553 8000524f 00000005 40100311
3fffff80: 3fffdad0 00000000 3ffeeee8 4020488b
3fffff90: 3fffdad0 00000000 3ffef1ac 401001b9
3fffffa0: 3fffdad0 00000000 3ffef1ac 4020c90c
3fffffb0: feefeffe feefeffe 3ffe8560 40100d15
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
I was having the same problem, I resolved it by removing the delay when answering the request. previous code:
url = self.requestline
print(url)
messagetosend = bytes('on',"utf")
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Content-Length', len(messagetosend))
self.end_headers()
self.wfile.write(messagetosend)
time.sleep(5)
return
server_address_httpd = ('192.168.0.108',8080)
httpd = HTTPServer(server_address_httpd, RequestHandler_httpd)
print('server started')
httpd.serve_forever()'
code after removing delay with perfect request
from http.server import BaseHTTPRequestHandler, HTTPServer
import time
class RequestHandler_httpd(BaseHTTPRequestHandler):
def do_GET(self):
print('You got this http request')
url = self.requestline
print(url)
messagetosend = bytes('on',"utf")
self.send_response(200)
self.send_header('Content-Type', 'text/plain')
self.send_header('Content-Length', len(messagetosend))
self.end_headers()
self.wfile.write(messagetosend)
return
server_address_httpd = ('192.168.0.108',8080)
httpd = HTTPServer(server_address_httpd, RequestHandler_httpd)
print('server started')
httpd.serve_forever()
I tried to downgrade to 2.3.0 and it worked perfectly fine no more exception.
User contributions licensed under CC BY-SA 3.0