lumapu / ahoy

Various tools, examples, and documentation for communicating with Hoymiles microinverters
https://ahoydtu.de
Other
953 stars 225 forks source link

Feature Request: Support ESP32 C3 #830

Open Argafal opened 1 year ago

Argafal commented 1 year ago

I am trying out a ESP32-C3. The board is a Lolin C3 mini, v2.1.0. In this issue I will collect changes required to run Ahoy on an ESP32-c3. If ever successful (big if) this can be used for a pull request later. Contributions/tests of others are most welcome.

My build environment (add this to platformio.ini):

[env:lolin_c3_mini]
platform = espressif32
board = lolin_c3_mini
build_flags = -D RELEASE -std=gnu++14 -DCONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=true -DCONFIG_ESP_CONSOLE_UART=ESP_CONSOLE_USB_SERIAL_JTAG
build_unflags = -std=gnu++11
monitor_filters =
    ;default   ; Remove typical terminal control codes from input
    ;time      ; Add timestamp with milliseconds for each new line
    ;log2file  ; Log data to a file “platformio-device-monitor-*.log” located in the current working directory
    esp32_exception_decoder
Argafal commented 1 year ago

First problem: a boot loop. The error looks as such:

ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)
Saved PC:0x40380082
SPIWP:0xee
mode:DIO, clock div:1
load:0x3fcd5810,len:0x438
load:0x403cc710,len:0x91c
load:0x403ce710,len:0x25b0
entry 0x403cc710
I: Initializing FS ..
I:  .. done
[   205][E][vfs_api.cpp:105] open(): /littlefs/settings.json does not exist, no permits for creation
W: failed to load json, using default config
I: Settings valid: false
ESP-ROM:esp32c3-api1-20210207
Build:Feb  7 2021
rst:0x8 (TG1WDT_SYS_RST),boot:0xf (SPI_FAST_FLASH_BOOT)

It is caused by non-existing pins being selected in the default configuration. Pin 16 (irq) does not exist on the C3 board. Hence in hmRadio.h the setup(...) method fails when calling pinMode(irq, INPUT_PULLUP);

The user should be informed when this fails. One can work around this issue by changing the default pins in config/config.h. Ahoy then boots.

Argafal commented 1 year ago

Next up, no access point is created. Ahoy keeps on trying to connect to the wifi with the ssid YOUR_WIFI_SSID.

I changed config/config.h to include my ssid and wifi password. However, AHOY doesn't connect to it either. Log snippet:

scanning APs with SSID XXX
reconnect in 8 seconds
reconnect in 7 seconds
reconnect in 6 seconds
reconnect in 5 seconds
reconnect in 4 seconds
reconnect in 3 seconds
reconnect in 2 seconds
Wifi event: 1
reconnect in 1 seconds
BSSID 0: 0 11 32 9d 20 95
reconnect in 0 seconds
try to connect to AP with BSSID: X Y Z A B C
reconnect in 19 seconds
Wifi event: 5
I: connectionEvent
reconnect in 18 seconds
Wifi event: 5
I: connectionEvent
reconnect in 17 seconds
Wifi event: 5
I: connectionEvent
reconnect in 16 seconds
Wifi event: 5
I: connectionEvent
reconnect in 15 seconds
Wifi event: 5
I: connectionEvent
reconnect in 14 seconds
Wifi event: 5
I: connectionEvent
reconnect in 13 seconds
Wifi event: 5
I: connectionEvent
reconnect in 12 seconds
Wifi event: 5

I have not found a solution yet. I will update this comment if/when I do. Others might chime in. Note: this is v2.1.0 of the Lolin C3 mini board. v1.0.0 had a wifi hardware issue. This version does not (supposedly).

stefan123t commented 2 weeks ago

@lumapu are there any plans to support the ESP32-C3 too ? Or can we close this as wontfix ?