[SOLVED] Soft WDT Reset on MQTT ESP8266 GW with NRF24L01+
-
I'm trying to replicate a gateway with the same hardware of four others that are already running, but I can't figure out why I'm hitting my head against a "SOFT WDT RESET" cycle that appears to be related to the use of NRF24L01+ radio.
I did all the "basic" troubleshooting before writing this:
- changed ESP8266 board (ordered 8 different models, from different producers and sellers)
- changed NRF24L01+ module (ordered 6 items from different producers and sellers)
- changed dupoint wires multiple times
- changed power source (USB, Bench, Wall Charger, Battery)
- changed library versions, both for MySensors and for BME280
Setup is as follows:
- Gateway with MQTT on ESP8266 Nodemcu
- NRF24L01+
- BME280
This is the sketch I'm trying to use:
#define MY_DEBUG #define MY_DEBUG_VERBOSE_GATEWAY #define MY_BAUD_RATE 9600 #define MY_RADIO_RF24 #define MY_RF24_DATARATE RF24_2MBPS #define MY_RF24_PA_LEVEL RF24_PA_HIGH #define MY_RF24_CE_PIN 3 #define MY_GATEWAY_MQTT_CLIENT #define MY_GATEWAY_ESP8266 #define MY_MQTT_PUBLISH_TOPIC_PREFIX "domoticz/in/fh-gateway-esterno-new" #define MY_MQTT_SUBSCRIBE_TOPIC_PREFIX "domoticz/out/fh-gateway-esterno-new" #define MY_MQTT_CLIENT_ID "fh-gateway-esterno-new" #define MY_WIFI_SSID "iNeo" #define MY_WIFI_PASSWORD "password" #define MY_HOSTNAME "fh-gateway-esterno-new" #define MY_CONTROLLER_IP_ADDRESS 192, 168, 0, 3 #define MY_PORT 1883 #define MY_SIGNAL_REPORT_ENABLED #define MY_TRANSPORT_SANITY_CHECK #include <ESP8266WiFi.h> #include <MySensors.h> #include <SPI.h> #include <Wire.h> #include "BlueDot_BME280.h" BlueDot_BME280 bme280 = BlueDot_BME280(); #define LONG_WAIT 500 #define SHORT_WAIT 150 #define SECURE_WAIT 60000 #define SKETCH_NAME "Gateway Esterno" #define SKETCH_VERSION "v4.0" #define TEMP_CHILD_ID 1 #define HUM_CHILD_ID 2 #define BARO_CHILD_ID 3 uint32_t SLEEP_TIME = 15000; bool metric = true; MyMessage temperatureMsg(TEMP_CHILD_ID, V_TEMP); MyMessage humidityMsg(HUM_CHILD_ID, V_HUM); MyMessage pressureMsg(BARO_CHILD_ID, V_PRESSURE); void preHwInit() { Wire.setClock(100000); bme280.parameter.communication = 0; bme280.parameter.I2CAddress = 0x77; bme280.parameter.sensorMode = 0b11; bme280.parameter.IIRfilter = 0b010; bme280.parameter.humidOversampling = 0b011; bme280.parameter.tempOversampling = 0b011; bme280.parameter.pressOversampling = 0b101; bme280.parameter.pressureSeaLevel = 1013.25; bme280.parameter.tempOutsideCelsius = 15; bme280.init(); } void setup() { } void presentation() { sendSketchInfo(SKETCH_NAME, SKETCH_VERSION); wait(LONG_WAIT); present(BARO_CHILD_ID, S_BARO); wait(SHORT_WAIT); present(TEMP_CHILD_ID, S_TEMP); wait(SHORT_WAIT); present(HUM_CHILD_ID, S_HUM); wait(SHORT_WAIT); } void loop() { send(temperatureMsg.set(bme280.readTempC(), 2)); wait(SHORT_WAIT); send(humidityMsg.set(bme280.readHumidity(), 2)); wait(SHORT_WAIT); send(pressureMsg.set(bme280.readPressure(), 2)); wait(LONG_WAIT); wait(SLEEP_TIME); }
This is the error I'm getting, it repeats endlessy as soon as I enable the radio:
03:52:43.408 -> ⸮l⸮r⸮86 MCO:BGN:INIT GW,CP=RNNGE---,REL=255,VER=2.3.1 03:52:43.558 -> 138 TSF:LRT:OK 03:52:43.590 -> 154 TSM:INIT 03:52:43.590 -> 167 TSF:WUR:MS=0 03:52:43.625 -> 192 TSM:INIT:TSP OK 03:52:43.667 -> scandone 03:52:43.667 -> state: 0 -> 2 (b0) 03:52:43.667 -> state: 2 -> 3 (0) 03:52:43.696 -> state: 3 -> 5 (10) 03:52:43.696 -> add 0 03:52:43.731 -> aid 10 03:52:43.731 -> cnt 03:52:43.731 -> 03:52:43.731 -> connected with iNeo, channel 11 03:52:43.766 -> dhcp client start... 03:52:43.800 -> ip:192.168.0.138,mask:255.255.255.0,gw:192.168.0.1 03:52:43.836 -> 409 TSM:INIT:GW MODE 03:52:43.872 -> 431 TSM:READY:ID=0,PAR=0,DIS=0 03:52:43.906 -> 463 MCO:REG:NOT NEEDED 03:52:43.906 -> 491 TSM:READY:NWD REQ 03:52:46.692 -> Soft WDT reset 03:52:46.730 -> 03:52:46.730 -> >>>stack>>> 03:52:46.730 -> 03:52:46.730 -> ctx: cont 03:52:46.730 -> sp: 3ffffc50 end: 3fffffd0 offset: 01b0 03:52:46.798 -> 3ffffe00: 001e8480 3ffe0001 3ffee76c 40202f42 03:52:46.832 -> 3ffffe10: 00000000 0000000e 00000000 000000ff 03:52:46.899 -> 3ffffe20: 00000000 00000001 00000003 00000030 03:52:46.939 -> 3ffffe30: 00000000 0000d6f1 0000000e 40203025 03:52:47.007 -> 3ffffe40: 00000000 3ffee765 00000000 402030ec 03:52:47.044 -> 3ffffe50: 00000007 44414552 574e3a59 45522044 03:52:47.078 -> 3ffffe60: ff000a51 3fffc6fc 00000032 000000ff 03:52:47.147 -> 3ffffe70: 3ffe84fe 3ffee8b8 3ffee765 40203d23 03:52:47.182 -> 3ffffe80: 3ffe84ff 3fffff00 40232fa6 3ffeee14 03:52:47.257 -> 3ffffe90: 666e6f63 7463696c 3f003132 3ffeee14 03:52:47.288 -> 3ffffea0: 00000000 4bc6a7f0 845a1cac 00000000 03:52:47.358 -> 3ffffeb0: 00000000 00000000 4bc6a7f0 00000000 03:52:47.393 -> 3ffffec0: 00000001 3ffef22c 3ffffef0 3ffffee0 03:52:47.464 -> 3ffffed0: 00000004 3f407596 0000049c 4021425c 03:52:47.497 -> 3ffffee0: 00023851 00418937 00000000 3ffee70c 03:52:47.565 -> 3ffffef0: 3ffe84fe 3ffee765 000000ff 40203e6c 03:52:47.605 -> 3fffff00: 3ffe84fe 000001eb 3ffee7a8 40204248 03:52:47.641 -> 3fffff10: 00000000 3fff017c 000001f4 402037a5 03:52:47.710 -> 3fffff20: 00023825 000001eb 000001f4 40205111 03:52:47.745 -> 3fffff30: 40233e67 000001eb 000001f4 4020512f 03:52:47.813 -> 3fffff40: 3ffe84fe 000001eb 000001f4 40205153 03:52:47.850 -> 3fffff50: 00000002 3ffeea83 3ffeea83 4020518f 03:52:47.921 -> 3fffff60: 00000006 00000000 3ffeea83 00000001 03:52:47.953 -> 3fffff70: 00000000 00a7fd40 00000000 3ffee70c 03:52:48.039 -> 3fffff80: 3ffe84fe 3ffeea83 00000000 4020573a 03:52:48.060 -> 3fffff90: 40204140 0300a8c0 40208658 40208640 03:52:48.133 -> 3fffffa0: 3fffdad0 3ffee763 3ffeebce 402057f4 03:52:48.165 -> 3fffffb0: feefeffe 00000000 3ffee668 40205858 03:52:48.202 -> 3fffffc0: feefeffe feefeffe 3ffe853c 4010010d 03:52:48.275 -> <<<stack<<<
Stack trace debug didn't give any insight, at least to a profane like me:
x40100ba0: delayMicroseconds at C:\Users\deimo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_wiring.c line 205 0x40100bc9: __digitalWrite at C:\Users\deimo\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.5.0\cores\esp8266\core_esp8266_wiring_digital.c line 82 0x40202edb: RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/hal/transport/RF24/driver/RF24.cpp line 100 0x40202f42: RF24_spiMultiByteTransfer(uint8_t, uint8_t*, uint8_t, bool) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/hal/transport/RF24/driver/RF24.cpp line 120 0x40203025: RF24_spiByteTransfer(uint8_t) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/hal/transport/RF24/driver/RF24.cpp line 125 0x402030ec: RF24_sendMessage(uint8_t, void const*, uint8_t, bool) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/hal/transport/RF24/driver/RF24.cpp line 154 0x40203d23: transportSendWrite(unsigned char, MyMessage&) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyTransport.cpp line 1005 0x40203e6c: transportRouteMessage(MyMessage&) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyTransport.cpp line 586 0x40204248: stReadyUpdate() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyTransport.cpp line 313 0x402037a5: transportUpdateSM() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyTransport.cpp line 387 0x40205111: transportProcess() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyTransport.cpp line 466 0x4020512f: _process() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp line 78 0x40205153: wait(unsigned int) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp line 533 0x4020518f: gatewayTransportConnect() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyGatewayTransportMQTTClient.cpp line 157 0x4020573a: gatewayTransportInit() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyGatewayTransportMQTTClient.cpp line 269 0x40204140: incomingMQTT(char*, unsigned char*, unsigned int) at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MyGatewayTransportMQTTClient.cpp line 123 0x40208658: std::_Function_base::_Base_manager ::_M_manager(std::_Any_data&, std::_Any_data const&, std::_Manager_operation) at c:\users\deimo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 1934 0x40208640: std::_Function_handler ::_M_invoke(std::_Any_data const&, char*, unsigned char*, unsigned int) at c:\users\deimo\appdata\local\arduino15\packages\esp8266\tools\xtensa-lx106-elf-gcc\2.5.0-3-20ed2b9\xtensa-lx106-elf\include\c++\4.8.2/functional line 2069 0x402057f4: _begin() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/core/MySensorsCore.cpp line 165 0x40205858: loop_wrapper() at C:\Users\deimo\Documents\Arduino\libraries\MySensors/hal/architecture/ESP8266/MyMainESP8266.cpp line 125
As you can see, I also tried implementing the preHwInit() method from here but without luck apparently.
If I disable the radio, the whole thing works perfectly: but since I changed so many radios (and also boards and sensors) I doubt, at this point, that the problem is faulty hardware.
I also tried powering up the radio from a different power source, with the same result.
UPDATE:
The problem seems to be correlated with the use of the specific sensor BME280. The way the sensor library work is causing issues with MySensors, generating the whole soft reset issue.
Tested with all the major libraries for BME280, the behaviour is always the same. As soon as the BME is initialized to start measuring the gateway crashes/reboots.
Confirmed that this happens only when the gateway is configured to use NRF24: ther same hardware, with the same sketch, without radio features, works perfectly over mqtt.UPDATE 2: Problem Solved.