esphome / feature-requests

ESPHome Feature Request Tracker
https://esphome.io/
406 stars 26 forks source link

Problem with interfacing 3x PZEM004T V1.0 modules to a WT32-ETH01 board. #2241

Closed tux-at-chello closed 1 year ago

tux-at-chello commented 1 year ago

In the past we used an Arduino Mega with an ethernet shield an 3 comports to interface 3 PZEM004T V1.0 modules and an Arduino based self written program to transfer data from a 3 phase solar panel array into a crestron controller to generate some data and graphs about the production of this 40 panel solar array.

Now in the days of ESPHome and Home Assistant we decided to convert these measuring modules over to an WT32-ETH01 module, just for the reason of multiple serial ports and intergrated ethernet, making it a hard wired interface and avoiding WiFi traffic at a high load due to the frequent repeat of the measurements.

For this purpose I defined 3 serial ports on the WT32-ETH01, using the 'receive only' ports as the RX ports of the construction, leading up to the following layout.

Phase L1 : TX data on GPIO 17, RX data on GPIO05 Phase L2 : TX data on GPIO 13, RX data on GPIO35 Phase L3 : TX data on GPIO 15, RX data on GPIO36

Standard TX0 and RX0 are left free, to be able to program the unit via serial protocol in case the ethernet interface fails and 'OTE' ( over the Ethernet ) is not available.

For testing purposes I have 2 push buttons to ground on GPIO2 and GPIO4 to have some inputs to play around with ( and testing connectivity to ESPhome ) in further projects.

This gives me the following YAML file.

substitutions:
  devicename: eth01
  long_devicename: eth01

esphome:
  name: eth01

esp32:
  board: esp-wrover-kit
  framework:
    type: arduino

//# Enable logging
logger:

//# Enable Home Assistant API
api:
  password: ""

ota:
  password: ""

web_server:
  port: 80

ethernet:
  type: LAN8720
  mdc_pin: GPIO23
  mdio_pin: GPIO18
  clk_mode: GPIO0_IN
  phy_addr: 1
  power_pin: GPIO16

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: True
    name: "$long_devicename button_1"
    on_press:
      - logger.log: "$long_devicename button_1"
  - platform: gpio
    pin:
      number: GPIO4
      mode: INPUT_PULLUP
      inverted: True
    name: "$long_devicename button_2"
    on_press:
      - logger.log: "$long_devicename button_2"

uart:
  - id: uart_bus_L1
//#    tx_pin: GPIO17
//#    rx_pin: GPIO5
//#    tx_pin: GPIO12
//#    rx_pin: GPIO35
    tx_pin: GPIO15
    rx_pin: GPIO36
    baud_rate: 9600

  - id: uart_bus_L2
//#    tx_pin: GPIO17
//#    rx_pin: GPIO5
    tx_pin: GPIO12
    rx_pin: GPIO35
//#    tx_pin: GPIO15
//#    rx_pin: GPIO36
    baud_rate: 9600

  - id: uart_bus_L3
    tx_pin: GPIO17
    rx_pin: GPIO5
//#    tx_pin: GPIO12
//#    rx_pin: GPIO35
//#    tx_pin: GPIO15
//#    rx_pin: GPIO36
    baud_rate: 9600

sensor:
  - platform: pzem004t
    uart_id: uart_bus_L1
    voltage:
      name: "PZEM-004T Voltage L1"
      filters:
//        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 230.0 -> 217.0
            - 240.0 -> 230.0
            - 250.0 -> 243.0
    current:
      name: "PZEM-004T Current L1"
    power:
      name: "PZEM-004T Power L1"
    energy:
      name: "PZEM-004T Energy L1"
    update_interval: 10s

  - platform: pzem004t
    uart_id: uart_bus_L2
    voltage:
      name: "PZEM-004T Voltage L2"
      filters:
//        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 230.0 -> 217.0
            - 240.0 -> 230.0
            - 250.0 -> 243.0
    current:
      name: "PZEM-004T Current L2"
    power:
      name: "PZEM-004T Power L2"
    energy:
      name: "PZEM-004T Energy L2"
    update_interval: 10s

  - platform: pzem004t
    uart_id: uart_bus_L3
    voltage:
      name: "PZEM-004T Voltage L3"
      filters:
