Uruchomiłem na biurku pod ESPHome sam moduł oraz później Expander. Expander jest na PCF8574 i podłączany jest po I2C jak na zdjęciu. W zestawie był taki kabelek.
Mam dwa problemy z Expanderem:
-
Adres ustawiony jest jak na tym zdjęciu (tak był fabrycznie i tak zostawiłem):
Na stronie producenta nie ma szczegółów, jak z tego odczytać adres. Jest rozpiska do innego expandera ESP32R4: https://rocketcontroller.com/esp32r4-relays-expander-guide/ gdzie oznaczało by to 0x21. Moje ESP nie działało na domyślnym adresie 0x21, wykryło, że jest coś na 0x39. Ktoś, coś? Jakieś wyjaśnienia? -
Prawdziwy problem: Expander czasami włącza pierwszy przekaźnik. ESP rzuca błędami jak z tego loga:
INFO ESPHome 2024.7.3
INFO Reading configuration /config/esphome/esphome-web-83abac.yaml...
INFO Starting log output from 192.168.X.X using esphome API
INFO Successfully connected to esphome-web-83abac @ 192.168.X.X in 0.032s
INFO Successful handshake with esphome-web-83abac @ 192.168.X.X in 0.033s
[08:06:40][I][app:100]: ESPHome version 2024.7.3 compiled on Aug 6 2024, 21:04:37
[08:06:40][I][app:102]: Project esphome.web version dev
[08:06:40][C][status_led:019]: Status LED:
[08:06:40][C][status_led:020]: Pin: GPIO4
[08:06:40][C][wifi:599]: WiFi:
[...]
[08:06:40][C][logger:185]: Logger:
[08:06:40][C][logger:186]: Level: DEBUG
[08:06:40][C][logger:188]: Log Baud Rate: 115200
[08:06:40][C][i2c.arduino:071]: I2C Bus:
[08:06:40][C][i2c.arduino:072]: SDA Pin: GPIO21
[08:06:40][C][i2c.arduino:073]: SCL Pin: GPIO22
[08:06:40][C][i2c.arduino:074]: Frequency: 10000 Hz
[08:06:40][C][i2c.arduino:086]: Recovery: bus successfully recovered
[08:06:40][I][i2c.arduino:096]: Results from i2c bus scan:
[08:06:40][I][i2c.arduino:102]: Found i2c device at address 0x39
[08:06:40][C][pcf8574:021]: PCF8574:
[08:06:40][C][pcf8574:022]: Address: 0x39
[08:06:40][C][pcf8574:023]: Is PCF8575: NO
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay R1'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: GPIO25
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay R2'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: GPIO26
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay R3'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: GPIO33
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay R4'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: GPIO32
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay ER1'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: 0 via PCF8574
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay ER2'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: 1 via PCF8574
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay ER3'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: 2 via PCF8574
[08:06:40][C][switch.gpio:068]: GPIO Switch 'Ast Relay ER4'
[08:06:40][C][switch.gpio:091]: Restore Mode: always OFF
[08:06:40][C][switch.gpio:031]: Pin: 3 via PCF8574
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Ast SWITCH R1'
[08:06:40][C][gpio.binary_sensor:016]: Pin: GPIO34
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Ast SWITCH R2'
[08:06:40][C][gpio.binary_sensor:016]: Pin: GPIO35
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Ast SWITCH R3'
[08:06:40][C][gpio.binary_sensor:016]: Pin: GPIO36
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'Ast SWITCH R4'
[08:06:40][C][gpio.binary_sensor:016]: Pin: GPIO39
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'PCF8574 Pin #4'
[08:06:40][C][gpio.binary_sensor:016]: Pin: 4 via PCF8574
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'PCF8574 Pin #5'
[08:06:40][C][gpio.binary_sensor:016]: Pin: 5 via PCF8574
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'PCF8574 Pin #6'
[08:06:40][C][gpio.binary_sensor:016]: Pin: 6 via PCF8574
[08:06:40][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'PCF8574 Pin #7'
[08:06:40][C][gpio.binary_sensor:016]: Pin: 7 via PCF8574
[08:06:40][C][esp32_ble:383]: ESP32 BLE:
[08:06:40][C][esp32_ble:385]: MAC address: E4:65:B8:83:AB:AE
[08:06:40][C][esp32_ble:386]: IO Capability: none
[08:06:40][C][esp32_ble_server:200]: ESP32 BLE Server:
[08:06:40][C][esp32_improv.component:261]: ESP32 Improv:
[08:06:40][C][captive_portal:088]: Captive Portal:
[08:06:40][C][web_server:173]: Web Server:
[08:06:40][C][web_server:174]: Address: esphome-web-83abac.local:80
[08:06:40][C][mdns:116]: mDNS:
[08:06:40][C][mdns:117]: Hostname: esphome-web-83abac
[08:06:40][C][esphome.ota:073]: Over-The-Air updates:
[08:06:40][C][esphome.ota:074]: Address: esphome-web-83abac.local:3232
[08:06:40][C][esphome.ota:075]: Version: 2
[08:06:40][C][safe_mode:018]: Safe Mode:
[08:06:40][C][safe_mode:020]: Boot considered successful after 60 seconds
[08:06:40][C][safe_mode:021]: Invoke after 10 boot attempts
[08:06:40][C][safe_mode:023]: Remain in safe mode for 300 seconds
[08:06:40][C][api:139]: API Server:
[08:06:40][C][api:140]: Address: esphome-web-83abac.local:6053
[08:06:40][C][api:144]: Using noise encryption: NO
[08:06:40][C][improv_serial:032]: Improv Serial:
[08:06:50][W][component:157]: Component pcf8574 set Warning flag: unspecified
[08:06:50][D][binary_sensor:036]: 'PCF8574 Pin #4': Sending state ON
[08:06:50][D][switch:020]: 'Ast Relay ER1' Toggling ON.
[08:06:50][W][component:170]: Component pcf8574 cleared Warning flag
[08:06:50][D][switch:055]: 'Ast Relay ER1': Sending state ON
[08:06:50][W][component:237]: Component gpio.binary_sensor took a long time for an operation (1044 ms).
[08:06:50][W][component:238]: Components should block for at most 30 ms.
[08:06:50][D][binary_sensor:036]: 'PCF8574 Pin #4': Sending state OFF
[08:07:38][W][component:157]: Component pcf8574 set Warning flag: unspecified
[08:07:38][W][component:237]: Component gpio.binary_sensor took a long time for an operation (1018 ms).
[08:07:38][W][component:238]: Components should block for at most 30 ms.
[08:07:38][W][component:170]: Component pcf8574 cleared Warning flag
[08:07:39][W][component:157]: Component pcf8574 set Warning flag: unspecified
[08:07:39][W][component:237]: Component gpio.binary_sensor took a long time for an operation (1017 ms).
[08:07:39][W][component:238]: Components should block for at most 30 ms.
[08:07:39][W][component:170]: Component pcf8574 cleared Warning flag
YAML wygląda tak:
substitutions:
name: esphome-web-83abac
friendly_name: Ast
esphome:
name: ${name}
friendly_name: ${friendly_name}
min_version: 2024.6.0
name_add_mac_suffix: false
project:
name: esphome.web
version: dev
esp32:
board: esp32doit-devkit-v1
framework:
type: arduino
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
# Allow provisioning Wi-Fi via serial
improv_serial:
wifi:
ap:
ssid: "xxxx"
password: "xxxxx"
# In combination with the `ap` this allows the user
# to provision wifi credentials to the device via WiFi AP.
captive_portal:
dashboard_import:
package_import_url: github://esphome/example-configs/esphome-web/esp32.yaml@main
import_full_config: true
# Sets up Bluetooth LE (Only on ESP32) to allow the user
# to provision wifi credentials to the device.
esp32_improv:
authorizer: none
# To have a "next url" for improv serial
web_server:
status_led:
pin:
number: GPIO4
inverted: true
i2c:
sda: GPIO21
scl: GPIO22
# scan: true
id: bus_a
frequency: 10kHz
pcf8574:
- id: 'pcf8574_hub'
address: 0x39
pcf8575: false
switch:
- platform: gpio
name: "$friendly_name Relay R1"
pin: GPIO25
id: relayR1
- platform: gpio
name: "$friendly_name Relay R2"
pin: GPIO26
id: relayR2
- platform: gpio
name: "$friendly_name Relay R3"
pin: GPIO33
id: relayR3
- platform: gpio
name: "$friendly_name Relay R4"
pin: GPIO32
id: relayR4
# Individual outputs for expander
- platform: gpio
name: "$friendly_name Relay ER1"
pin:
pcf8574: pcf8574_hub
# Use pin number 0
number: 0
# One of INPUT or OUTPUT
mode:
output: true
inverted: false
id: relayER1
- platform: gpio
name: "$friendly_name Relay ER2"
pin:
pcf8574: pcf8574_hub
number: 1
mode:
output: true
inverted: false
id: relayER2
- platform: gpio
name: "$friendly_name Relay ER3"
pin:
pcf8574: pcf8574_hub
number: 2
mode:
output: true
inverted: false
id: relayER3
- platform: gpio
name: "$friendly_name Relay ER4"
pin:
pcf8574: pcf8574_hub
number: 3
mode:
output: true
inverted: false
id: relayER4
binary_sensor:
- platform: gpio
pin:
number: GPIO34
name: "$friendly_name SWITCH R1"
on_press:
then:
- switch.toggle: relayR1
- platform: gpio
pin:
number: GPIO35
name: "$friendly_name SWITCH R2"
on_press:
then:
- switch.toggle: relayR2
- platform: gpio
pin:
number: GPIO36
name: "$friendly_name SWITCH R3"
on_press:
then:
- switch.toggle: relayR3
- platform: gpio
pin:
number: GPIO39
name: "$friendly_name SWITCH R4"
on_press:
then:
- switch.toggle: relayR4
- platform: gpio
name: "PCF8574 Pin #4"
pin:
pcf8574: pcf8574_hub
number: 4
mode:
input: true
inverted: false
on_press:
then:
- switch.toggle: relayER1
- platform: gpio
name: "PCF8574 Pin #5"
pin:
pcf8574: pcf8574_hub
number: 5
mode:
input: true
inverted: false
on_press:
then:
- switch.toggle: relayER2
- platform: gpio
name: "PCF8574 Pin #6"
pin:
pcf8574: pcf8574_hub
number: 6
mode:
input: true
inverted: false
on_press:
then:
- switch.toggle: relayER3
- platform: gpio
name: "PCF8574 Pin #7"
pin:
pcf8574: pcf8574_hub
number: 7
mode:
input: true
inverted: false
on_press:
then:
- switch.toggle: relayER4
Pierwotnie I2C było na domyślnej prędkości 50kHz, ustawiłem mniej na 10kHz, ale nic się nie zmieniło. Jakieś pomysły? Te warningi powodują co jakiś czas reset urządzenia. Gdy byłem przy biurku, to nawet co kilkanaście minut. Gdy expander odłączyłem, to sam moduł się nie resetował, prawidłowo reagował na wejścia AC. Reklamować moduł expandera? Lutownicę mam, to mogę przylutować jakiegoś PullUP, ale ponoć ESPHOME automatycznie daje do takiego weścia I2C PullUpy. Chyba, że się coś zmieniło i PullUpa trzeba zadeklarować samodzielnie?