Zwischenstromzähler mit ESPHome und SH-U12 RS485 zu TTL auslesen

Hallo zusammen,

ich habe die Idee verworfen meinen Zwischenzähler mit einem Waveshare auszulesen. Ich denke die Variante mit einem ESP32 in ESPHome und einem SH-U12 RS485 zu TTL ist “schlanker”, günstiger und man muss nicht noch etwas auf dem Dashboard des Waveshare konfigurieren. Für mich als Anfänger fällt dann eine Fehlerquelle weg.

Verkabelt habe ich den ESP32 und das SH-U12 RS485 zu TTL wie folgt:

Quelle

Der ESP32 ist in ESPHome online, die Konfiguration sieht derzeit so aus:

esphome:
  name: wpstromzaehler
  friendly_name: wpstromzaehler
  min_version: 2026.4.0
  name_add_mac_suffix: false

esp32:
  variant: esp32
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

uart:
  id: mod_bus
  tx_pin: 17  
  rx_pin: 16   
  baud_rate: 9600
  stop_bits: 1
  parity: EVEN

modbus:
  id: modbus1
  uart_id: mod_bus           
  send_wait_time: 500ms      

modbus_controller:
  - id: wpstromzaehler
    address: 0x1            # address of the ModBUS slave device on the bus
    modbus_id: modbus1
    update_interval: 10s

Ich habe

uart, modbus und modbus_controller

erstmal aus diesem Beitrag übernommen.

Die baud_rate, stop_bits und parityhabe aus der Anleitung des Drehstromzählers.

Die Modbus Tabelle habe ich hier hochgeladen.

Ich brauche nun Hilfe dabei, dass ich den Stromverbrauch in Homeassistant im “Energy Dashboard” auswerten kann. Ich sehe nicht in den Entitäten bzw. es werden gar keine angelegt.

Viele Grüße
Martin

Die musst du schon selber anlegen so wie es in dem Beispiel das du als Vorlage genommen hast auch gemacht wird.

Ich habe nun weiter gesucht und mir folgende “sensor” angelegt:

esphome:
  name: wpstromzaehler
  friendly_name: wpstromzaehler
  min_version: 2026.4.0
  name_add_mac_suffix: false

esp32:
  variant: esp32
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password


uart:
  id: modbus_uart
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1

modbus:
  id: modbus1
  flow_control_pin: GPIO4

modbus_controller:
  - id: qtgdsz01
    address: 1
    modbus_id: modbus1
    update_interval: 10s
    setup_priority: -10

sensor:

  # Gesamtenergie
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Gesamtenergie"
    id: total_energy
    register_type: holding
    address: 6000
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtwirkenergie vorwärts
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Wirkenergie Vorwärts"
    address: 6010
    register_type: holding
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtleistung
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Leistung"
    id: total_power
    register_type: holding
    address: 5012
    value_type: FP32
    unit_of_measurement: "kW"
    device_class: power
    state_class: measurement
    accuracy_decimals: 2

  # Spannung L1
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L1"
    register_type: holding
    address: 5002
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L2
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L2"
    register_type: holding
    address: 5004
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L3
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L3"
    register_type: holding
    address: 5006
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Strom gesamt
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Strom Gesamt"
    register_type: holding
    address: 5008
    value_type: FP32
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 2

Nichtsdestotrotz habe ich weder die Entitäten, noch die Zustände in den Entwicklerwerkzeugen.

Ich versuche mich immer weiter. Praktisch müsste ja, wenn die yaml installiert wird, sonst halt eine “0” angeigt werden. Aber ich bekomme gar nichts.

So wir machen Fortschritte.
Nachdem ich nun einen neuen ESP32 gekauft habe, habe ich diesen anders in ESPHome eingebunden.

Den ESP32, der nicht lief, habe ich über web.esphome.io installiert. Anschließen über das WLAN mit “Take Controll” in ESPHome eingebunden. Anschließend die gleiche config installiert, dann wurden keine Entitäten angelegt.

Den neuen ESP32 habe ich per USB an Home Assistant angeschlossen und dann in ESPHome eingebunden. Dann die gleiche config installiert und siehe da - alle Entitäten wurden angelegt.

