How to use PZEM004T Energy Monitor with esphome

where should i write this step .?

hass.io users: Add  `"esphome_version": "pzem004t"`  to your addon config

i also want to test my pzem004t , but i donno how to add pzem test support to my existing node with esphome .

Bump. Just bought a PZEM. Would like to see it on ESPHome :slight_smile:

If you have a pzem004t in Version 3 or newer you can already use it with esphome :man_superhero:

https://github.com/esphome/feature-requests/issues/49#issuecomment-521480331

But from what Iā€™ve read, itā€™s still unstableā€¦ Or have I misinterpreted something?

The integration from @OttoWinter for the pzem v1 and v2 does not yet work like it should. But the linked one for pzem v3 should do the job just fine.

The version are for different hardware revisions (printed on the board)

And how should we compile the linked version? It must be somehow inserted into the Addon container for it to be recognized and work. How should I do that?

I have been following the pzem topic and I have 2 pzem v3 running Tasmota, only because I dont understand how to configure the test environment in my hassioā€¦

Is it possible to use PZEM with the USB connection?

@Valentino_Stillhardt

If you open the linked issue (https://github.com/esphome/feature-requests/issues/49#issuecomment-521480331) itā€™s explained how you can use it with a local pip/python install. It just works and takes around 30 seconds of your time.

@xppx99

You donā€™t need the hassio addon for it. Just do a local pip install on your local machine and you are ready to goā€¦

@Hunty

USB and esphome? No! Why? What question is this?

1 Like

@orange-assistant
My question was about connecting PZEM using USB connection to Home assistant without esphome. I want to buy a PZEM and connect it directly to my nuc.

You will need a usb to ttl adapter and some software running on your nuc (depends on the OS). One more thing would be a script to publish the value to home assistant (for example with mqtt) or use a custom python script to poll the pzem004t from home assistantā€¦

Hi everyone,

Iā€™ve a problem and I donā€™t know how to go on, Iā€™ve been testing so much time but I cannot see any data in my HASS.

These are the connections that I have:

Regarding hardware:
I modified PZEM 004T v3 adding 1k resistor ( with a tester I verified a right voltage )
I connected correctly PZEM input Voltage cables and toroidal transformer to one the cables.
I connected D1-tx D2-rx 3V3-"5V"pzem GND-GND
I powered nodemcu with usb and give me 4,6V

Regarding software:
I followed all the steps and I properly installed ESPHOME in HASS
I also add new device and dowload firmware to nodemcu ( It appears as connected with good wifi signal )
I edited nodemcu device in ESPHOME User interface adding this:

esphome:
  name: consumo
  platform: ESP8266
  board: nodemcuv2

wifi:
  ssid: "MiFibra-0B4A"
  password: "6xxxxxx"

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

captive_portal:

# Enable logging
logger:

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

ota:
  password: "Cxxxxx"
  
# Example configuration entry

uart:
  rx_pin: D1
  tx_pin: D2
  baud_rate: 9600
  stop_bits: 2

sensor:
  - platform: pzemac
    current:
      name: "PZEM-004T V3 Current"
    voltage:
      name: "PZEM-004T V3 Voltage"
    power:
      name: "PZEM-004T V3 Power"
    frequency:
      name: "PZEM-004T V3 Frequency"
    power_factor:
      name: "PZEM-004T V3 Power Factor"
    update_interval: 1s

This is also what I see in nodemcu log with esphome:

> INFO Reading configuration /config/esphome/consumo.yaml...
> INFO Starting log output from consumo.local using esphome API
> INFO Connecting to consumo.local:6053 (192.168.1.20)
> INFO Successfully connected to consumo.local
> [11:38:26][I][app:100]: ESPHome version 1.14.2 compiled on Nov 17 2019, 21:52:21
> [11:38:26][C][wifi:409]: WiFi:
> [11:38:26][C][wifi:277]:   SSID: [redacted]
> [11:38:26][C][wifi:278]:   IP Address: 192.168.1.20
> [11:38:26][C][wifi:280]:   BSSID: [redacted]
> [11:38:26][C][wifi:281]:   Hostname: 'consumo'
> [11:38:26][C][wifi:285]:   Signal strength: -63 dB ā–‚ā–„ā–†ā–ˆ
> [11:38:26][C][wifi:289]:   Channel: 1
> [11:38:26][C][wifi:290]:   Subnet: 255.255.255.0
> [11:38:26][C][wifi:291]:   Gateway: 192.168.1.1
> [11:38:26][C][wifi:292]:   DNS1: 192.168.1.1
> [11:38:26][C][wifi:293]:   DNS2: (IP unset)
> [11:38:26][C][uart:145]: UART Bus:
> [11:38:26][C][uart:147]:   TX Pin: GPIO4
> [11:38:26][C][uart:150]:   RX Pin: GPIO5
> [11:38:26][C][uart:152]:   Baud Rate: 9600 baud
> [11:38:26][C][uart:153]:   Stop bits: 2
> [11:38:26][C][uart:157]:   Using software serial
> [11:38:26][C][modbus:096]: Modbus:
> [11:38:26][C][logger:175]: Logger:
> [11:38:26][C][logger:176]:   Level: DEBUG
> [11:38:26][C][logger:177]:   Log Baud Rate: 115200
> [11:38:26][C][logger:178]:   Hardware UART: UART0
> [11:38:26][C][pzemac:061]: PZEMAC:
> [11:38:26][C][pzemac:062]:   Address: 0x01
> [11:38:26][C][pzemac:063]: Voltage 'PZEM-004T V3 Voltage'
> [11:38:26][C][pzemac:063]:   Unit of Measurement: 'V'
> [11:38:26][C][pzemac:063]:   Accuracy Decimals: 1
> [11:38:26][C][pzemac:063]:   Icon: 'mdi:flash'
> [11:38:26][C][pzemac:064]: Current 'PZEM-004T V3 Current'
> [11:38:26][C][pzemac:064]:   Unit of Measurement: 'A'
> [11:38:26][C][pzemac:064]:   Accuracy Decimals: 3
> [11:38:26][C][pzemac:064]:   Icon: 'mdi:current-ac'
> [11:38:26][C][pzemac:065]: Power 'PZEM-004T V3 Power'
> [11:38:26][C][pzemac:065]:   Unit of Measurement: 'W'
> [11:38:26][C][pzemac:065]:   Accuracy Decimals: 1
> [11:38:26][C][pzemac:065]:   Icon: 'mdi:power'
> [11:38:26][C][pzemac:066]: Frequency 'PZEM-004T V3 Frequency'
> [11:38:26][C][pzemac:066]:   Unit of Measurement: ''
> [11:38:26][C][pzemac:066]:   Accuracy Decimals: 1
> [11:38:26][C][pzemac:066]:   Icon: 'mdi:current-ac'
> [11:38:26](Message skipped because it was too big to fit in TCP buffer - This is only cosmetic)
> [11:38:26][C][pzemac:067]:   Unit of Measurement: ''
> [11:38:26][C][pzemac:067]:   Accuracy Decimals: 2
> [11:38:26][C][pzemac:067]:   Icon: 'mdi:flash'
> [11:38:26][C][captive_portal:169]: Captive Portal:
> [11:38:26][C][ota:029]: Over-The-Air Updates:
> [11:38:26][C][ota:030]:   Address: consumo.local:8266
> [11:38:26][C][ota:032]:   Using Password.
> [11:38:26][C][api:095]: API Server:
> [11:38:26][C][api:096]:   Address: consumo.local:6053

I turn on a dryer connected but I cannot see any change in my hass panel:

image

It looks there is facing some problem in communications but I donā€™t know what.
I changed tx-rx cables, with the same result but I can see when I put interval time to 1 second is I can see in nodemcu and pzem blinking a led and if I change rt->tx I can see in pzem board 2 leds blinking.

Iā€™m quite desperate testing it for a long time.

Thanks for your help.
@orange-assistant @bpmittal

If you use ā€œSHOW LOGSā€ in esphome, do you get any cyan text after the log above ?

I see thereā€™s a typo on epshomes page, showing 2 rx pins:

uart:
  rx_pin: D1
  rx_pin: D2
  baud_rate: 9600
  stop_bits: 2

if you look at the v1 page is shows:

uart:
  tx_pin: D1
  rx_pin: D2
  baud_rate: 9600
  stop_bits: 2

Maybe try that ?

Looking at your wiring and the spec sheet, the +5V is a 5V input into the PZEM004T how are you powering it from 3.3v ? See this page:

https://primalcortex.wordpress.com/tag/pzem004t/

OK I found the 1K resistor hack online, sorry

You should be able to power the pzem with 5V. This should do the trick.

Hi,

this is what i see:

and yes, I changed rx -> tx

I donā€™t have one of these (YET - it is on order) but I do have another power monitoring device and the logs have this, it doesnā€™t look like ESP is getting any data
to send to HA ?

[12:14:53][C][captive_portal:169]: Captive Portal:
[12:14:53][C][ota:029]: Over-The-Air Updates:
[12:14:53][C][ota:030]:   Address: 192.168.1.48:8266
[12:14:53][C][api:095]: API Server:
[12:14:53][C][api:096]:   Address: 192.168.1.48:6053
[12:15:02][D][sensor:092]: 'DressingTable_Power': Sending state 0.66520 W with 1 decimals of accuracy
[12:15:02][D][sensor:092]: 'DressingTable_Total Daily Energy': Sending state 0.00908 kWh with 3 decimals of accuracy
[12:15:04][D][sensor:092]: 'DressingTable_Total Daily Cost': Sending state 0.12674 p with 0 decimals of accuracy
[12:15:12][D][hlw8012:063]: Got power=0.6W, current=7.6A
[12:15:12][D][sensor:092]: 'DressingTable_Power': Sending state 0.66520 W with 1 decimals of accuracy
[12:15:12][D][sensor:092]: 'DressingTable_Total Daily Energy': Sending state 0.00908 kWh with 3 decimals of accuracy
[12:15:22][D][hlw8012:063]: Got power=0.6W, current=7.6A
[12:15:22][D][sensor:092]: 'DressingTable_Power': Sending state 0.66520 W with 1 decimals of accuracy
[12:15:22][D][sensor:092]: 'DressingTable_Total Daily Energy': Sending state 0.00908 kWh with 3 decimals of accuracy

Hi @sendorm , I can power pzem with 4,6v coming form nodemcu VIN, but the result is the same.
Do i need 5V?

Think youā€™d need a level shifter not just a 5v supply to get the RX and TX pins to 5V also

https://primalcortex.wordpress.com/tag/pzem004t/

The 1k is there to fix that issue specifically. It obviates the need for a level shifter.

Yes I saw that (see my post above), you were saying to power if from 5V which would need a level shifter ?