rt1970
(Rene T.)
August 23, 2022, 7:57am
1
Hi
I have 10 pieces PZEM-004T as energy monitor.
Sometimes 2-3 PZEMs fail. Restart usually helps.
In the log file this yellow message:
'Modbus CRC check failed! 4C65!=1404
Does anyone know the problem?
1 Like
Does anyone know your wiring/yaml
?
rt1970
(Rene T.)
August 24, 2022, 6:36pm
3
uart:
id: uart1
tx_pin: D2
rx_pin: D1
baud_rate: 9600
# debug:
modbus:
- id: mod_bus_pzem1
send_wait_time: 250ms
uart_id: uart1
sensor:
- platform: pzemac
id: Strom_Gesamt
current:
name: "Strom Gesamt"
voltage:
name: "Spannung Gesamt"
energy:
name: "Energie Gesamt"
power:
name: "Leistung Gesamt"
frequency:
name: "Frequenz Gesamt"
power_factor:
name: "Power Factor Gesamt"
update_interval: 10s
address: 1
modbus_id: mod_bus_pzem1
- platform: pzemac
id: Strom_Aussen
current:
name: "Strom Aussen"
# voltage:
# name: "Spannung Aussen"
energy:
name: "Energie Aussen"
power:
name: "Leistung Aussen"
# frequency:
# name: "Frequenz Aussen"
# power_factor:
# name: "Power Factor Aussen"
update_interval: 10s
address: 2
modbus_id: mod_bus_pzem1
etc.
PIN D2 is on an OptoCoupler PC 817 to RX from PZEM.
PIN D1 is on TX from PZEM.
All PZEM parallel.
No diodes on the TX’s from each pzem in your setup?
rt1970
(Rene T.)
August 25, 2022, 10:15am
5
Sorry. Yes. Every PZEM have diode to TX. But no resistor to 5V
My Optocoupler are 2 pcs parallel (one over other)
rt1970:
But no resistor to 5V
Maybe you could try to add one and see if it helps?
I wonder if they always the same ones or always “random” ones?
I also see you have no stop_bits
(default is 1
) in your uart
defined. Some users claim setting it to 2
helps with the CRC check failed
opened 04:19PM - 25 Oct 21 UTC
closed 12:05AM - 06 Nov 23 UTC
integration: pzemac
### The problem
Access more than 4 PZEM-004T V3 at the same time,The data wi… ll not be read.
I set different addresses for each pzem.
No more than 4 pzem, everything is normal,Once more than 4, the data will not be read at all.
### Which version of ESPHome has the issue?
ESPHome 2021.8.0
### What type of installation are you using?
Docker
### Which version of Home Assistant has the issue?
2021.9
### What platform are you using?
ESP32 and ESP8266
### Board
nodemcu
### Component causing the issue
pzem-004T V3
### Example YAML snippet
```yaml
substitutions:
device_name: energy-centerpcroom
esphome:
name: ${device_name}
platform: ESP8266
board: nodemcuv2
logger:
baud_rate: 0 # (UART logging interferes with pzem)
level: DEBUG
# Enable Home Assistant API
api:
password: "xx"
ota:
password: "xx"
web_server:
port: 80
wifi:
ssid: "xx"
password: "xx"
fast_connect: true
use_address: 10.253.12.253
manual_ip:
static_ip: 10.253.12.253
gateway: 10.253.12.1
subnet: 255.255.255.0
dns1: 192.168.250.3
ap:
ssid: "esp32-centerpcroom"
password: "8888888888"
captive_portal:
uart:
- tx_pin: D1
rx_pin: D2
baud_rate: 9600
stop_bits: 1
modbus:
binary_sensor:
- platform: status
name: "${device_name} Status"
sensor:
- platform: pzemac
id: pzemac1
energy:
name: "energy_ac1"
id: "energy_ac1"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac1"
id: "current_ac1"
accuracy_decimals: 1
voltage:
name: "voltage_ac1"
id: "voltage_ac1"
filters:
- multiply: 1
accuracy_decimals: 1
frequency:
name: "frequency_ac1"
id: "frequency_ac1"
accuracy_decimals: 1
power_factor:
name: "factor_ac1"
id: "factor_ac1"
accuracy_decimals: 1
power:
name: "power_ac1"
id: "power_ac1"
filters:
- multiply: 1
accuracy_decimals: 0
update_interval: never
address: 1
- platform: pzemac
id: pzemac2
energy:
name: "energy_ac2"
id: "energy_ac2"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac2"
id: "current_ac2"
accuracy_decimals: 1
voltage:
name: "voltage_ac2"
id: "voltage_ac2"
filters:
- multiply: 1
accuracy_decimals: 1
frequency:
name: "frequency_ac2"
id: "frequency_ac2"
accuracy_decimals: 1
power_factor:
name: "factor_ac2"
id: "factor_ac2"
accuracy_decimals: 1
power:
name: "power_ac2"
id: "power_ac2"
filters:
- multiply: 1
accuracy_decimals: 0
update_interval: never
address: 2
- platform: pzemac
id: pzemac3
energy:
name: "energy_ac3"
id: "energy_ac3"
filters:
- multiply: 0.002
unit_of_measurement: kWh
accuracy_decimals: 1
current:
name: "current_ac3"
id: "current_ac3"
accuracy_decimals: 1
voltage:
name: "voltage_ac3"
id: "voltage_ac3"
filters:
- multiply: 1
accuracy_decimals: 1
frequency:
name: "frequency_ac3"
id: "frequency_ac3"
accuracy_decimals: 1
power_factor:
name: "factor_ac3"
id: "factor_ac3"
accuracy_decimals: 1
power:
name: "power_ac3"
id: "power_ac3"
filters:
- multiply: 1
accuracy_decimals: 0
update_interval: never
address: 3
- platform: total_daily_energy
name: "energy_ac1_daily"
power_id: power_ac1
id: energy_ac1_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac2_daily"
power_id: power_ac2
id: energy_ac2_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: total_daily_energy
name: "energy_ac3_daily"
power_id: power_ac3
id: energy_ac3_daily
unit_of_measurement: kWh
accuracy_decimals: 1
icon: mdi:counter
filters:
- multiply: 0.001
- platform: template
name: "total_power"
id: "total_power"
device_class: power
state_class: measurement
unit_of_measurement: W
accuracy_decimals: 1
lambda: |-
return id(power_ac1).state + id(power_ac2).state + id(power_ac3).state ;
- platform: template
name: "energy_total_daily"
id: "energy_total_daily"
icon: mdi:counter
device_class: energy
state_class: measurement
unit_of_measurement: kWh
accuracy_decimals: 1
lambda: |-
return id(energy_ac1_daily).state + id(energy_ac2_daily).state + id(energy_ac3_daily).state ;
time:
- platform: homeassistant
id: homeassistant_time
switch:
- platform: restart
name: "${device_name}_Restart"
- platform: uart
name: "${device_name}_Reset"
data: [0x01, 0x42, 0x80, 0x11]
interval:
- interval: 5s
then:
- delay: 150ms
- lambda: "id(pzemac1).update();"
- delay: 150ms
- lambda: "id(pzemac2).update();"
- delay: 150ms
- lambda: "id(pzemac3).update();"
```
```
### Anything in the logs that might be useful for us?
_No response_
### Additional information
![c1504ab8e85a0d774dc5a5573608ba6](https://user-images.githubusercontent.com/33926386/138834952-2b533466-9f6f-4905-a159-33397f29c7bc.jpg)
rt1970
(Rene T.)
August 25, 2022, 2:21pm
8
Stop_bits: 2 → only CRC error and no data!
“…more then 4…”
that problem is no data. my problem is sometime no data and sometime any CRC-Error.
I thing i should use a 1.5 Amps PNP Transistor S8550 instead optocoupler…
Looks like my first try. 1 to 4 no problem. Direct connected.
Then 5 to … = no Data.
More then 4 with one optocoupler many CRC-Error´s.
Now two optocoupler parallel sometime CRC-error´s
rt1970:
“…more then 4…”
So 4 pzem always work stable? And as soon you have more you always experiencing some sort of problems - right?
I was wondering anyways that you have 10 pzem connected to one esp82xx, I had in mind there was kind of a hard limit… but by the looks of it there isn’t - beside some unstable experiences
Another thing which might be worth trying is to use more than one uart
bus. For example hook 4 pzem’s up to one uart
bus and another 4 to another bus and another for the rest?
rt1970
(Rene T.)
August 25, 2022, 3:19pm
10
I have try 4 pcs testet for 10min. without problems.
Limit? I dont know. I have used adress 1 to 11.
Why should i use 2 uart and modbusses?
Just to see if you can avoid the problems you have… like a work’a’round (having more than 4 pzem connected to a esp but still have it stable and not throwing CRC failures and stop sending data)
rt1970
(Rene T.)
August 25, 2022, 3:50pm
12
I understand. I think the problem ist not software. I think the problem is power consumption from optocoupler in the PZEM´s oder Timing problem.
a little more timeout from adress to adress maybe…
1 Like
Hi
Were you able to solve your problem?
If the answer is yes, how?
rt1970
(Rene T.)
April 25, 2024, 8:12am
14
My last Version is 2 optocoupler on top of each other for RX Optocoupler.
The Optocoupler goes to 5V and R8 from PZEM i have 500 Ohm.
Look here:
HOWTO control PZEM-004t · arendst/Tasmota · Discussion #10567 (github.com)
BTW: Sometime are 2 or 3 not available. Then i must restart ESP. Sometime 2 or 3 times.