homie-esp8266: Getting Infinite loop with compiled code...can you pls help?

Hi Guys, I’m new here so please dont shoot my head off if I’ve accidentally broken a rule while posting. So i’m new to the homie framework, i’ve successfully compiled code for my door sensor alone but now i want to use additional sensors for my wemos d1 mini. There are obviously a bunch of smart folks on this site and I wanted to seek some assistance.

I compiled the code but its going into an iterative loop in the serial monitor. can someone please spot where i may have gone wrong? Much appreciated in advance

`

#include <Homie.h>
#include <ArduinoJson.h>


const int PIN_DOOR = D1;
const int PIN_WATER = D3;

bool sleepFlag = false;

Bounce debouncer = Bounce(); // Bounce is     built into Homie, so you can use it without including it first
int lastDoorValue = -1;
int lastWaterValue = -1;

HomieNode doorNode("door", "door");
HomieNode waterNode("water", "water");


void loopHandler() {
  int doorValue = debouncer.read();
  int waterValue = debouncer.read();

  if (doorValue != lastDoorValue) {
      Homie.getLogger() << "Door is now " << (doorValue ? "open" : "closed") << endl;

    doorNode.setProperty("open").send(doorValue ? "true" : "false");
     lastDoorValue = doorValue;
  }
   if (waterValue != lastWaterValue) {
     Homie.getLogger() << "Water sensor state is " << (waterValue ? "Leak Detected" : "clear") << endl;

     waterNode.setProperty("clear").send(waterValue ? "true" : "false");
 lastWaterValue = waterValue;
  }
}

void onHomieEvent(const HomieEvent& event) {
   switch(event.type) {
     case HomieEventType::MQTT_READY:
       Homie.getLogger() << "MQTT connected, preparing for deep sleep..." << endl;
      Homie.prepareToSleep();
      break;
     case HomieEventType::READY_TO_SLEEP:
      Homie.getLogger() << "Ready to sleep" << endl;
      ESP.deepSleep(0);
      break;
  }
}

void setup() {
  Serial.begin(115200);
  Serial << endl << endl;
  Homie.disableResetTrigger();  // we do not want to trigger config mode by sensor input
  pinMode(PIN_DOOR, INPUT);
 pinMode(PIN_WATER, INPUT);
  digitalWrite(PIN_DOOR, HIGH);
  digitalWrite(PIN_WATER, HIGH);
  debouncer.attach(PIN_DOOR);
  debouncer.attach(PIN_WATER);
  debouncer.interval(50);

  Homie_setFirmware("my-sensors", "1.0.0");
  Homie.setLoopFunction(loopHandler);
  Homie.onEvent(onHomieEvent);

  doorNode.advertise("open");
  waterNode.advertise("clear");

 Homie.setup();
}

 void loop() {

  Homie.loop();
  debouncer.update();

}

`

