Connect PZEM-016 Energy Meter (ModBus) to Home Assistant – part 2 (directly via RS485 to USB dongle)

In the first part, we described how to connect PZEM-016 ModBus energy monitor using RS485 to TTL converter and Wemos D1 mini board using ESPHome add-on. You can read about it here.

This post was updated to be compatible with latest Home Assistant 2021.7

Now, in the second part, we will show you how to connect PZEM-016 energy monitor using RS485 to USB dongle. This is an easier way to connect, but it requires laying the RS485 bus line to the Home Assistant server location.

The required components and wiring diagram are shown below:

pzem-016 rs485 usb

Plug RS485 to USB dongle into your Home Assistant 2021 server (my is core-2021.6.0, supervisor-2021.05.4, Home Assistant OS 5.13)

Add this code to your HA configuration.yaml file

modbus:
  - name: rs485usb
    type: serial
    method: rtu
    port: /dev/ttyUSB2
    baudrate: 9600
    stopbits: 1 
    bytesize: 8
    parity: N
    timeout: 1
    sensors:
      - name: HousePower_PhaseA_Voltage
        unit_of_measurement: V
        slave: 1
        address: 0
        input_type: input
        scale: 0.1
        offset: 0
        precision: 1
      - name: HousePower_PhaseA_Current
        unit_of_measurement: A
        slave: 1
        address: 1
        count: 2
        swap: word
        input_type: input
        scale: 0.001
        offset: 0
        precision: 1
      - name: HousePower_PhaseA_Power
        unit_of_measurement: W
        slave: 1
        address: 3
        count: 2
        swap: word
        input_type: input
        scale: 0.1
        offset: 0
        precision: 1
      - name: HousePower_PhaseA_Wh
        unit_of_measurement: Wh
        slave: 1
        address: 5
        count: 2
        swap: word
        input_type: input
        scale: 1
        offset: 0
        precision: 1
      - name: HousePower_PhaseA_Frequency
        unit_of_measurement: Hz
        slave: 1
        address: 7
        input_type: input
        scale: 0.1
        offset: 0
        precision: 1
      - name: HousePower_PhaseA_PowerFactor
        unit_of_measurement: Pf
        slave: 1
        address: 8
        input_type: input
        scale: 0.01
        offset: 0
        precision: 1

Be careful and choose the correct port! (for example my port – /dev/ttyUSB2)

The port number can be viewed in the ESPHome add-on (top right corner).

If everything works correctly, 6 new sensors (sensor.housepower_phasea_XXX) will appear in the system. You can add them to Home Assistant dashboard manually.

That’s all, PZEM-016 energy monitor is connected! 🙂

In the third part, we will tell you how you can get data from the PZEM-016 using MQTT.

Advertisement
Previous articleConnect PZEM-016 Energy Meter (ModBus) to Home Assistant – part 1 (via RS485 to TTL converter using Wemos D1 mini esp8266 and ESPHome)
Next articleDJI Mini 3 (DJI Mini 2s) possible Release Date, Price & Specs Rumours

4 COMMENTS

  1. Hi – This seems to work well – got it on the first try. However, for some reason the current always read 0.

    Any ideas?

    • Are you sure you connected the sensor to only one wire (L or N), and not to both at once? AC cable should be also connected.

  2. Sorry for the delay – I ended up using the TTL/Wemos as the power I wanted to monitor is no where near my HA. Attached to the Clothes Dryer Cable, I get a max of about .125A, which I am sure is not right (for safety sake, I connected power to 120V instead of to the dryer line itself (which, based on the 3 breakers assigned to this dryer, I would assume is really 3x the value I get, but that is still well less than 1A.)

LEAVE A REPLY

Please enter your comment!
Please enter your name here