esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
291 stars 34 forks source link

PZEM 016 system crashes #2513

Open e1z0 opened 2 years ago

e1z0 commented 2 years ago

The problem

Constant crashes with PZEM016 module connected to d1 mini esp8266 using built-in 5V output from module, tried swap tx/rx nothing helped. It's crashing randomly, can run whole day without crash or can crash 5mins from startup and so on.

Connected using this schema (without lcd, only rx,tx,vcc 5v and gnd): )

Which version of ESPHome has the issue?

2021.9.2

What type of installation are you using?

pip

Which version of Home Assistant has the issue?

2021.9.6

What platform are you using?

ESP8266

Board

d1 mini

Component causing the issue

pzemac

Example YAML snippet

substitutions:
  esp_name: energy-monitor-1
  esp_name_upper: Energy Phase 1
  description: First phase energy monitor

esphome:
  name: ${esp_name}
  comment: ${description}
  platform: ESP8266
  board: d1_mini
  #arduino_version: latest
  arduino_version: dev

wifi:
  fast_connect: true
  power_save_mode: none
  reboot_timeout: 7min
  use_address: ${esp_name}.local
  ssid: !secret wifi_ap
  password: !secret wifi_password
  ap:
    ssid: "${esp_name_upper} AP"
    password: ""

web_server:
  port: 80

mqtt:
  broker: !secret mqtt_broker
  client_id: ${esp_name}-client
  username: livingroom
  password: MyMQTTPassword
  discovery: true

debug:

# Enable logging
logger:
  baud_rate: 0
  level: debug

ota:

uart:
  rx_pin: GPIO3
  tx_pin: GPIO1
  baud_rate: 9600
  stop_bits: 1

sensor:
  - platform: pzemac
    current:
      name: "${esp_name_upper} Current"
      id: aac
      internal: true
    voltage:
      name: "${esp_name_upper} Voltage"
      id: vac
      internal: true
    power:
      name: "${esp_name_upper} Power"
      id: w
      internal: true
    frequency:
      name: "${esp_name_upper} Frequency"
      id: f
      internal: true
    power_factor:
      name: "${esp_name_upper} Power Factor"
      id: pf
      internal: true
    update_interval: 2s
  - platform: total_daily_energy
    name: "${esp_name_upper} Daily Energy"
    power_id: w
    filters:
        # Multiplication factor from W to kW is 0.001
      - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:counter
    accuracy_decimals: 1

  - platform: template #########################
    name: "${esp_name_upper} Current Slow"
    lambda: |-
      if (id(aac).state) {
        return (id(aac).state);
      } else {
        return 0;
      }
    unit_of_measurement: A
    icon: "mdi:alpha-a-circle"
    update_interval: 10s

  - platform: template #########################
    name: "${esp_name_upper} Voltage Slow"
    lambda: |-
      if (id(vac).state) {
        return (id(vac).state);
      } else {
        return 0;
      }
    unit_of_measurement: V
    icon: "mdi:alpha-v-circle"
    update_interval: 10s

  - platform: template #########################
    name: "${esp_name_upper} Power Slow"
    lambda: |-
      if (id(w).state) {
        return (id(w).state);
      } else {
        return 0;
      }
    unit_of_measurement: W
    icon: "mdi:alpha-w-circle"
    update_interval: 10s
  - platform: template #########################
    name: "${esp_name_upper} Frequency Slow"
    lambda: |-
      if (id(f).state) {
        return (id(f).state);
      } else {
        return 0;
      }
    unit_of_measurement: Hz
    icon: "mdi:alpha-f-circle"
    update_interval: 10s
  - platform: template #########################
    name: "${esp_name_upper} Power Factor Slow"
    lambda: |-
      if (id(pf).state) {
        return (id(pf).state);
      } else {
        return 0;
      }
    unit_of_measurement: PF
    icon: "mdi:alpha-p-circle"
    update_interval: 10s

Anything in the logs that might be useful for us?

Reset Info: Fatal exception:0 flag:2 (Exception) epc1:0x4023e525 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000
Reset Info: Fatal exception:4 flag:1 (Hardware Watchdog) epc1:0x40242e13 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000
Reset Info: Fatal exception:0 flag:2 (Exception) epc1:0x402532a3 epc2:0x00000000 epc3:0x00000000 excvaddr:0x00000000 depc:0x00000000

