ryanalden / esphome-jura-component

Custom component for ESPhome to communicate with Jura Impressa J6 coffee machines
71 stars 22 forks source link

reboots when using jura wifi dongle #13

Open pvtex opened 5 months ago

pvtex commented 5 months ago

Hi,

i am trying to use the jura wifi dongle with the esp32 inside. when i use your code i get a watchdog timeout right after wifi scan has started. this happens a few time and then the esp32 starts in safe mode. what do i have to do to get the dongle running with your code?

[D][text_sensor:064]: 'Jura-Wifi ESPHome version': Sending state '2024.5.4 May 29 2024, 13:22:16'
[D][binary_sensor:034]: 'Jura-Wifi Status': Sending initial state OFF
[C][wifi:038]: Setting up WiFi...
[C][wifi:051]: Starting WiFi...
[C][wifi:052]:   Local MAC: A4:E5:7C:52:E9:BC
[D][wifi:462]: Starting scan...
[D][sensor:094]: 'Jura-Wifi Uptime': Sending state 0.34800 s with 0 decimals of accuracy
E (10963) task_wdt: Task watchdog got triggered. The following tasks did not reset the watchdog in time:
E (10963) task_wdt:  - loopTask (CPU 1)
E (10963) task_wdt: Tasks currently running:
E (10963) task_wdt: CPU 0: IDLE
E (10963) task_wdt: CPU 1: IDLE
E (10963) task_wdt: Aborting.

abort() was called at PC 0x400ff648 on core 0

Backtrace:0x40083809:0x3ffbe9bc |<-CORRUPTED

ELF file SHA256: 0000000000000000

Rebooting...
ets Jun  8 2016 00:22:57

rst:0xc (SW_CPU_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:13132
load:0x40080400,len:3036
entry 0x400805e4
[I][logger:156]: Log initialized
[C][status_led:014]: Setting up Status LED...
[C][ota:483]: There have been 1 suspected unsuccessful boot attempts.
[D][esp32.preferences:114]: Saving 1 preferences to flash...
[D][esp32.preferences:143]: Saving 1 preferences to flash: 0 cached, 1 written, 0 failed
[W][app:022]: Component <unknown> already registered! (0x3ffbcd08)
[I][app:029]: Running through setup()...
[C][uart.arduino_esp32:077]: Setting up UART...
pvtex commented 5 months ago

found the solution. first change the beginning of the yaml file:

substitutions:
  devicename: jura-wifi
  friendly_name: Jura-Wifi
  device_description: Jura Coffee Machine

esphome:
  name: $devicename
  comment: ${device_description}
  platformio_options:
    upload_speed: 115200
  includes:
    - jura_coffee.h

esp32:
  board: esp32dev
  framework:
    type: arduino

then i needed to edit the jura_coffee.h file: in the first line:

#include <esp_task_wdt.h>    
#define WDT_TIMEOUT 20

and the new setup function

void setup() override {      
    this->set_update_interval(60000);      // 600000 = 10 minutes // Now 60 seconds     
    esp_task_wdt_init(WDT_TIMEOUT, true);  // enable panic so ESP32 restarts      
    esp_task_wdt_add(NULL);                // add current thread to WDT watch      
}

and the new loop function:

void loop() override {      
    delay(8);       
    esp_task_wdt_reset();     // Added to repeatedly reset the Watch Dog Timer       
}