Entweder der ESP32 ist kaputt, oder der Weg des Anlegens in ESPHome war das Problem.
Gut, also nun muss ich noch den Modbus zum laufen bekommen.

Dieser Code ist nun auf dem ESP32:

esphome:
  name: wpstromzaehler
  friendly_name: wpstromzaehler
  min_version: 2026.4.0
  name_add_mac_suffix: false

esp32:
  variant: esp32
  framework:
    type: esp-idf

# Enable logging
logger:

# Enable Home Assistant API
api:

# Allow Over-The-Air updates
ota:
- platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password


uart:
  id: modbus_uart
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1

modbus:
  id: modbus1
  flow_control_pin: GPIO4

modbus_controller:
  - id: qtgdsz01
    address: 1
    modbus_id: modbus1
    update_interval: 10s
    setup_priority: -10

sensor:

  # Gesamtenergie
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Gesamtenergie"
    id: total_energy
    register_type: holding
    address: 6000
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtwirkenergie vorwärts
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Wirkenergie Vorwärts"
    address: 6010
    register_type: holding
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtleistung
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Leistung"
    id: total_power
    register_type: holding
    address: 5012
    value_type: FP32
    unit_of_measurement: "kW"
    device_class: power
    state_class: measurement
    accuracy_decimals: 2

  # Spannung L1
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L1"
    register_type: holding
    address: 5002
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L2
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L2"
    register_type: holding
    address: 5004
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L3
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L3"
    register_type: holding
    address: 5006
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Strom gesamt
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Strom Gesamt"
    register_type: holding
    address: 5008
    value_type: FP32
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 2

Ich habe ebenfalls versucht die Adressen zu kürzen (zum Beispiel 5999 statt 6000).
Ich habe RX und TX gedreht.

Trotzdem bekomme ich dieses Log:

