I'm using arduino ide 1.8.2
board Nodemcu 1.0
board manager url: http://arduino.esp8266.com/stable/packa ... index.json
The circuit has a single sensor and my code to detect sensor change is written in an interupt. Time interval between interupts is recorded and sent to thingspeak.
The issue is that although the functionality is sound, after a day or two, The serial monitor stops reporting intervals, this is reflected in the thingspeak channel. The sensor has an oboard led which indicate changes are still being detected. No errors are seen on the serial monitor. Pressing the reset button gets it going again, for a day or two then it silently fails again.
I've tried lookin at FreeHeap which is fine, and Serial.printf to see where it stops without any solid info as to what's going in.
\here's a portion of mr code with the interupt routine and setup
void isr()
{
float pulselength;
float now = micros();
pulseNow = now;
if ( (pulseNow - pulseThen) > resolution ) //drop the very first pulse as uncertain length
{
Serial.print("interrupt start ..");
Serial.println(tn++);
++numPulses;
Serial.println("Pulse detected ");
Serial.print(" ");
pulselength = (pulseNow - pulseThen) /1000000;
keeppulse += pulselength;
Serial.print("pulselength..");
Serial.print(pulselength);
Serial.print(" keeppulse..");
Serial.print(keeppulse);
Serial.print(" numPulses ");
Serial.println(numPulses);
pulseThen = pulseNow;
Serial.printf("interupt heap size: %u\n", ESP.getFreeHeap());
Serial.println("interrupt end ..");
}
}
void setup() {
// put your setup code here, to run once:
struct wifisettings::settings pete;
pinMode(LED_PIN, OUTPUT);
Serial.begin(115200);
Serial.println();
wifisettings::set_wizsetting(&wiz);
wifimanager::doWifiManagerSetup(&wiz);
wifisettings::get_wizsetting(&wiz);
// display.display();
delay(4000);
// display.clearDisplay();
Serial.println("interval counter v9.2\n");
pinMode(2, OUTPUT); //probe output on pin D4
attachInterrupt(0, isr, RISING); // define interrupt 0
numPulses = 0;
keeppulse = 0;
if (drd.detectDoubleReset()) {
Serial.println("Double Reset Detected");
doConfig();
} else {
Serial.println("No Double Reset Detected");
}
Serial.printf("Setup heap size: %u\n", ESP.getFreeHeap());
}