this is the error loop ` Offline message acknowledged. Di✔ Wi-Fi connected, IP: 192.168.1.151 Triggering WIFI_CONNECTED event… ↕ Attempting to connect to MQTT… Sending initial information… ✔ MQTT ready Triggering MQTT_READY event… MQTT connected, preparing for deep sleep… Flagged for sleep by sketch Calling setup function… Device in preparation to sleep… 〽 Sending statistics… • Wi-Fi signal quality: 100% • Uptime: 2s Door is now open Water sensor state is Leak Detected Offline message acknowledged. Disconnecting MQTT… ✖ MQTT disconnected Triggering MQTT_DISCONNECTED event… Triggering READY_TO_SLEEP event… Ready to sleep

Exception (28): epc1=0x4022c5c2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000004c depc=0x00000000

ctx: sys sp: 3ffffbd0 end: 3fffffb0 offset: 01a0

stack>>> 3ffffd70: 00000002 00000000 3ffefea8 40214482
3ffffd80: 3ffffdb0 00000000 0000033d 40214551
3ffffd90: 3fff0108 00000001 3ffefea8 402145d0
3ffffda0: 3fff0108 00000000 3ffefea8 3fff37ac
3ffffdb0: 3fff0108 3ffef9d8 3ffefea8 40214205
3ffffdc0: 3fff305c 3ffef9d8 3ffefea8 40212249
3ffffdd0: 3fff0108 3ffef9d8 3ffefbe4 4020f31a
3ffffde0: 3fff305c 00000017 3fff304c 40220a3a
3ffffdf0: 3fff04e4 00000017 3fff304c 402129cb
3ffffe00: 3fff3772 00000031 3ffefea8 40212a49
3ffffe10: 3fff3364 3ffffe60 4020de6c 40220a18
3ffffe20: 3fff3772 00000031 3ffefea8 40220c66
3ffffe30: 00007fff 00000031 3ffefea8 402138b4
3ffffe40: 3ffea97c 00000031 3ffefea8 4021291d
3ffffe50: 3fff3364 0025def1 40211b2c 40220c44
3ffffe60: 40212a1c 00000000 3ffefea8 00000001
3ffffe70: 00000021 00004288 00000000 00000002
3ffffe80: 3fff0029 3fff37ac 00002200 4000050c
3ffffe90: 3fffc278 40101f8c 3fffc200 00000000
3ffffea0: 3ffefea8 3fff372c 00000000 40212950
3ffffeb0: 4000001b 00000030 3fff18b4 40214650
3ffffec0: 3fff3684 00000001 00000000 3fffd9d0
3ffffed0: 00000000 00000000 00000000 3fff18d4
3ffffee0: 3fff3684 3fff18b8 3fff18b4 40214694
3ffffef0: 3fff3684 3fff18b8 3fff18b9 4022b034
3fffff00: dd01a8c0 0000000a 3ffe9d1c 00000000
3fffff10: 00000000 00000067 3fffff80 3fff374a
3fffff20: 3fff1a2c 3fff372c 3fff1b14 4022ef59
3fffff30: 00000014 00000306 00000306 3fff1a2c
3fffff40: 3fffdc80 3fff1fd4 3fff3364 3fff201c
3fffff50: 00000008 3fff1a2c 3fff372c 402285b9
3fffff60: 3fffdc80 3fff1fd4 3fff3364 4010453c
3fffff70: 40245b5e 3fff1fd4 3fff3364 40245b70
3fffff80: 3fff373c 3fff372c 00000000 3fff05f0
3fffff90: 40240a43 00000000 3fff3364 40247acf
3fffffa0: 40000f49 3fffdab0 3fffdab0 40000f49
<<<stack<<<

ets Jan 8 2013,rst cause:2, boot mode:(3,2)

load 0x4010f000, len 1384, room 16 tail 8 chksum 0x2d csum 0x2d v614f7c32 ~ld ^H⸮H⸮💡 Firmware my-sensors (1.0.0) 🔌 Booting into normal mode 🔌 {} Stored configuration • Hardware device ID: b4e62d1b5e99 • Device ID: basement-sensors • Name: Basement Sensors • Device Stats Interval: 60 sec • Wi-Fi: ◦ SSID: mynet ◦ Password not shown • MQTT: ◦ Host: 192.168.1.200 ◦ Port: 1883 ◦ Base topic: homie/ ◦ Auth? yes ◦ Username: not shown ◦ Password not shown • OTA: ◦ Enabled? yes ↕ Attempting to connect to Wi-Fi… ✔ Wi-Fi connected, IP: 192.168.1.151 Triggering WIFI_CONNECTED event… ↕ Attempting to connect to MQTT… Sending initial information… ✔ MQTT ready Triggering MQTT_READY event… MQTT connected, preparing for deep sleep… Flagged for sleep by sketch Calling setup function… Device in preparation to sleep… 〽 Sending statistics… • Wi-Fi signal quality: 100% • Uptime: 2s Door is now open Water sensor state is Leak Detected Offline message acknowledged. Disconnecting MQTT… ✖ MQTT disconnected Triggering MQTT_DISCONNECTED event… Triggering READY_TO_SLEEP event… Ready to sleep

Exception (28): epc1=0x4022c5c2 epc2=0x00000000 epc3=0x00000000 excvaddr=0x0000004c depc=0x00000000

ctx: sys sp: 3ffffbd0 end: 3fffffb0 offset: 01a0

stack>>> 3ffffd70: 00000002 00000000 3ffefea8 40214482
3ffffd80: 3ffffdb0 00000000 00000307 40214551
3ffffd90: 3fff0108 00000001 3ffefea8 402145d0
3ffffda0: 3fff0108 00000000 3ffefea8 3fff334c
3ffffdb0: 3fff0108 3ffef9d8 3ffefea8 40214205
3ffffdc0: 3fff319c 3ffef9d8 3ffefea8 40212249
3ffffdd0: 3fff0108 3ffef9d8 3ffefbe4 4020f31a
3ffffde0: 3fff319c 00000017 3fff318c 40220a3a
3ffffdf0: 3fff04e4 00000017 3fff318c 402129cb
3ffffe00: 3fff3772 00000031 3ffefea8 40212a49
3ffffe10: 3fff306c 3ffffe60 4020de6c 40220a18
3ffffe20: 3fff3772 00000031 3ffefea8 40220c66
3ffffe30: 0025b585 00000031 3ffefea8 402138b4
3ffffe40: 3ffea970 00000031 3ffefea8 4021291d
3ffffe50: 3fff306c 00000000 40211b2c 40220c44
3ffffe60: 40212a1c 00000000 3ffefea8 3fffc278
3ffffe70: 00000021 3fffc200 00000022 3ffea97c
3ffffe80: 3fff0029 3fff334c 00000000 401006fa
3ffffe90: 00000030 00000014 ffffffff 00000000
3ffffea0: 3ffefea8 3fff372c 00000000 40212950
3ffffeb0: 0000001b 00000000 3fff18b4 40214650
3ffffec0: 3fff3684 00000001 3fff05f0 00000000
3ffffed0: 3fffdad0 3fff05e0 00000030 3fff18d4
3ffffee0: 3fff3684 3fff18b8 3fff18b4 40214694
3ffffef0: 3fff3684 3fff18b8 3fff18b9 4022b034
3fffff00: dd01a8c0 0000000a 3ffe9d1c 00000000
3fffff10: 00000000 00000067 3fffff80 3fff374a
3fffff20: 3fff1a2c 3fff372c 3fff1b14 4022ef59
3fffff30: 00000014 00000343 00000343 3fff1a2c
3fffff40: 3fffdc80 3fff1fd4 3fff354c 3fff202c
3fffff50: 00000008 3fff1a2c 3fff372c 402285b9
3fffff60: 3fffdc80 3fff1fd4 3fff354c 4010453c
3fffff70: 40245b5e 3fff1fd4 3fff354c 40245b70
3fffff80: 3fff373c 3fff372c 00000000 3fff05f0
3fffff90: 40240a43 00000000 3fff354c 40247acf
3fffffa0: 40000f49 3fffdab0 3fffdab0 40000f49
<<<stack<<< `

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Comments: 38 (7 by maintainers)

Most upvoted comments

I have also been fighting with this problem. My solution was to revert to 0.8.1 of AsyncMqtt: https://github.com/marvinroger/async-mqtt-client/releases/tag/v0.8.1 (remember to build clean and rebuild everything)