Zry.IO

返回

Peacefair PZEM-004T V3

PZEM-004T V3 是一款交流电能监控模块,支持测量 80-260 V 电压、最大 100 A 电流及功率、电能、频率和功率因数(datasheet [存档]),通过 RS-485 串口 Modbus 协议通讯。

从 AliExpress 以 €8.17 包邮购入,为了安装方便,测量电流的互感器选用可开闭的非侵入式(一般称作 CT clamp):

pzem

硬件

电路十分简单。由于 PZEM 使用无源串口,需要外部提供 +5 V 供电,为了方便直接选用集成了 USB 5 V 转 3.3 V 供电电路的 WeMos D1 mini 模块而不是裸 ESP-12F。

另外需要加上一个电平转换器将 PZEM 的 5 V TTL 转为 ESP 接受的 3.3 V。

schematic

电压探头可以用一个普通插头做,插到墙上插座;或者和电流探头一起进配电箱,然后直接接到空气开关上。

完整的电路板、PZEM 及电压探头(普通插头):

电路板上的继电器是为未来的公寓大门远程开关项目准备的

overview

电流探头安装

先给电流互感器焊上延长线。

拆下配电箱面板,找到入户总火线或零线(通常是最粗的,连着总空气开关),将电流互感器钳上:

ct-clamp-installed

装回面板,将电流互感器导线从缺口处引出:

breaker-box

按照 PZEM 模块外壳上印着的说明,分别连接好电压和电流探头,然后给 ESP 模块连上电源,完成:

done

软件

ESPHome 配置示例:

之后在 Home Assistant 接入设备,即可在电能监测平台直接选取 sensor.energy 作为数据源:

hass-energy

如果想添加概览卡片到 lovelace,可以先用 YAML 配置两个 utility_meter 传感器:

energy_monthly:  # 每月用电量
  source: sensor.energy
  cycle: monthly
energy_daily:  # 每日用电量
  source: sensor.energy
  cycle: daily
yaml

然后添加一个 lovelace 概览卡片:

lovelace-glance-card

type: glance
title: 用电
show_icon: true
show_state: true
state_color: false
entities:
  - entity: sensor.power
  - entity: sensor.energy_daily
    name: 当日
  - entity: sensor.energy_monthly
    name: 当月
yaml
基于 PZEM-004T V3 的全屋电能监控
https://zry.io/zh/smart-home/whole-home-energy-monitoring-based-on-pzem-004t-v3
作者 zry98
发布于 2022年2月9日
6 条评论
sanjay

Is it required to use level shifter ic - like this https://robu.in/product/level-converter-4-channel/

zry98

Yes, I used an exact same one as you linked

Josip

Which program is installed on esp8266?

zry98
Gemul

Hi, just want to let you know that the rx/tx wiring in diagram and the given code is not correct. the code says TX is GPIO4, which is D2, and in diagram, D2 is connected to the TX pin (next to GND) of the PZEM. TX should be connected to RX and vice versa.

zry98
@Gemul :

Thanks for pointing that out! Fixed in the yaml.