//        # Map from sensor -> measured value
        - calibrate_linear:
            - 0.0 -> 0.0
            - 230.0 -> 217.0
            - 240.0 -> 230.0
            - 250.0 -> 243.0
    current:
      name: "PZEM-004T Current L3"
    power:
      name: "PZEM-004T Power L3"
    energy:
      name: "PZEM-004T Energy L3"
    update_interval: 10s

For testing I only have one PZEM004T V1.0 module available and this one is connected to GPIO17 and GPIO 5

What I see and measure is that if this module is configured at the 3rd defined uart, 'uart_bus_L3', is does not work properly, as when it is defined at 'uart_bus_L1' or 'uart_bus_L2' the module starts responding data immediately. You can see that I tested with the several com poorts using the '#' to enable or disable the different GPIO pins on the board.

I connected a TTL to USB serial converter on the RX data of the GPIO05 to see the response received from the PZEM004T module on the differend uart definitions and found the following:

If defined to the first or second uart defined, the module gets all the 4 required request out of the TX data and responds accordingly, making it a working module for ESPHome and reporting the 'voltage', 'current', 'power' and 'energy' telegrams as requested.

On the serial interface I receive in decimal the following data out of the PZEM004 module: 160 0 236 7 0 0 147 161 0 0 0 0 0 161 162 0 0 0 0 0 162 163 114 60 25 0 0 105

Where 160 ( 0xA0 ) is measured voltage and 163 ( 0xA03 ) is registered Wh of this module. ( yes these panels were active over there : 7.486.489 Wh ! and this ony one phase ...)

If defined to the third uart ( uart_bus_L3 ) the software only transmits the 'voltage' request to the PZEM004 module: this responds accordingly and reports the measured voltage. Due to the fact that not all 4 telegrams are answered, ESPHome does not send this single response to Home Automation, thereby declaring this interface 'not working'.

On the seial interface I receive in decimal the following data : 160 0 236 7 0 0 147 160 0 237 3 0 0 144 160 0 237 1 0 0 143 160 0 236 9 0 0 149

where '160' is 'answer voltage' ( Hex 0xA0 ) followed by the measured voltage of 236.7 Volt.

If I swap the uart sub definition of 'uart_bus_L2' and 'uart_bus_L3' making L3 the second uart definition on GPIO17 and GPIO05, this port is fully operational.

The 'esphome run PZEM.yaml' compiles without any error in any configuration and the log of the WT32-ETH01 at boot when connecting to HA show the GPIO lines as defined in the YAML file : that part works fine in all configurations.

We now assume after several days of testing and debugging that there is something going wrong in defining the 3rd uart on the software and therefore the PZEM software module for this serial port is not working properly.

esphome is upgraded to version 2023.4.4 last night and code is compiled to this version.

