Connect PZEM-016 Energy Meter (ModBus) to Home Assistant 2024 – 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 (07 April 2022) to be compatible with latest Home Assistant 2022.4.0

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 2022.4.0 server (my server info: core-2022.4.0, supervisor-2022.03.5, Home Assistant OS 7.6, Linux Operating System Version 5.10.108, update channel stable)

Add this code to your HA configuration.yaml file

modbus:
  - name: rs485usb
    type: serial
    method: rtu
    port: /dev/ttyUSB1
    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
        data_type: int16
        device_class: voltage
      - 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
        data_type: int32
        device_class: current
      - 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
        data_type: int32
        device_class: power
      - 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
        data_type: int32
        device_class: energy                                                  
        state_class: total_increasing
      - name: HousePower_PhaseA_Frequency
        unit_of_measurement: Hz
        slave: 1
        address: 7
        input_type: input
        scale: 0.1
        offset: 0
        precision: 1
        data_type: int16
        device_class: frequency
      - name: HousePower_PhaseA_PowerFactor
        unit_of_measurement: Pf
        slave: 1
        address: 8
        input_type: input
        scale: 0.01
        offset: 0
        precision: 1
        data_type: int16
        device_class: power_factor

 

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

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.

3 COMMENTS

  1. 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.)

Stay in the Loop

Get the weekly email from TechLifeTravel that makes reading the news actually enjoyable. Join our mailing list to stay in the loop to stay informed, for free.

LATEST ARTICLES