Soft WDT reset on ESP8266 RFM69 gateway after find parent
Troubleshooting
21
Posts
3
Posters
2.4k
Views
3
Watching
-
@mfalkvidd but how do you know which node rssi is which? You are getting an average of mixed values since domoticz is recording one value every 5 minutes
-
Since my node had been reporting without problems for several days, I disconnected the gateway from my computer and plugged it in to a phone charger instead. The gateway came up as it should and Domoticz reconnected but I am no longer getting any messages from the node. Reset the node but that didn't help. Back to troubleshooting.
-
Alright. I'll add a ceramic capacitor.
For compleeness, here is my complete sketch for the node:
// Enable debug prints #define MY_DEBUG #define MY_NODE_ID 1 // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_FREQUENCY RFM69_433MHZ // RFM69_433MHZ for development branch, RF69_433MHZ for master #define MY_RF69_IRQ_PIN 2 #define MY_RF69_SPI_CS 10 #include <MySensors.h> // From Library Manager #include <BME280I2C.h> // From Library Manager BME280I2C bme; static const uint64_t UPDATE_INTERVAL = 300000; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_VCC_BEFORE 2 #define CHILD_ID_VCC_AFTER 3 MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgVccBefore(CHILD_ID_VCC_BEFORE, V_VOLTAGE); MyMessage msgVccAfter(CHILD_ID_VCC_AFTER, V_VOLTAGE); //TODO: Add pressure from BME280? //TODO: Add light detection (irq-based, LDR) //TODO: Add flooding detection void presentation() { // Send the sketch version information to the gateway sendSketchInfo("StorageRoom", "1.1"); present(CHILD_ID_HUM, S_HUM); wait(100); present(CHILD_ID_TEMP, S_TEMP); wait(100); present(CHILD_ID_VCC_BEFORE, S_CUSTOM); wait(100); present(CHILD_ID_VCC_AFTER, S_CUSTOM); } void setup() { if (! bme.begin()) { Serial.println("Could not find a valid BME280 sensor, check wiring! Continuing without sensor..."); } } void loop() { static float lastTemp; static float lastHum; send(msgVccBefore.set(readVcc() / 1000.0, 3)); float temperature = bme.temp(); if (isnan(temperature)) { Serial.println("Failed reading temperature"); } else if (temperature != lastTemp) { // Only send temperature if it changed since the last measurement lastTemp = temperature; send(msgTemp.set(temperature, 1)); } #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif float humidity = bme.hum(); if (isnan(humidity)) { Serial.println("Failed reading humidity"); } else if (humidity != lastHum) { // Only send humidity if it changed since the last measurement lastHum = humidity; send(msgHum.set(humidity, 1)); } #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif send(msgVccAfter.set(readVcc() / 1000.0, 3)); // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } long readVcc() { // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA, ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high << 8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts }and for the gateway:
// Based on https://github.com/mysensors/MySensors/tree/master/examples/GatewayESP8266OTA #include <ArduinoOTA.h> // Enable debug prints to serial monitor #define MY_DEBUG #define MY_BAUD_RATE 74880 // To be able to see reset messages #define WIFI_REPORT_INTERVAL 300000 // Enables and select radio type (if attached) #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RF69_IRQ_PIN D2 #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN #define MY_RF69_SPI_CS D8 #define MY_RFM69_FREQUENCY RFM69_433MHZ // RFM69_433MHZ for development branch, RF69_433MHZ for master #define MY_GATEWAY_ESP8266 #define MY_WIFI_SSID "Mr-IoT.com" #include "settings.h" // Set the hostname for the WiFi Client. This is the hostname // it will pass to the DHCP server if not static. #define MY_HOSTNAME "RFM69-Gateway" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) //#define MY_IP_ADDRESS 192,168,178,87 // If using static ip you can define Gateway and Subnet address as well //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 #if defined(MY_USE_UDP) #include <WiFiUDP.h> #else #include <ESP8266WiFi.h> #endif #include <MySensors.h> #define CHILD_ID_WIFI_RSSI 0 MyMessage msgWifiRssi(CHILD_ID_WIFI_RSSI, V_LEVEL); #define CHILD_ID_RSSI1 1 MyMessage msgRssi1(CHILD_ID_RSSI1, V_LEVEL); bool sendRssi = false; int16_t rssi; void setup() { // Setup locally attached sensors ArduinoOTA.onStart([]() { DEBUG_OUTPUT("ArduinoOTA start\n"); }); ArduinoOTA.onEnd([]() { DEBUG_OUTPUT("\nArduinoOTA end\n"); }); ArduinoOTA.setPassword((const char *)OTA_PASSWORD); ArduinoOTA.setHostname(MY_HOSTNAME); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { DEBUG_OUTPUT("OTA Progress: %u%%\r", (progress / (total / 100))); }); ArduinoOTA.onError([](ota_error_t error) { DEBUG_OUTPUT("Error[%u]: ", error); if (error == OTA_AUTH_ERROR) { DEBUG_OUTPUT("Auth Failed\n"); } else if (error == OTA_BEGIN_ERROR) { DEBUG_OUTPUT("Begin Failed\n"); } else if (error == OTA_CONNECT_ERROR) { DEBUG_OUTPUT("Connect Failed\n"); } else if (error == OTA_RECEIVE_ERROR) { DEBUG_OUTPUT("Receive Failed\n"); } else if (error == OTA_END_ERROR) { DEBUG_OUTPUT("End Failed\n"); } }); ArduinoOTA.begin(); } void presentation() { // Present locally attached sensors here present(CHILD_ID_WIFI_RSSI, S_SOUND); wait(100); present(CHILD_ID_RSSI1, S_SOUND); } long lastSend = 0; void loop() { // Send locally attech sensors data here ArduinoOTA.handle(); if (millis() - lastSend > WIFI_REPORT_INTERVAL) { send(msgWifiRssi.set(WiFi.RSSI(), 1)); lastSend = millis(); } if (sendRssi) { sendRssi = false; send(msgRssi1.set(rssi, 0)); } } void receive(const MyMessage &message) { rssi = _radio.RSSI; if (message.sender == 1) { sendRssi = true; } } -
Alright. I'll add a ceramic capacitor.
For compleeness, here is my complete sketch for the node:
// Enable debug prints #define MY_DEBUG #define MY_NODE_ID 1 // Enable and select radio type attached #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RFM69_FREQUENCY RFM69_433MHZ // RFM69_433MHZ for development branch, RF69_433MHZ for master #define MY_RF69_IRQ_PIN 2 #define MY_RF69_SPI_CS 10 #include <MySensors.h> // From Library Manager #include <BME280I2C.h> // From Library Manager BME280I2C bme; static const uint64_t UPDATE_INTERVAL = 300000; #define CHILD_ID_HUM 0 #define CHILD_ID_TEMP 1 #define CHILD_ID_VCC_BEFORE 2 #define CHILD_ID_VCC_AFTER 3 MyMessage msgHum(CHILD_ID_HUM, V_HUM); MyMessage msgTemp(CHILD_ID_TEMP, V_TEMP); MyMessage msgVccBefore(CHILD_ID_VCC_BEFORE, V_VOLTAGE); MyMessage msgVccAfter(CHILD_ID_VCC_AFTER, V_VOLTAGE); //TODO: Add pressure from BME280? //TODO: Add light detection (irq-based, LDR) //TODO: Add flooding detection void presentation() { // Send the sketch version information to the gateway sendSketchInfo("StorageRoom", "1.1"); present(CHILD_ID_HUM, S_HUM); wait(100); present(CHILD_ID_TEMP, S_TEMP); wait(100); present(CHILD_ID_VCC_BEFORE, S_CUSTOM); wait(100); present(CHILD_ID_VCC_AFTER, S_CUSTOM); } void setup() { if (! bme.begin()) { Serial.println("Could not find a valid BME280 sensor, check wiring! Continuing without sensor..."); } } void loop() { static float lastTemp; static float lastHum; send(msgVccBefore.set(readVcc() / 1000.0, 3)); float temperature = bme.temp(); if (isnan(temperature)) { Serial.println("Failed reading temperature"); } else if (temperature != lastTemp) { // Only send temperature if it changed since the last measurement lastTemp = temperature; send(msgTemp.set(temperature, 1)); } #ifdef MY_DEBUG Serial.print("T: "); Serial.println(temperature); #endif float humidity = bme.hum(); if (isnan(humidity)) { Serial.println("Failed reading humidity"); } else if (humidity != lastHum) { // Only send humidity if it changed since the last measurement lastHum = humidity; send(msgHum.set(humidity, 1)); } #ifdef MY_DEBUG Serial.print("H: "); Serial.println(humidity); #endif send(msgVccAfter.set(readVcc() / 1000.0, 3)); // Sleep for a while to save energy sleep(UPDATE_INTERVAL); } long readVcc() { // From http://provideyourown.com/2012/secret-arduino-voltmeter-measure-battery-voltage/ // Read 1.1V reference against AVcc // set the reference to Vcc and the measurement to the internal 1.1V reference #if defined(__AVR_ATmega32U4__) || defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) ADMUX = _BV(REFS0) | _BV(MUX4) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #elif defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) ADMUX = _BV(MUX5) | _BV(MUX0); #elif defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__) ADMUX = _BV(MUX3) | _BV(MUX2); #else ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); #endif delay(2); // Wait for Vref to settle ADCSRA |= _BV(ADSC); // Start conversion while (bit_is_set(ADCSRA, ADSC)); // measuring uint8_t low = ADCL; // must read ADCL first - it then locks ADCH uint8_t high = ADCH; // unlocks both long result = (high << 8) | low; result = 1125300L / result; // Calculate Vcc (in mV); 1125300 = 1.1*1023*1000 return result; // Vcc in millivolts }and for the gateway:
// Based on https://github.com/mysensors/MySensors/tree/master/examples/GatewayESP8266OTA #include <ArduinoOTA.h> // Enable debug prints to serial monitor #define MY_DEBUG #define MY_BAUD_RATE 74880 // To be able to see reset messages #define WIFI_REPORT_INTERVAL 300000 // Enables and select radio type (if attached) #define MY_RADIO_RFM69 #define MY_IS_RFM69HW #define MY_RF69_IRQ_PIN D2 #define MY_RF69_IRQ_NUM MY_RF69_IRQ_PIN #define MY_RF69_SPI_CS D8 #define MY_RFM69_FREQUENCY RFM69_433MHZ // RFM69_433MHZ for development branch, RF69_433MHZ for master #define MY_GATEWAY_ESP8266 #define MY_WIFI_SSID "Mr-IoT.com" #include "settings.h" // Set the hostname for the WiFi Client. This is the hostname // it will pass to the DHCP server if not static. #define MY_HOSTNAME "RFM69-Gateway" // Enable MY_IP_ADDRESS here if you want a static ip address (no DHCP) //#define MY_IP_ADDRESS 192,168,178,87 // If using static ip you can define Gateway and Subnet address as well //#define MY_IP_GATEWAY_ADDRESS 192,168,178,1 //#define MY_IP_SUBNET_ADDRESS 255,255,255,0 // The port to keep open on node server mode #define MY_PORT 5003 // How many clients should be able to connect to this gateway (default 1) #define MY_GATEWAY_MAX_CLIENTS 2 // Controller ip address. Enables client mode (default is "server" mode). // Also enable this if MY_USE_UDP is used and you want sensor data sent somewhere. //#define MY_CONTROLLER_IP_ADDRESS 192, 168, 178, 68 #if defined(MY_USE_UDP) #include <WiFiUDP.h> #else #include <ESP8266WiFi.h> #endif #include <MySensors.h> #define CHILD_ID_WIFI_RSSI 0 MyMessage msgWifiRssi(CHILD_ID_WIFI_RSSI, V_LEVEL); #define CHILD_ID_RSSI1 1 MyMessage msgRssi1(CHILD_ID_RSSI1, V_LEVEL); bool sendRssi = false; int16_t rssi; void setup() { // Setup locally attached sensors ArduinoOTA.onStart([]() { DEBUG_OUTPUT("ArduinoOTA start\n"); }); ArduinoOTA.onEnd([]() { DEBUG_OUTPUT("\nArduinoOTA end\n"); }); ArduinoOTA.setPassword((const char *)OTA_PASSWORD); ArduinoOTA.setHostname(MY_HOSTNAME); ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) { DEBUG_OUTPUT("OTA Progress: %u%%\r", (progress / (total / 100))); }); ArduinoOTA.onError([](ota_error_t error) { DEBUG_OUTPUT("Error[%u]: ", error); if (error == OTA_AUTH_ERROR) { DEBUG_OUTPUT("Auth Failed\n"); } else if (error == OTA_BEGIN_ERROR) { DEBUG_OUTPUT("Begin Failed\n"); } else if (error == OTA_CONNECT_ERROR) { DEBUG_OUTPUT("Connect Failed\n"); } else if (error == OTA_RECEIVE_ERROR) { DEBUG_OUTPUT("Receive Failed\n"); } else if (error == OTA_END_ERROR) { DEBUG_OUTPUT("End Failed\n"); } }); ArduinoOTA.begin(); } void presentation() { // Present locally attached sensors here present(CHILD_ID_WIFI_RSSI, S_SOUND); wait(100); present(CHILD_ID_RSSI1, S_SOUND); } long lastSend = 0; void loop() { // Send locally attech sensors data here ArduinoOTA.handle(); if (millis() - lastSend > WIFI_REPORT_INTERVAL) { send(msgWifiRssi.set(WiFi.RSSI(), 1)); lastSend = millis(); } if (sendRssi) { sendRssi = false; send(msgRssi1.set(rssi, 0)); } } void receive(const MyMessage &message) { rssi = _radio.RSSI; if (message.sender == 1) { sendRssi = true; } }