INFO Starting log output from eth01.local using esphome API
INFO Successfully connected to eth01.local
[21:53:38][I][app:102]: ESPHome version 2023.4.4 compiled on May 13 2023, 22:06:27
[21:53:38][C][logger:294]: Logger:
[21:53:38][C][logger:295]:   Level: DEBUG
[21:53:38][C][logger:296]:   Log Baud Rate: 115200
[21:53:38][C][logger:297]:   Hardware UART: UART0
[21:53:38][C][uart.arduino_esp32:108]: UART Bus 1:
[21:53:38][C][uart.arduino_esp32:109]:   TX Pin: GPIO15
[21:53:38][C][uart.arduino_esp32:110]:   RX Pin: GPIO36
[21:53:38][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:53:38][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:53:38][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:53:38][C][uart.arduino_esp32:116]:   Parity: NONE
[21:53:38][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:53:38][C][uart.arduino_esp32:108]: UART Bus 2:
[21:53:38][C][uart.arduino_esp32:109]:   TX Pin: GPIO12
[21:53:38][C][uart.arduino_esp32:110]:   RX Pin: GPIO35
[21:53:38][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:53:38][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:53:38][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:53:38][C][uart.arduino_esp32:116]:   Parity: NONE
[21:53:38][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:53:38][C][uart.arduino_esp32:108]: UART Bus 3:
[21:53:38][C][uart.arduino_esp32:109]:   TX Pin: GPIO17
[21:53:38][C][uart.arduino_esp32:110]:   RX Pin: GPIO5
[21:53:38][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:53:38][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:53:38][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:53:38][C][uart.arduino_esp32:116]:   Parity: NONE
[21:53:38][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:53:38][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'eth01 button_1'
[21:53:38][C][gpio.binary_sensor:016]:   Pin: GPIO2
[21:53:38][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'eth01 button_2'
[21:53:38][C][gpio.binary_sensor:016]:   Pin: GPIO4
[21:53:38][C][pzem004t:118]: PZEM004T:
[21:53:38][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L1'
[21:53:38][C][pzem004t:119]:   Device Class: 'voltage'
[21:53:38][C][pzem004t:119]:   State Class: 'measurement'
[21:53:38][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:53:38][C][pzem004t:119]:   Accuracy Decimals: 1
[21:53:38][C][pzem004t:120]: Current 'PZEM-004T Current L1'
[21:53:38][C][pzem004t:120]:   Device Class: 'current'
[21:53:38][C][pzem004t:120]:   State Class: 'measurement'
[21:53:38][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:53:38][C][pzem004t:120]:   Accuracy Decimals: 2
[21:53:38][C][pzem004t:121]: Power 'PZEM-004T Power L1'
[21:53:38][C][pzem004t:121]:   Device Class: 'power'
[21:53:38][C][pzem004t:121]:   State Class: 'measurement'
[21:53:38][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:53:38][C][pzem004t:121]:   Accuracy Decimals: 0
[21:53:38][C][pzem004t:118]: PZEM004T:
[21:53:38][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L2'
[21:53:38][C][pzem004t:119]:   Device Class: 'voltage'
[21:53:38][C][pzem004t:119]:   State Class: 'measurement'
[21:53:38][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:53:38][C][pzem004t:119]:   Accuracy Decimals: 1
[21:53:38][C][pzem004t:120]: Current 'PZEM-004T Current L2'
[21:53:38][C][pzem004t:120]:   Device Class: 'current'
[21:53:38][C][pzem004t:120]:   State Class: 'measurement'
[21:53:38][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:53:38][C][pzem004t:120]:   Accuracy Decimals: 2
[21:53:38][C][pzem004t:121]: Power 'PZEM-004T Power L2'
[21:53:38][C][pzem004t:121]:   Device Class: 'power'
[21:53:38][C][pzem004t:121]:   State Class: 'measurement'
[21:53:38][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:53:38][C][pzem004t:121]:   Accuracy Decimals: 0
[21:53:38][C][pzem004t:118]: PZEM004T:
[21:53:38][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L3'
[21:53:38][C][pzem004t:119]:   Device Class: 'voltage'
[21:53:38][C][pzem004t:119]:   State Class: 'measurement'
[21:53:38][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:53:38][C][pzem004t:119]:   Accuracy Decimals: 1
[21:53:38][C][pzem004t:120]: Current 'PZEM-004T Current L3'
[21:53:38][C][pzem004t:120]:   Device Class: 'current'
[21:53:38][C][pzem004t:120]:   State Class: 'measurement'
[21:53:38][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:53:38][C][pzem004t:120]:   Accuracy Decimals: 2
[21:53:38][C][pzem004t:121]: Power 'PZEM-004T Power L3'
[21:53:38][C][pzem004t:121]:   Device Class: 'power'
[21:53:38][C][pzem004t:121]:   State Class: 'measurement'
[21:53:38][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:53:38][C][pzem004t:121]:   Accuracy Decimals: 0
[21:53:38][C][ethernet:179]: Ethernet:
[21:53:38][C][ethernet:306]:   IP Address: aa.bb.cc.102
[21:53:38][C][ethernet:307]:   Hostname: 'eth01'
[21:53:38][C][ethernet:308]:   Subnet: 255.255.255.0
[21:53:38][C][ethernet:309]:   Gateway: aa.bb.cc.254
[21:53:38][C][ethernet:315]:   DNS1: 8.8.8.8
[21:53:38][C][ethernet:316]:   DNS2: 8.8.4.4
[21:53:38][C][ethernet:327]:   MAC Address: 90:38:0C:B1:77:1B
[21:53:38][C][ethernet:332]:   Is Full Duplex: YES
[21:53:38][C][ethernet:337]:   Link Speed: 100
[21:53:38][C][ethernet:182]:   Power Pin: 16
[21:53:38][C][ethernet:184]:   MDC Pin: 23
[21:53:38][C][ethernet:185]:   MDIO Pin: 18
[21:53:38][C][ethernet:186]:   Type: LAN8720
[21:53:38][C][ethernet:187]:   PHY addr: 1
[21:53:38][C][web_server:151]: Web Server:
[21:53:38][C][web_server:152]:   Address: eth01.local:80
[21:53:38][C][mdns:108]: mDNS:
[21:53:38][C][mdns:109]:   Hostname: eth01
[21:53:38][C][ota:093]: Over-The-Air Updates:
[21:53:38][C][ota:094]:   Address: eth01.local:3232
[21:53:38][C][api:138]: API Server:
[21:53:38][C][api:139]:   Address: eth01.local:6053
[21:53:38][C][api:143]:   Using noise encryption: NO

After changing the GPIO17 and GPIO05 to uart_bus_L1 is works directly:

[21:58:06][D][api.connection:961]: Home Assistant 2023.1.1 (aa.bb.cc.240): Connected successfully
[21:58:06][I][app:102]: ESPHome version 2023.4.4 compiled on May 14 2023, 21:56:38
[21:58:06][C][logger:294]: Logger:
[21:58:06][C][logger:295]:   Level: DEBUG
[21:58:06][C][logger:296]:   Log Baud Rate: 115200
[21:58:06][C][logger:297]:   Hardware UART: UART0
[21:58:06][C][uart.arduino_esp32:108]: UART Bus 1:
[21:58:06][C][uart.arduino_esp32:109]:   TX Pin: GPIO17
[21:58:06][C][uart.arduino_esp32:110]:   RX Pin: GPIO5
[21:58:06][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:58:06][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:58:06][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:58:06][C][uart.arduino_esp32:116]:   Parity: NONE
[21:58:06][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:58:06][C][uart.arduino_esp32:108]: UART Bus 2:
[21:58:06][C][uart.arduino_esp32:109]:   TX Pin: GPIO12
[21:58:06][C][uart.arduino_esp32:110]:   RX Pin: GPIO35
[21:58:06][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:58:06][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:58:06][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:58:06][C][uart.arduino_esp32:116]:   Parity: NONE
[21:58:06][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:58:06][C][uart.arduino_esp32:108]: UART Bus 3:
[21:58:06][C][uart.arduino_esp32:109]:   TX Pin: GPIO15
[21:58:06][C][uart.arduino_esp32:110]:   RX Pin: GPIO36
[21:58:06][C][uart.arduino_esp32:112]:   RX Buffer Size: 256
[21:58:06][C][uart.arduino_esp32:114]:   Baud Rate: 9600 baud
[21:58:06][C][uart.arduino_esp32:115]:   Data Bits: 8
[21:58:06][C][uart.arduino_esp32:116]:   Parity: NONE
[21:58:06][C][uart.arduino_esp32:117]:   Stop bits: 1
[21:58:06][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'eth01 button_1'
[21:58:06][C][gpio.binary_sensor:016]:   Pin: GPIO2
[21:58:06][C][gpio.binary_sensor:015]: GPIO Binary Sensor 'eth01 button_2'
[21:58:06][C][gpio.binary_sensor:016]:   Pin: GPIO4
[21:58:06][C][pzem004t:118]: PZEM004T:
[21:58:06][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L1'
[21:58:06][C][pzem004t:119]:   Device Class: 'voltage'
[21:58:06][C][pzem004t:119]:   State Class: 'measurement'
[21:58:06][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:58:06][C][pzem004t:119]:   Accuracy Decimals: 1
[21:58:06][C][pzem004t:120]: Current 'PZEM-004T Current L1'
[21:58:06][C][pzem004t:120]:   Device Class: 'current'
[21:58:06][C][pzem004t:120]:   State Class: 'measurement'
[21:58:06][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:58:06][C][pzem004t:120]:   Accuracy Decimals: 2
[21:58:06][C][pzem004t:121]: Power 'PZEM-004T Power L1'
[21:58:06][C][pzem004t:121]:   Device Class: 'power'
[21:58:06][C][pzem004t:121]:   State Class: 'measurement'
[21:58:06][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:58:06][C][pzem004t:121]:   Accuracy Decimals: 0
[21:58:06][C][pzem004t:118]: PZEM004T:
[21:58:07][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L2'
[21:58:07][C][pzem004t:119]:   Device Class: 'voltage'
[21:58:07][C][pzem004t:119]:   State Class: 'measurement'
[21:58:07][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:58:07][C][pzem004t:119]:   Accuracy Decimals: 1
[21:58:07][C][pzem004t:120]: Current 'PZEM-004T Current L2'
[21:58:07][C][pzem004t:120]:   Device Class: 'current'
[21:58:07][C][pzem004t:120]:   State Class: 'measurement'
[21:58:07][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:58:07][C][pzem004t:120]:   Accuracy Decimals: 2
[21:58:07][C][pzem004t:121]: Power 'PZEM-004T Power L2'
[21:58:07][C][pzem004t:121]:   Device Class: 'power'
[21:58:07][C][pzem004t:121]:   State Class: 'measurement'
[21:58:07][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:58:07][C][pzem004t:121]:   Accuracy Decimals: 0
[21:58:07][C][pzem004t:118]: PZEM004T:
[21:58:07][C][pzem004t:119]: Voltage 'PZEM-004T Voltage L3'
[21:58:07][C][pzem004t:119]:   Device Class: 'voltage'
[21:58:07][C][pzem004t:119]:   State Class: 'measurement'
[21:58:07][C][pzem004t:119]:   Unit of Measurement: 'V'
[21:58:07][C][pzem004t:119]:   Accuracy Decimals: 1
[21:58:07][C][pzem004t:120]: Current 'PZEM-004T Current L3'
[21:58:07][C][pzem004t:120]:   Device Class: 'current'
[21:58:07][C][pzem004t:120]:   State Class: 'measurement'
[21:58:07][C][pzem004t:120]:   Unit of Measurement: 'A'
[21:58:07][C][pzem004t:120]:   Accuracy Decimals: 2
[21:58:07][C][pzem004t:121]: Power 'PZEM-004T Power L3'
[21:58:07][C][pzem004t:121]:   Device Class: 'power'
[21:58:07][C][pzem004t:121]:   State Class: 'measurement'
[21:58:07][C][pzem004t:121]:   Unit of Measurement: 'W'
[21:58:07][C][pzem004t:121]:   Accuracy Decimals: 0
[21:58:07][C][ethernet:179]: Ethernet:
[21:58:07][C][ethernet:306]:   IP Address: aa.bb.cc.102
[21:58:07][C][ethernet:307]:   Hostname: 'eth01'
[21:58:07][C][ethernet:308]:   Subnet: 255.255.255.0
[21:58:07][C][ethernet:309]:   Gateway: aa.bb.cc.254
[21:58:07][C][ethernet:315]:   DNS1: 8.8.8.8
[21:58:07][C][ethernet:316]:   DNS2: 8.8.4.4
[21:58:07][C][ethernet:327]:   MAC Address: 90:38:0C:B1:77:1B
[21:58:07][C][ethernet:332]:   Is Full Duplex: YES
[21:58:07][C][ethernet:337]:   Link Speed: 100
[21:58:07][C][ethernet:182]:   Power Pin: 16
[21:58:07][C][ethernet:184]:   MDC Pin: 23
[21:58:07][C][ethernet:185]:   MDIO Pin: 18
[21:58:07][C][ethernet:186]:   Type: LAN8720
[21:58:07][C][ethernet:187]:   PHY addr: 1
[21:58:07][C][web_server:151]: Web Server:
[21:58:07][C][web_server:152]:   Address: eth01.local:80
[21:58:07][C][mdns:108]: mDNS:
[21:58:07][C][mdns:109]:   Hostname: eth01
[21:58:07][C][ota:093]: Over-The-Air Updates:
[21:58:07][C][ota:094]:   Address: eth01.local:3232
[21:58:07][C][api:138]: API Server:
[21:58:07][C][api:139]:   Address: eth01.local:6053
[21:58:07][C][api:143]:   Using noise encryption: NO
[21:58:07][D][sensor:110]: 'PZEM-004T Energy L1': Sending state 7486489.00000 Wh with 0 decimals of accuracy
[21:58:07][D][pzem004t:078]: Got Energy 7486489 Wh
[21:58:11][D][sensor:110]: 'PZEM-004T Voltage L1': Sending state 225.00696 V with 1 decimals of accuracy
[21:58:11][D][pzem004t:052]: Got Voltage 234.7 V
[21:58:12][D][sensor:110]: 'PZEM-004T Current L1': Sending state 0.00000 A with 2 decimals of accuracy
[21:58:12][D][pzem004t:061]: Got Current 0.00 A
[21:58:12][D][sensor:110]: 'PZEM-004T Power L1': Sending state 0.00000 W with 0 decimals of accuracy
[21:58:12][D][pzem004t:069]: Got Power 0 W
[21:58:13][D][sensor:110]: 'PZEM-004T Energy L1': Sending state 7486489.00000 Wh with 0 decimals of accuracy
[21:58:13][D][pzem004t:078]: Got Energy 7486489 Wh
[21:58:21][D][sensor:110]: 'PZEM-004T Voltage L1': Sending state 224.62300 V with 1 decimals of accuracy
[21:58:21][D][pzem004t:052]: Got Voltage 234.3 V
[21:58:22][D][sensor:110]: 'PZEM-004T Current L1': Sending state 0.00000 A with 2 decimals of accuracy
[21:58:22][D][pzem004t:061]: Got Current 0.00 A
[21:58:22][D][sensor:110]: 'PZEM-004T Power L1': Sending state 0.00000 W with 0 decimals of accuracy
[21:58:22][D][pzem004t:069]: Got Power 0 W
[21:58:23][D][sensor:110]: 'PZEM-004T Energy L1': Sending state 7486489.00000 Wh with 0 decimals of accuracy
[21:58:23][D][pzem004t:078]: Got Energy 7486489 Wh

Question : are we doing anything illegal to the WTH32-ETH01 or is anything else causing this problem ?

Kind regards from an enthousiastic group of 4 out of The Netherlands.

ssieb commented 1 year ago

An ESP32 has 3 hardware uarts and esphome doesn't support software serial on it. Previously, you could only use uart0 if you use the default pins (1 and 3), but that was fixed in the latest release, so if you upgrade esphome, it should work now.

tux-at-chello commented 1 year ago

Hello,

I did some testing today and found an error message on the serial debug port with the esphome version 2023.4.4 :

[15:44:26][I][app:029]: Running through setup()...
[15:44:26][C][uart.arduino_esp32:077]: Setting up UART...
[15:44:26][C][uart.arduino_esp32:077]: Setting up UART...
[15:44:26][C][uart.arduino_esp32:077]: Setting up UART...
[15:44:26][    68][E][HardwareSerial.cpp:309] begin(): Serial number is invalid, please use numers from 0 to 2

After upgrading to version 2023.5.1 and recompiling the code the message changed into :

[I][app:029]: Running through setup()...
[C][uart.arduino_esp32:077]: Setting up UART...
[C][uart.arduino_esp32:077]: Setting up UART...
[C][uart.arduino_esp32:077]: Setting up UART...
[W][uart.arduino_esp32:104]: Maximum number of UART components created already.
[E][component:113]: Component uart was marked as failed.

Even after I changed the tx and rx pins to GPIO1 and GPIO3 ( the debug port ) for the third UARD definition. So software-serial is ( still ) not implemented in esphome version 2023.5.1 and we are limited to two ports?

tux-at-chello commented 1 year ago

Sorry for the mess: this issue is still open !

ssieb commented 1 year ago

You have to disable the serial logging. There is no plan to add software serial to ESP32, there are 3 uarts available.