Additional information

I've also tried different arduino_version from 3.0.1 to 2.6.3, the same problem on all versions. Also tried manual ip wifi configuration without fast connect, different AP, with power saving and without. When disconnected from module or with wrong baud_rate, it never crashes.

e1z0 commented 2 years ago

PZEM 004T v3.0 also crashes, i've extracted the backtrace

Exception 28: LoadProhibited: A load referenced a page mapped with an attribute that does not permit loads
PC: 0x40225e2b
EXCVADDR: 0x000000a4

Decoding stack results
0x402334b5: operator delete(void*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/del_op.cc line 48
20:39:09]--------------- CUT HERE FOR EXCEPTION DECODER ---------------
[20:39:09]
[20:39:09]Exception (28):
[20:39:09]epc1=0x40225e2b epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000a4 depc=0x00000000
[20:39:09]
[20:39:09]>>>stack>>>
[20:39:09]
[20:39:09]ctx: cont
[20:39:09]sp: 3ffffad0 end: 3fffffc0 offset: 0190
[20:39:09]3ffffc60:  3ffe9452 0000001f 00000001 402334b5  
[20:39:09]3ffffc70:  6d305b1b 0a0d0a0d 800d0a0d 40214d05  
[20:39:09]3ffffc80:  00000007 3fff582c 3fff7994 40214d6a  
[20:39:09]3ffffc90:  3fff691c 00000088 0002478b 3ffe8f64  
[20:39:09]3ffffca0:  00000007 3fff691c 3fff50e4 40214db8  
[20:39:09]3ffffcb0:  3fff691c 0088008f 0a003738 3fff50e4  
[20:39:09]3ffffcc0:  00000000 00000066 3ffefe90 402216b4  
[20:39:09]3ffffcd0:  00000007 3fff19f8 3fff1075 40208169  
[20:39:09]3ffffce0:  ffffffff 3fff1075 3fff563c 4020218d  
[20:39:09]3ffffcf0:  3fff561c 00000033 00000000 40202062  
[20:39:09]3ffffd00:  3ffffda0 3ffffd90 00000010 00000007  
[20:39:09]3ffffd10:  00000031 00000000 3fff0fec 40202300  
[20:39:09]3ffffd20:  00000033 40267304 3ffe8f64 4020ec14  
[20:39:09]3ffffd30:  3fff319c 3a83126f 00000010 3ab6434e  
[20:39:09]3ffffd40:  3fff47dc 00000001 3fff3118 4020ebe8  
[20:39:09]3ffffd50:  3ffffda0 3ffffd90 00000010 00000000  
[20:39:09]3ffffd60:  3fff3101 00000000 00000010 4020ec14  
[20:39:10]3ffffd70:  3ffffda0 3ffffd90 00000010 402060c8  
[20:39:10]3ffffd80:  3ffffda0 3ffffd90 00000010 40202062  
[20:39:10]3ffffd90:  00000000 4bc6a7f0 00024783 3ab6434e  
[20:39:10]3ffffda0:  00000022 00000000 4bc6a7f0 00000000  
[20:39:10]3ffffdb0:  00000000 3fff47e0 3fff3118 4020f068  
[20:39:10]3ffffdc0:  e0019a26 e0019a26 e0019a26 3ab6434e  
[20:39:10]3ffffdd0:  00024748 3fff3118 3fff30ac 4020733c  
[20:39:10]3ffffde0:  00000000 3ffffe20 00000010 00000006  
[20:39:10]3ffffdf0:  3fff30ac 00000000 3fff30ac 4020755d  
[20:39:10]3ffffe00:  00000000 3ffffe20 00000010 00000000  
[20:39:10]3ffffe10:  3ffffe30 3ffffe20 00000010 00000001  
[20:39:10]3ffffe20:  3fff61fc 00000000 3fff61cc 40207578  
[20:39:10]3ffffe30:  3fff2f98 00000000 3ffffe60 401000fd  
[20:39:10]3ffffe40:  3fff562c 00000097 3fff2ef4 402064e4  
[20:39:10]3ffffe50:  00000000 00000000 3fff2338 00000001  
[20:39:10]3ffffe60:  3fff2338 3ffffe70 00000010 40202300  
[20:39:10]3ffffe70:  3fff2338 402673cc 3ffe8f70 3fff1424  
[20:39:10]3ffffe80:  3fff2f98 00000000 4bc6a7f0 00000000  
[20:39:10]3ffffe90:  00000000 00000000 3fff2ef4 40206554  
[20:39:10]3ffffea0:  00000000 00000000 00000010 3fff3108  
[20:39:10]3ffffeb0:  00000001 00000000 00024731 3fff439c  
[20:39:10]3ffffec0:  3fff5e1c 0002472e 3fff2ef4 40206adc  
[20:39:10]3ffffed0:  00000001 00000000 40100ade b851eb85  
[20:39:10]3ffffee0:  00000000 4bc6a7f0 3ffefbb8 40206b78  
[20:39:10]3ffffef0:  3fff5e1c 0002472e 3fffff20 40226f14  
[20:39:10]3fffff00:  3fffdad0 0002472e 3ffefbb8 401006f1  
[20:39:10]3fffff10:  00001388 000233a6 0002472e 00000000  
[20:39:10]3fffff20:  00024731 3fff2f50 0000000d 3fff216c  
[20:39:10]3fffff30:  3fff5e50 3fff5e1c 0000000d 40223a5c  
[20:39:10]3fffff40:  402242d1 0000000d 3fff216c 3ffeffdc  
[20:39:10]3fffff50:  3fffdad0 00000000 3ffefbb8 4020cd45  
[20:39:10]3fffff60:  007a1200 cc1937a5 3fff2500 3fff24a0  
[20:39:10]3fffff70:  00000000 feefeffe feefeffe feefeffe  
[20:39:10]3fffff80:  00000000 00000000 00000001 3ffeffdc  
[20:39:10]3fffff90:  3fffdad0 00000000 3ffeff9c 40210300  
[20:39:10]3fffffa0:  3fffdad0 00000000 3ffeff9c 40223b74  
[20:39:10]3fffffb0:  feefeffe feefeffe 3ffe858c 40100955  
[20:39:10]<<<stack<<<
[20:39:10]
[20:39:10]--------------- CUT HERE FOR EXCEPTION DECODER ---------------
e1z0 commented 2 years ago
WARNING Decoded 0x40225a37: AsyncClient::canSend()
[21:09:50]Exception (28):
WARNING Exception type: Access to invalid address: LOAD (wild pointer?)
WARNING Decoded 0x40225a37: AsyncClient::canSend()
WARNING Found stack trace! Trying to decode it
WARNING Decoded 0x4023312d: operator delete(void*) at /workdir/repo/gcc/libstdc++-v3/libsupc++/del_op.cc:48
WARNING Decoded 0x40214911: AsyncEventSourceClient::_queueMessage(AsyncEventSourceMessage*)
WARNING Decoded 0x40214976: AsyncEventSourceClient::write(char const*, unsigned int)
WARNING Decoded 0x402149c4: AsyncEventSource::send(char const*, char const*, unsigned int, unsigned int)
WARNING Decoded 0x402212c0: Print::println()
WARNING Decoded 0x40207e5d: std::_Function_handler<void (int, char const*, char const*), esphome::web_server::WebServer::setup()::{lambda(int, char const*, char const*)#2}>::_M_invoke(std::_Any_data const&, int, char const*, char const*) at web_server.cpp
WARNING Decoded 0x4020218d: esphome::logger::Logger::log_message_(int, char const*, int)
WARNING Decoded 0x40202062: esphome::logger::Logger::vprintf_to_buffer_(char const*, __va_list_tag)
WARNING Decoded 0x40202300: esphome::logger::Logger::log_vprintf_(int, char const*, int, __FlashStringHelper const*, __va_list_tag)
WARNING Decoded 0x40264f9c: chip_v6_unset_chanfreq
WARNING Decoded 0x4020e8c8: esphome::esp_log_vprintf_(int, char const*, int, __FlashStringHelper const*, __va_list_tag)
WARNING Decoded 0x402258f1: AsyncClient::send()
WARNING Decoded 0x4020e8f4: esphome::esp_log_printf_(int, char const*, int, __FlashStringHelper const*, ...)
WARNING Decoded 0x4023319c: operator new(unsigned int) at /workdir/repo/gcc/libstdc++-v3/libsupc++/new_op.cc:52
WARNING Decoded 0x40223668: esp_yield
WARNING Decoded 0x40223ed2: __delay
WARNING Decoded 0x40203355: esphome::mqtt::MQTTClientComponent::publish(std::string const&, char const*, unsigned int, unsigned char, bool)
WARNING Decoded 0x40233b6e: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, std::allocator<char> const&) at /workdir/arena.x86_64/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:218 (discriminator 2)
WARNING Decoded 0x40233386: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string() at /workdir/arena.x86_64/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.h:541
WARNING Decoded 0x40203432: esphome::mqtt::MQTTClientComponent::publish(std::string const&, std::string const&, unsigned char, bool)
WARNING Decoded 0x40207f28: std::_Function_base::_Base_manager<esphome::web_server::WebServer::sensor_json(esphome::sensor::Sensor*, float)::{lambda(ArduinoJson::JsonObject&)#1}>::_M_manager(std::_Any_data&, std::_Function_base::_Base_manager<esphome::web_server::WebServer::sensor_json(esphome::sensor::Sensor*, float)::{lambda(ArduinoJson::JsonObject&)#1}> const&, std::_Manager_operation) at web_server.cpp
WARNING Decoded 0x4020380a: esphome::mqtt::MQTTComponent::publish(std::string const&, std::string const&)
WARNING Decoded 0x4020432c: esphome::mqtt::MQTTSensorComponent::publish_state(float)
WARNING Decoded 0x402339a4: std::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(std::string const&) at /workdir/arena.x86_64/gcc/xtensa-lx106-elf/libstdc++-v3/include/bits/basic_string.tcc:176
WARNING Decoded 0x40204354: std::_Function_handler<void (float), esphome::mqtt::MQTTSensorComponent::setup()::{lambda(float)#1}>::_M_invoke(std::_Any_data const&, float) at mqtt_sensor.cpp
WARNING Decoded 0x401000fd: std::function<void (float)>::operator()(float) const
WARNING Decoded 0x40206388: esphome::sensor::Sensor::internal_send_state_to_frontend(float)
WARNING Decoded 0x4020e8f4: esphome::esp_log_printf_(int, char const*, int, __FlashStringHelper const*, ...)
WARNING Decoded 0x40205fd5: esphome::sensor::Filter::output(float)
WARNING Decoded 0x4020600d: esphome::sensor::Filter::input(float)
WARNING Decoded 0x40206402: esphome::sensor::Sensor::publish_state(float)
WARNING Decoded 0x4020718f: esphome::total_daily_energy::TotalDailyEnergy::publish_state_and_save(float)
WARNING Decoded 0x40207401: esphome::total_daily_energy::TotalDailyEnergy::process_new_state_(float)
WARNING Decoded 0x4020741c: std::_Function_handler<void (float), esphome::total_daily_energy::TotalDailyEnergy::setup()::{lambda(float)#1}>::_M_invoke(std::_Any_data const&, float) at total_daily_energy.cpp
WARNING Decoded 0x401000fd: std::function<void (float)>::operator()(float) const
WARNING Decoded 0x40100a7c: millis
WARNING Decoded 0x40206388: esphome::sensor::Sensor::internal_send_state_to_frontend(float)
WARNING Decoded 0x402063f8: esphome::sensor::Sensor::publish_state(float)
WARNING Decoded 0x40206980: esphome::template_::TemplateSensor::update()
WARNING Decoded 0x40100aaa: millis
WARNING Decoded 0x40206a1c: non-virtual thunk to esphome::template_::TemplateSensor::update()
WARNING Decoded 0x40226b88: std::_Function_handler<void (), esphome::PollingComponent::call_setup()::{lambda()#1}>::_M_invoke(std::_Any_data const&) at component.cpp
WARNING Decoded 0x401006e9: esphome::Scheduler::call()
WARNING Decoded 0x40105ef5: ets_timer_arm_new
WARNING Decoded 0x40223668: esp_yield
WARNING Decoded 0x40223edd: __delay
WARNING Decoded 0x4020ca25: esphome::Application::loop()
WARNING Decoded 0x4020ff0c: loop
WARNING Decoded 0x40223780: loop_wrapper() at core_esp8266_main.cpp
WARNING Decoded 0x40100921: cont_wrapper
github-actions[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.