INFO ESPHome 2026.5.3
INFO Loaded validated config cache for stromwp.yaml, skipping validation.
INFO Starting log output from stromwp.local using esphome API
INFO Successfully resolved stromwp.local in 1.593s
INFO Successfully connected to stromwp @ 10.10.7.120 in 0.007s
INFO Successful handshake with stromwp @ 10.10.7.120 in 0.096s
[19:30:33.252][I][app:151]: ESPHome version 2026.5.3 compiled on 2026-06-06 18:44:24 +0200
[19:30:33.252][I][app:158]: ESP32 Chip: ESP32 rev3.1, 2 core(s)
[19:30:33.253][W][app:171]: Chip rev >= 3.0 detected. Set minimum_chip_revision: "3.1" under esp32 > framework > advanced to reduce binary size
[19:30:33.253][W][app:198]: Bootloader supports SRAM1 as IRAM (+40KB). Set sram1_as_iram: true under esp32 > framework > advanced
[19:30:33.258][C][logger:219]: Logger:
[19:30:33.258][C][logger:219]:   Max Level: DEBUG
[19:30:33.258][C][logger:219]:   Initial Level: DEBUG
[19:30:33.280][C][logger:226]:   Log Baud Rate: 115200
[19:30:33.280][C][logger:226]:   Hardware UART: UART0
[19:30:33.281][C][logger:235]:   Task Log Buffer Size: 768 bytes
[19:30:33.304][C][uart.idf:254]: UART Bus 1:
[19:30:33.305][C][uart.idf:152]:   TX Pin: GPIO17
[19:30:33.308][C][uart.idf:152]:   RX Pin: GPIO16
[19:30:33.309][C][uart.idf:259]:   RX Buffer Size: 256
[19:30:33.309][C][uart.idf:259]:   RX Full Threshold: 8
[19:30:33.309][C][uart.idf:259]:   RX Timeout: 2
[19:30:33.310][C][uart.idf:268]:   Baud Rate: 9600 baud
[19:30:33.310][C][uart.idf:268]:   Data Bits: 8
[19:30:33.310][C][uart.idf:268]:   Parity: NONE
[19:30:33.310][C][uart.idf:268]:   Stop bits: 1
[19:30:33.310][C][uart.idf:268]:   Wake on data RX: ENABLED
[19:30:33.329][C][modbus:320]: Modbus:
[19:30:33.329][C][modbus:320]:   Send Wait Time: 250 ms
[19:30:33.329][C][modbus:320]:   Turnaround Time: 100 ms
[19:30:33.329][C][modbus:320]:   Frame Delay: 5 ms
[19:30:33.329][C][modbus:320]:   Long Rx Buffer Delay: 10 ms
[19:30:33.329][C][modbus:320]:   CRC Disabled: NO
[19:30:33.330][C][modbus:152]:   Flow Control Pin: GPIO4
[19:30:33.346][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Gesamtenergie'
[19:30:33.346]modbus_controller.sensor  State Class: 'total_increasing'
[19:30:33.346]modbus_controller.sensor  Unit of Measurement: 'kWh'
[19:30:33.346]modbus_controller.sensor  Accuracy Decimals: 2
[19:30:33.370][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'energy'
[19:30:33.370][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Wirkenergie Vorwärts'
[19:30:33.370]modbus_controller.sensor  State Class: 'total_increasing'
[19:30:33.370]modbus_controller.sensor  Unit of Measurement: 'kWh'
[19:30:33.370]modbus_controller.sensor  Accuracy Decimals: 2
[19:30:33.371][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'energy'
[19:30:33.392][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Leistung'
[19:30:33.392]modbus_controller.sensor  State Class: 'measurement'
[19:30:33.392]modbus_controller.sensor  Unit of Measurement: 'kW'
[19:30:33.392]modbus_controller.sensor  Accuracy Decimals: 2
[19:30:33.430][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'power'
[19:30:33.431][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Spannung L1'
[19:30:33.431]modbus_controller.sensor  State Class: 'measurement'
[19:30:33.431]modbus_controller.sensor  Unit of Measurement: 'V'
[19:30:33.431]modbus_controller.sensor  Accuracy Decimals: 1
[19:30:33.432][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'voltage'
[19:30:33.459][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Spannung L2'
[19:30:33.459]modbus_controller.sensor  State Class: 'measurement'
[19:30:33.459]modbus_controller.sensor  Unit of Measurement: 'V'
[19:30:33.459]modbus_controller.sensor  Accuracy Decimals: 1
[19:30:33.492][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'voltage'
[19:30:33.492][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Spannung L3'
[19:30:33.492]modbus_controller.sensor  State Class: 'measurement'
[19:30:33.492]modbus_controller.sensor  Unit of Measurement: 'V'
[19:30:33.492]modbus_controller.sensor  Accuracy Decimals: 1
[19:30:33.493][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'voltage'
[19:30:33.515][C][modbus_controller.sensor:017]: modbus_controller.sensorModbus Controller Sensor 'Strom Gesamt'
[19:30:33.515]modbus_controller.sensor  State Class: 'measurement'
[19:30:33.515]modbus_controller.sensor  Unit of Measurement: 'A'
[19:30:33.515]modbus_controller.sensor  Accuracy Decimals: 2
[19:30:33.561][C][modbus_controller.sensor:232]: modbus_controller.sensor  Device Class: 'current'
[19:30:33.561][C][captive_portal:133]: Captive Portal:
[19:30:33.566][C][wifi:1526]: WiFi:
[19:30:33.566][C][wifi:1526]:   Local MAC: 70:4B:CA:83:92:FC
[19:30:33.566][C][wifi:1526]:   Connected: YES
[19:30:33.570][C][wifi:1237]:   IP Address: 10.10.7.120
[19:30:33.575][C][wifi:1248]:   SSID: 'jemt-SH'[redacted]
[19:30:33.575][C][wifi:1248]:   BSSID: FA:9F:C2:AA:B8:43[redacted]
[19:30:33.575][C][wifi:1248]:   Hostname: 'stromwp'
[19:30:33.575][C][wifi:1248]:   Signal strength: -62 dB ▂▄▆█
[19:30:33.575][C][wifi:1248]:   Channel: 11
[19:30:33.575][C][wifi:1248]:   Subnet: 255.255.255.0
[19:30:33.575][C][wifi:1248]:   Gateway: 10.10.7.1
[19:30:33.575][C][wifi:1248]:   DNS1: 10.10.3.10
[19:30:33.575][C][wifi:1248]:   DNS2: 0.0.0.0
[19:30:33.593][C][esphome.ota:097]: Over-The-Air updates:
[19:30:33.593][C][esphome.ota:097]:   Address: stromwp.local:3232
[19:30:33.593][C][esphome.ota:097]:   Version: 2
[19:30:33.611][C][esphome.ota:104]:   Password configured
[19:30:33.628][C][safe_mode:058]: Safe Mode:
[19:30:33.628][C][safe_mode:058]:   Successful after: 60s
[19:30:33.628][C][safe_mode:058]:   Invoke after: 10 attempts
[19:30:33.628][C][safe_mode:058]:   Duration: 300s
[19:30:33.630][C][safe_mode:079]:   Bootloader rollback: support unknown
[19:30:33.655][C][web_server.ota:256]: Web Server OTA
[19:30:33.674][C][api:238]: Server:
[19:30:33.674][C][api:238]:   Address: stromwp.local:6053
[19:30:33.674][C][api:238]:   Listen backlog: 4
[19:30:33.674][C][api:238]:   Max connections: 5
[19:30:33.678][C][api:245]:   Noise encryption: YES
[19:30:33.697][C][mdns:230]: mDNS:
[19:30:33.697][C][mdns:230]:   Hostname: stromwp
[19:30:33.715][C][modbus_controller:309]: ModbusController:
[19:30:33.715][C][modbus_controller:309]:   Address: 0x01
[19:30:33.715][C][modbus_controller:309]:   Max Command Retries: 4
[19:30:33.715][C][modbus_controller:309]:   Offline Skip Updates: 0
[19:30:35.730][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:36.015][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:36.299][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:36.582][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:36.872][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:36.893][D][modbus_controller:038]: Modbus command to device=1 register=0x138A no response received - removed from send queue
[19:30:37.172][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:37.459][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:37.738][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:38.022][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:38.319][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:38.324][D][modbus_controller:038]: Modbus command to device=1 register=0x1394 no response received - removed from send queue
[19:30:38.610][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:38.896][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:39.178][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:39.464][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:39.751][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:39.754][D][modbus_controller:038]: Modbus command to device=1 register=0x1770 no response received - removed from send queue
[19:30:40.058][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:40.335][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:40.619][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:40.908][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:41.188][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:41.191][D][modbus_controller:038]: Modbus command to device=1 register=0x177A no response received - removed from send queue
[19:30:45.719][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:46.004][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:46.301][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:46.572][W][modbus:063]: Stop waiting for response from 1 256ms after last send
[19:30:46.857][W][modbus:063]: Stop waiting for response from 1 256ms after last send

Dann suchen wir mal weiter.

Viele Grüße

Guten Morgen

Der nächste Schritt ist erledigt. Ich habe gestern die komplette Verkabelung (auch die vom Elektriker am Stromzähler) noch einmal abgenommen und neu aufgelegt. Nachdem ich dann die yaml nochmal geprüft habe und ein paar Kleinigkeiten angepasst habe sieht das Ergebnis nun so aus:

Ich bekomme also nun statt “Unknown” nur “0”.

Die yaml sieht nun so aus:

esphome:
  name: stromwp
  friendly_name: stromwp

esp32:
  board: esp32dev
  framework:
    type: esp-idf

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "itOMt6ygXDBtwBNLRnT8Lwzzq9rP3YtsgYjX1u0+El4="

ota:
  - platform: esphome
    password: "e9e11152e8db62036fe051f9494c7885"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Stromwp Fallback Hotspot"
    password: "mmTqxD6mh9uM"

uart:
  id: modbus_uart
  tx_pin: GPIO17 #blau rxd geht auf 16
  rx_pin: GPIO16 #schwarz txd geht auf 17
  baud_rate: 9600
  data_bits: 8
  parity: EVEN
  stop_bits: 1

modbus:
  id: modbus1
  send_wait_time: 600ms #von https://github.com/esphome/issues/issues/6633
  turnaround_time: 100ms #von https://github.com/esphome/issues/issues/6633

modbus_controller:
  - id: qtgdsz01
    address: 1
    modbus_id: modbus1
    update_interval: 10s
    setup_priority: -10

sensor:

  # Gesamtenergie
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Gesamtenergie"
    id: total_energy
    register_type: holding
    address: 5999
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtwirkenergie vorwärts
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Wirkenergie Vorwärts"
    address: 6009
    register_type: holding
    value_type: FP32
    unit_of_measurement: "kWh"
    device_class: energy
    state_class: total_increasing
    accuracy_decimals: 2

  # Gesamtleistung
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Leistung"
    id: total_power
    register_type: holding
    address: 5011
    value_type: FP32
    unit_of_measurement: "kW"
    device_class: power
    state_class: measurement
    accuracy_decimals: 2

  # Spannung L1
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L1"
    register_type: holding
    address: 5001
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L2
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L2"
    register_type: holding
    address: 5003
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Spannung L3
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Spannung L3"
    register_type: holding
    address: 5005
    value_type: FP32
    unit_of_measurement: "V"
    device_class: voltage
    state_class: measurement
    accuracy_decimals: 1

  # Strom gesamt
  - platform: modbus_controller
    modbus_controller_id: qtgdsz01
    name: "Strom Gesamt"
    register_type: holding
    address: 5007
    value_type: FP32
    unit_of_measurement: "A"
    device_class: current
    state_class: measurement
    accuracy_decimals: 2

Das Log sieht wie folgt aus:

[092045.734][W][modbus417] Clearing buffer of 17 bytes - timeout after partial response 60ms after last send
[092045.781][C][mdns230] mDNS
[092045.781][C][mdns230]   Hostname stromwp
[092045.782][C][modbus_controller309] ModbusController
[092045.782][C][modbus_controller309]   Address 0x01
[092045.782][C][modbus_controller309]   Max Command Retries 4
[092045.782][C][modbus_controller309]   Offline Skip Updates 0
[092046.282][W][modbus063] Stop waiting for response from 1 625ms after last send
[092046.342][W][modbus417] Clearing buffer of 8 bytes - timeout after partial response 27ms after last send
[092046.353][D][modbus_controller.sensor024] Sensor new state 0.00
[092046.451][S][sensor] 'Leistung'  0.00 kW
[092046.497][W][modbus417] Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[092047.075][W][modbus063] Stop waiting for response from 1 626ms after last send
[092047.123][W][modbus417] Clearing buffer of 8 bytes - timeout after partial response 27ms after last send
[092047.160][D][modbus_controller.sensor024] Sensor new state 0.00
[092047.247][S][sensor] 'Gesamtenergie'  0.00 kWh
[092047.293][W][modbus417] Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[092047.857][W][modbus063] Stop waiting for response from 1 611ms after last send
[092047.903][W][modbus417] Clearing buffer of 8 bytes - timeout after partial response 27ms after last send
[092047.925][D][modbus_controller.sensor024] Sensor new state 0.00
[092048.041][S][sensor] 'Wirkenergie Vorwärts'  0.00 kWh
[092053.614][W][modbus417] Clearing buffer of 8 bytes - timeout after partial response 27ms after last send
[092053.645][D][modbus_controller.sensor024] Sensor new state 0.00
[092053.651][D][modbus_controller.sensor024] Sensor new state 0.00
[092053.651][D][modbus_controller.sensor024] Sensor new state 0.00
[092053.655][D][modbus_controller.sensor024] Sensor new state 0.00
[092053.748][S][sensor] 'Spannung L1'  0.0 V
[092053.748][S][sensor] 'Spannung L2'  0.0 V
[092053.749][S][sensor] 'Spannung L3'  0.0 V
[092053.750][S][sensor] 'Strom Gesamt'  0.00 A

Dann suchen wir mal weiter.

Viele Grüße

Schon mal so versucht?

modbus_controller:
  - id: qtgdsz01
    address: 0x01
    modbus_id: modbus1
    update_interval: 10s
    setup_priority: -10

Oder das mal versuchen.:

uart:
  id: modbus_uart
  tx_pin: GPIO4
  rx_pin: GPIO5
  baud_rate: 9600
  data_bits: 8
  parity: NONE
  stop_bits: 1

GPIO16 wird meist vom ESP32 intern genutzt. Parity mal auf “NONE” einstellen.

beim Bauen kommt auch bestimmt eine Warnung bezüglich “Wifi”. Der Eintrag müsste so aussehen.:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  min_auth_mode: WPA2

Hat zwar nichts mit deinem Problem zu tun. Aber eine Warnung weniger beim Bauen, macht es auch übersichtlicher.

Jetzt ja, aber leider kein anderes Ergebnis.

Wenn ich GPIO05 verwende bekomme ich eine Warnung. Ebenfalls keine Ergebnisse.

parity: EVEN

Muss korrekt sein, ändere ich nur das auf NONEdann bekomme ich in den Geräten wieder “UNBEKANNT” statt “0”.

Bekomme eine Warnung das ich weder captive_portal noch web… configuriert habe. Müsste ich mich schlau machen wenn ich nun erstmal die Werte ausgelesen bekomme.

Ich denke, dass ich heute Abend nochmal A und B tausche, evtl. ist das ja das Problem. Man liest verschiedene Hinweise das A auf A soll oder manchmal auch A auf B.

Ich hatte letzte Woche ein ähnliches Problem. Hab dann die komplette Yaml von einer KI bearbeiten lassen. Nach etwas hin und her hat es dann funktioniert. Ich habe eine SDM630 Emulation für Growatt WR gebastelt.

Guten Morgen,

das mache ich tatsächlich parallel mit ChatGPT. Gibt einem tatsächlich mal gute Ideen.
Ich habe gestern A B getauscht, dann kommt wieder “Unbekannt” heraus - sprich das ist richtig. Danach wieder umgedreht und nun sieht das log so aus:

[07:49:17.523][S][sensor]: 'Spannung L3' >> 0.0 V
[07:49:17.523][S][sensor]: 'Strom Gesamt' >> 0.00 A
[07:49:17.557][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:17.656][S][sensor]: 'Leistung' >> 0.00 kW
[07:49:17.704][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:17.805][S][sensor]: 'Gesamtenergie' >> 0.00 kWh
[07:49:17.854][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:17.970][S][sensor]: 'Wirkenergie Vorwärts' >> 0.00 kWh
[07:49:27.110][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.208][S][sensor]: 'Spannung L1' >> 0.0 V
[07:49:27.258][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.355][S][sensor]: 'Spannung L2' >> 0.0 V
[07:49:27.410][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.413][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.513][S][sensor]: 'Spannung L3' >> 0.0 V
[07:49:27.513][S][sensor]: 'Strom Gesamt' >> 0.00 A
[07:49:27.559][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.661][S][sensor]: 'Leistung' >> 0.00 kW
[07:49:27.717][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.822][S][sensor]: 'Gesamtenergie' >> 0.00 kWh
[07:49:27.858][D][modbus_controller.sensor:024]: Sensor new state: 0.00
[07:49:27.960][S][sensor]: 'Wirkenergie Vorwärts' >> 0.00 kWh

Also keine Warnungen mehr. Nun bleibt es trotzdem “0”.

Bei den Registern habe ich schon zum Beispiel 5999 statt 6000 versucht.

Auf jeden Fall machen wir kleine Fortschritte.

Viele Grüße

Edit:

Es ist verrückt. Nun habe ich 1x debug in der yaml “an” gemacht, und danach wieder die letzte yaml gelanden. Nun sieht es wieder so aus:

[08:45:11.981][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:12.543][W][modbus:063]: Stop waiting for response from 1 611ms after last send
[08:45:12.611][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 48ms after last send
[08:45:13.174][W][modbus:063]: Stop waiting for response from 1 611ms after last send
[08:45:13.241][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:13.823][W][modbus:063]: Stop waiting for response from 1 626ms after last send
[08:45:13.886][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:14.466][W][modbus:063]: Stop waiting for response from 1 626ms after last send
[08:45:14.541][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 48ms after last send
[08:45:15.099][W][modbus:063]: Stop waiting for response from 1 611ms after last send
[08:45:15.116][W][modbus_controller:026]: Modbus device=1 set offline
[08:45:15.119][D][modbus_controller:038]: Modbus command to device=1 register=0x1389 no response received - removed from send queue
[08:45:15.184][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:15.769][W][modbus:063]: Stop waiting for response from 1 626ms after last send
[08:45:15.830][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:16.410][W][modbus:063]: Stop waiting for response from 1 626ms after last send
[08:45:16.483][W][modbus:417]: Clearing buffer of 17 bytes - timeout after partial response 47ms after last send
[08:45:17.055][W][modbus:063]: Stop waiting for response from 1 626ms after last send
[08:45:17.101][W][modbus:417]: Clearing buffer of 8 bytes - timeout after partial response 27ms after last send
[08:45:17.106][W][modbus_controller:068]: Modbus device=1 back online
[08:45:17.126][D][modbus_controller.sensor:024]: Sensor new state: 0.00

Ich werde verrückt.

Ich habe die besten Erfahrungen mit Google Gemini gemacht. Chatgpt kürzt gerne mal die Yaml. Auch Copilot von MS ist ganz brauchbar. Ich habe immer Auszüge vom Log an die KI geschickt bis die Fehler ausgemerzt waren. Auch habe ich die KI immer die ganze Yaml schreiben lassen, um Fehler wie zum Beispiel Tabs zu vermeiden. Auch wenn beim Bauen Fehler oder Warnungen aufgetreten sind, habe ich diese zur KI geschickt.

Dieses kleine Gimik hat komplett Gemini programmiert.

1 „Gefällt mir“

Was hat es denn mit dem

flow_control_pin: GPIO4 # ← DE/RE hier anschließen

auf sich? Den habe ich ja gar nicht?

Oder sollte ich auf die vorhandene S0 Schnittele gehen?

Kommentier den mal mit einer # aus. Kann sein dass dies schon das Problem ist. Den braucht man nicht immer. Stand bei mir auch in der yaml. Hab ich einfach auskommentiert, weil ich den Anschluss auch nicht habe.

Kann es sein das bei dir unter “modbus”, die uart_id fehlt? Müsste das nicht so aussehen?

modbus:
  - uart_id: modbus_uart
    id: modbus1
    send_wait_time: 600ms #von https://github.com/esphome/issues/issues/6633
    turnaround_time: 100ms #von https://github.com/esphome/issues/issues/6633

Ich habe ja keinen flow_control_pin - daher steht der auch nicht in der yaml.

Also eine uart_id kann ich nicht eintragen:

Nicht bei uart eintragen. So wie ich es oben gepostet habe. Unter “modbus” die Zeile “- uart_id: modbus_uart” eintragen.

So mal nebenbei. Finde den Fehler.

Logisch gibt es Mecker wenn du GPIO05 schreibst. Es heißt ja auch GPIO5!

Aber egal. Daran wird es schon nicht liegen.

Ah stimmt. Aber ist nicht so.
Wie oben geschrieben sieht die yaml ja so aus:

uart:
  id: modbus_uart
  tx_pin: GPIO17
  rx_pin: GPIO16
  baud_rate: 9600
  parity: NONE
  stop_bits: 1


modbus:
  id: modbus1
  uart_id: modbus_uart

Der wird auch nur für das Modell hier benötigt, DE und RE werden dann gebrückt und kommen an den flow_control_pin

für dieses Modell nicht


:wink:

Ich habe nun nochmal ein anderes Modul bestellt.
Irgendwie muss ich ja mal zum Ende kommen.

Oder ist ein Auslesen über die S0 Schnittstelle sinnvoller?

Welchen Stromzähler hast du denn?

Hast du denn auch mal RX/TX Getauscht?

Im ersten Post sind die Links zu den Anleitungen und der Modbus Tabelle.
Ja habe ich gemacht, dann kommt “Unknown” statt “0”