本帖最后由 dianxin11 于 2024-4-13 22:22 编辑
海鲜市场淘到一个有协议的1p电表,价格美丽,趁着过年时间充裕,DIY了一个智能电表。
所需材料
- DDSU1778未知品牌带协议1p电表。价格 90元5个,平均18一个。
- 1p空开1个,PDD3元一个。
- 485转ttl模块,淘宝2元一个。
- ams1117 3v模块 1元。
- esp01s模块一个 5元。
- 船型开关 算1元。
- 5v报废充电头。
合计30元。
电表相关资料
这个电表默认的就是Modbus-RTU协议,不过没有资料,地址是我用串口工具一点点调试出来的,有不正确的地方望指正。
第一屏和第二屏显示的是电表的地址。第一屏是低6位,第二屏高6位。共12位地址。测试后发现几块表默认地址都是0x000000000001和电表侧面标识一致。
第三屏显示的是串口速率,要根据这里的数据配置串口通信速率。
第四屏显示的是用电量。后面分别电压、电流、功率因数、频率。
硬件及接线
- 5v充电头接ams1117,输出3.3v分别给esp01和485转ttl模块供
- esp01的tx接485模块的tx,rx接rx。
- 485模块的A,B分别接电表的5,6口。
- 将接好的模块放入提前掏空的空开中。
成品效果如下:
esphome配置文件
substitutions:
device_name: "ddsu1778_01"
esphome:
name: ${device_name}
esp8266:
board: esp01_1m
# Enable logging
logger:
baud_rate: 0
# Enable Home Assistant API
api:
encryption:
key: ""
ota:
password: ""
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Ddsu1778-01 Fallback Hotspot"
password: ""
captive_portal:
uart:
id: ${device_name}_uart
tx_pin: 1
rx_pin: 3
baud_rate: 2400
# parity: even
stop_bits: 2
modbus:
id: ${device_name}_modbus
send_wait_time: 200ms
modbus_controller:
- id: ${device_name}_modbus_controller
modbus_id: ${device_name}_modbus
address: 0x01
command_throttle: 200ms
setup_priority: -10
update_interval: 30s
sensor:
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_u
name: U #电压
address: 0x06
#register_count: 2
unit_of_measurement: V
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
filters:
- multiply: 0.1
device_class: voltage
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_i
name: I #电流
address: 0x08
#register_count: 2
unit_of_measurement: A
register_type: holding
value_type: U_WORD
accuracy_decimals: 3
filters:
- multiply: 0.001
device_class: current
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_p
name: P #瞬时总有功功率
address: 0x09
#register_count: 2
unit_of_measurement: W
register_type: holding
value_type: U_DWORD
accuracy_decimals: 1
filters:
- multiply: 0.1
device_class: power
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_pf
name: PF #功率因数
address: 0x0B
#register_count: 2
register_type: holding
value_type: U_WORD
accuracy_decimals: 3
filters:
- multiply: 0.001
device_class: power_factor
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_freq
name: Freq #频率
address: 0x0C
#register_count: 2
unit_of_measurement: Hz
register_type: holding
value_type: U_WORD
filters:
- multiply: 0.01
accuracy_decimals: 2
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_ep
name: Ep #总有功电能
address: 0x03
#register_count: 2
unit_of_measurement: kWh
register_type: holding
value_type: U_WORD
accuracy_decimals: 2
device_class: energy
state_class: total_increasing
filters:
- median:
window_size: 3
send_every: 3
- multiply: 0.01
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_modbus_ep1
name: Ep1
address: 0x01
#register_count: 2
unit_of_measurement: kWh
register_type: holding
value_type: U_WORD
accuracy_decimals: 2
device_class: energy
state_class: total_increasing
filters:
- multiply: 0.01
Ep 和Ep1两个读数一致(目前),不知道哪个才是总有功电能。
参考文章 https://github.com/liwei19920307/ESP485
|