Hi,
as this is my first post in this forum, please be patient I spent the last couple of days with troubleshooting but didn’t get any useful information so far.
I implemented a custom sensor using ESP32 to read the output from an optical interface from a Siemens UH50 heat meter inspired by this post:
Siemens UH50 / Landis+Gyr ULTRAHEAT T550 und die optische Schnittstelle | Sedelmaier.at
This solution worked for a couple of months now, until I upgraded Home Assistant to 2012.12 a couple of days ago resulting in sensor becoming unavailable.
Connected to USB to get some logs and recognized it got stuck in a boot loop:
[21:18:49]ets Jun 8 2016 00:22:57
[21:18:49]
[21:18:49]rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
[21:18:49]configsip: 0, SPIWP:0xee
[21:18:49]clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
[21:18:49]mode:DIO, clock div:2
[21:18:49]load:0x3fff0018,len:4
[21:18:49]load:0x3fff001c,len:1044
[21:18:49]load:0x40078000,len:8896
[21:18:49]load:0x40080400,len:5828
[21:18:49]entry 0x400806ac
[21:18:50][E][esp32-hal-misc.c:111] disableCore1WDT(): Failed to remove Core 1 IDLE task from WDT
[21:18:50][I][logger:214]: Log initialized
[21:18:50][C][ota:458]: There have been 8 suspected unsuccessful boot attempts.
[21:18:50][D][esp32.preferences:114]: Saving preferences to flash...
[21:18:50][I][app:029]: Running through setup()...
[21:18:50][C][wifi:037]: Setting up WiFi...
[21:18:50][D][wifi:370]: Starting scan...
[21:18:55]E (5430) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
[21:18:55]E (5430) task_wdt: - loopTask (CPU 1)
[21:18:55]E (5430) task_wdt: Tasks currently running:
[21:18:55]E (5430) task_wdt: CPU 0: IDLE0
[21:18:55]E (5430) task_wdt: CPU 1: loopTask
[21:18:55]E (5430) task_wdt: Aborting.
[21:18:55]abort() was called at PC 0x4014da1c on core 0
[21:18:55]
[21:18:55]ELF file SHA256: 0000000000000000
[21:18:55]
[21:18:55]Backtrace: 0x40088ac8:0x3ffbf820 0x40088d45:0x3ffbf840 0x4014da1c:0x3ffbf860 0x40087205:0x3ffbf880 0x40164923:0x3ffbc160 0x4014f327:0x3ffbc180 0x4008b505:0x3ffbc1a0 0x40089d56:0x3ffbc1c0
[21:18:55]
[21:18:55]Rebooting...
I tried compiling the custom component in Arduino IDE, uploaded it to my ESP32 module and everything worked as expected. So i guess there might be some issue with ESPhome.
yaml
esphome:
name: esp32_counter_heating
platform: ESP32
board: nodemcu-32s
includes:
- sensorMeterHeating.h
wifi:
ssid: !secret wlan_iot_ssid
password: !secret wlan_iot_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Esp32 Counter Heating"
password: "<PW>"
captive_portal:
# Enable logging
logger:
# Enable Home Assistant API
api:
password: !secret esphome_api_password
ota:
password: !secret esphome_api_password
sensor:
- platform: custom
lambda: |-
auto my_sensor = new SensorMeterHeating();
App.register_component(my_sensor);
return {my_sensor->sensor_kWh, my_sensor->sensor_m3};
sensors:
- name: "Meter Heating kWh"
unit_of_measurement: kWh
accuracy_decimals: 1
- name: "Meter Heating m3"
unit_of_measurement: m3
accuracy_decimals: 2
- platform: wifi_signal
name: "ESP32 Counter Heating WiFi Signal"
update_interval: 60s
custom component included in yaml
#include "esphome.h"
#define RXD2 16
#define TXD2 17
// Polling Intervall in minutes
int pollingInterval = 1;
class SensorMeterHeating : public PollingComponent {
public:
Sensor *sensor_kWh = new Sensor();
Sensor *sensor_m3 = new Sensor();
SensorMeterHeating() : PollingComponent(pollingInterval*60000) { }
void setup() override {
}
void update() override {
Serial2.begin(300, SERIAL_7E1, RXD2, TXD2);
Serial2.setTimeout(10000);
// send init message
for (int i=0; i <= 40; i++){
Serial2.write(0x00);
}
// send request message
Serial2.write("/?!\x0D\x0A");
Serial2.flush();
delay(500);
char term = '\n';
ESP_LOGD("custom", "Identification Message: %s", Serial2.readStringUntil(term));
ESP_LOGD("custom", "Change Baudrate to 2400");
Serial2.begin(2400, SERIAL_7E1, RXD2, TXD2);
char terminator = '!';
String output = Serial2.readStringUntil(terminator);
String kWh = substringBetween(output, "6.8(", "*kWh)6.26(");
int sensorOutput_kWh = kWh.toInt();
String m3 = substringBetween(output, "6.26(", "*m3)9.21(");
float sensorOutput_m3 = m3.toFloat();
ESP_LOGD("custom", "Sensor loaded");
//publish sensors if not 0
if (sensorOutput_kWh != 0 && sensorOutput_m3 != 0) {
ESP_LOGD("custom", "send data");
sensor_kWh->publish_state(sensorOutput_kWh);
sensor_m3->publish_state(sensorOutput_m3);
}
//ESP_LOGD("custom", strNew);
//Serial2.flush();
//Serial2.end();
}
String substringBetween(String s, String a, String b) {
int p = s.indexOf(a) + a.length();
return s.substring(p, s.indexOf(b, p));
}
};
Maybe someone had similar issues after the latest upgrade…
Cheers