本帖最后由 idaniel 于 2023-3-11 09:43 编辑
PCB来自 liwei19920307 的项目 ESP485 ,GitHub地址:https://github.com/liwei19920307/ESP485/ 原作者使用正泰DDSU666电表,本人家中都是使用德力西的空开,因此想改用德力西的电表进行接入
ESPHOME代码
substitutions:
device_name: esp485
esphome:
name: ${device_name}
# platformio_options:
# board_build.flash_mode: dio
# board_build.mcu: esp32c3
esp32:
board: esp32-c3-devkitm-1
framework:
type: arduino
logger:
api:
ota:
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
fast_connect: on
web_server:
port: 80
button:
- platform: restart
name: ${device_name}_reboot
time:
- platform: sntp
id: ${device_name}_time
uart:
id: ${device_name}_uart
rx_pin: 18
tx_pin: 19
baud_rate: 2400
data_bits: 8
stop_bits: 1
parity: EVEN
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: 10s
text_sensor:
- platform: wifi_info
ip_address:
name: ${device_name}_ip
mac_address:
name: ${device_name}_mac
sensor:
- platform: uptime
name: ${device_name}_uptime
- platform: wifi_signal
name: ${device_name}_signal
update_interval: 60s
#当前电压
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_u
name: ${device_name}_u
address: 0x0300
register_count: 1
unit_of_measurement: V
register_type: holding
value_type: U_WORD
accuracy_decimals: 1
device_class: voltage
filters:
- multiply: 0.1
#当前电流
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_i
name: ${device_name}_i
address: 0x0303
register_count: 1
unit_of_measurement: A
register_type: holding
value_type: U_WORD
accuracy_decimals: 2
device_class: current
filters:
- multiply: 0.01
#瞬时A相有功功率
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_s
name: ${device_name}_s
address: 0x0306
register_count: 1
unit_of_measurement: kW
register_type: holding
value_type: U_WORD
accuracy_decimals: 2
filters:
- multiply: 0.01
device_class: power
- platform: modbus_controller
modbus_controller_id: ${device_name}_modbus_controller
id: ${device_name}_ep
name: ${device_name}_ep
address: 0x000A
register_count: 2
unit_of_measurement: kWh
register_type: holding
value_type: S_DWORD
accuracy_decimals: 2
device_class: energy
state_class: total_increasing
filters:
- multiply: 0.01
- median:
window_size: 3
send_every: 3
|