I have built a nice Webserver on the ESP8266-07,
on Arduino IDE 1.69 build 20.4.16:8:33, to control 4 water valves.
The ESP8266WebServer is running since 8 days, with no crash,
and no Wifi reconnection, very well.
In addition to the water valves, the flow rate should be detected,
by an Watersensor 60L/min = 240 pulse / min,
connected to GPIO14, read via Interrupt.
With water sensor is connected, I have observed the following:
Up to Water-puls below 50, all works fine. The system reports all data and all work fine.
At more than 50 water-puls, the ESP did not recorded every puls,
So when the number of puls gets higher, the ESP did not count pulses anymore.
(the 50 puls is here for example)
Here as example, at my Water-Ssytem, when the counting stops:
(Connected to the Generator, 78 puls / sec)
Heap: 38000
Boot Vers: 4
CPU: 80
SDK: 1.5.2(7eee54f4)
Chip ID: 1191149
Flash ID: 1327328
MakeHtmlPage duration = 11286, FreeHeap = 28864
WaterSensor pulseCount:84 Milis:19319
WaterSensor pulseCount:79 Milis:20322
WaterSensor pulseCount:78 Milis:21325
WaterSensor pulseCount:78 Milis:22328
WaterSensor pulseCount:78 Milis:23331
WaterSensor pulseCount:84 Milis:24414
WaterSensor pulseCount:79 Milis:25417
WaterSensor pulseCount:80 Milis:26444
WaterSensor pulseCount:36 Milis:27447
WaterSensor pulseCount:13 Milis:28533
WaterSensor pulseCount:9 Milis:29536
WaterSensor pulseCount:0 Milis:30563
WaterSensor pulseCount:0 Milis:31566
WaterSensor pulseCount:0 Milis:32653
To reproduce this, I have built an second ESP8266-07 as Puls generator and on the same device counting the puls via GPIO14 by interrupt, reporting to Serial, and all works fine, up to 240 puls / sec.
Connecting these Puls-generator to my Water-Webserver-ESP, it crashes immediately,
When he saw the 240 puls/ sec. Below 50 it works.
So I take the AdvancedWebserver example out of the ESP8266Wifi.zip
Newest Version, and added the follwing few lines:
// declare the value
volatile unsigned long G_pulseCount; // counted per Interrupt
// ISR
void pulseCounter()
{
G_pulseCount++; // Increment the pulse counter
}
// at the end of setup
G_pulseCount = 0;
attachInterrupt(14, pulseCounter, FALLING);
// at handleRoot() added the Puls Count line
<body>\
<h1>Hello from ESP8266!</h1>\
<p>Uptime: %02d:%02d:%02d</p>\
<p>PulsCount: %02d</p>\
<img src=\"/test.svg\" />\
</body>\
// and added the puls value to be displayed
hr, min % 60, sec % 60, G_pulseCount
Now I noticed that it works,
All puls where counted, and displayed.
I added at the LOOP an delay(2)
To simulate some other functions like calculating or Blinking some led,
to give the system more stress
void loop ( void ) {
server.handleClient();
delay(2);
}
And now the system crashes, sometimes in a few minutes, sometimes very fast.
It seams for me, the ESPWebserver consumes to much system time, to serve the IO-Interrupt,
So he counts not all or no more puls when the puls came to fast.
Some times when the ESP did not count the pulse, which are coming from the Generator very constant, 240Puls/sec.
The puls counting can be restart, by refreshing the website, for an short time, but it stops again or the system crashes with an exception like
wifi evt: 0
....wifi evt: 3
.
Connected to Spandau5
IP address: 192.168.111.43
MDNS responder started
HTTP server started
pm open,type:2 0
Fatal exception 0(IllegalInstructionCause):
epc1=0x40201f1c, epc2=0x00000000, epc3=0x00000000, excvaddr=0x00000000, depc=0x00000000
Exception (0):
epc1=0x40201f1c epc2=0x00000000 epc3=0x00000000 excvaddr=0x00000000 depc=0x00000000
ctx: sys
sp: 3ffffc30 end: 3fffffb0 offset: 01a0
>>>stack>>>
3ffffdd0: 40106bc8 3fff0334 3fff0334 fffffffe
3ffffde0: ffffffff 00000020 00000001 00000000
3ffffdf0: 00000000 401011b3 00000000 00000022
3ffffe00: 3fffc200 40106b90 3fffc258 4000050c
3ffffe10: 40004378 00000030 00000016 ffffffff
3ffffe20: 60000200 00000008 00000000 80000000
3ffffe30: 20000000 3fff2120 80000000 203fc040
3ffffe40: 80000000 3fffc6fc 3fff0334 3fff2124
3ffffe50: 000002b4 003fc040 60000600 00000030
3ffffe60: 3fffc200 40106b90 3fffc258 4000050c
3ffffe70: 40106c2c 00000030 0000001b ffffffff
3ffffe80: ffffffff 00000020 00000000 00000000
3ffffe90: 00000000 00000000 0000001f 401052f9
3ffffea0: 4000050c 40106b90 3fffc258 4000050c
3ffffeb0: 40000f68 00000030 00000016 ffffffff
3ffffec0: 40000f58 00000000 00000020 00000000
3ffffed0: feefeffe 3fff0334 3fff0334 fffffffe
3ffffee0: ffffffff 3ffeebd8 3fff0334 3fffdab0
3ffffef0: 00000000 3fffdad0 3fff0420 00000030
3fffff00: 00000000 400042db 3ffe9b51 60000600
3fffff10: 40004b31 3fff20e4 000002f4 003fc000
3fffff20: 401056e2 3ffeec00 3ffedca0 40106dc8
3fffff30: 4020bb99 3ffedca0 3ffeec00 0530a5fd
3fffff40: 3fff20e4 00001000 4020c02e 00000008
3fffff50: 00000000 00000000 4020c0db 3ffedd54
3fffff60: 3ffeec00 00520baf 3ffeebd8 40201018
3fffff70: 4021d7ad 3ffedd54 3ffeec00 0530a4d0
3fffff80: 4021d7f2 3fffdab0 00000000 3fffdcb0
3fffff90: 3ffeec10 3fffdad0 3fff0420 402071db
3fffffa0: 40000f49 00009b7b 3fffdab0 40000f49
<<<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
Can any body help here?
What is the reason on ESP8266Webserver and Interrupts usage?
I will be glad to get some Help.
Thanks
Mickbaer from Berlin Germany