讨论群: 810581215
在 1.0 基础上添加 TYPE-C 接口方便刷机,替换 C3 模块为乐鑫的(安信可和乐鑫关系崩了),PCB 兼容两个版本的 C3 模块,不带天线 ESP32-C3-WROOM-02U-N4(方便放入正泰模数化插座)和带天线 ESP32-C3-WROOM-02-H4 (适合不用壳 TYPE-C 供电裸奔的)
名称 | 型号 | 数量 | PCB 标注 | 链接 |
---|---|---|---|---|
ESP32-C3-WROOM-02U-N4 | - | 1 | ESP32-C3-WROOM-02-H4 | 购买 |
ME1117A33B3G 稳压电源芯 | - | 1 | 1117-3 | 购买 |
MAX13487EESA SOIC-8 | - | 1 | 485 | 购买 |
0603 贴片电阻 4.7KΩ | - | 1 | R1/R2 | 购买 |
0603 贴片电容 50V 100NF ±10% | - | 1 | C1 | 购买 |
2.4G 内置柔性 FPC 软天线 | IPEX 接头 | 1 | - | 购买 |
Type-C 母座 16P | - | 1 | TYPE-C | 购买 |
220V 转 5V700mA 电源模块 | 5V700mA | 1 | - | 购买 |
正泰 DDSU666 | 5-80A ModBus | 1 | - | 购买 |
正泰模数化插座 | AC30-103 | 1 | - | 购买 |
ESP32-C3-WROOM-02-H4 | - | 1 | ESP32-C3-WROOM-02-H4 | 购买 |
按 PCB 标注焊接即可,注意 C3 模块的焊接,缝隙很小,一定要对齐
-
直接采集
substitutions: device_name: living_esp485 esphome: name: ${device_name} esp32: board: esp32-c3-devkitm-1 framework: type: arduino version: latest logger: level: debug debug: update_interval: 5s api: encryption: key: !secret api_encryption_key ota: - platform: esphome password: !secret ota_password wifi: ssid: !secret wifi_ssid password: !secret wifi_password fast_connect: on web_server: port: 80 version: 3 include_internal: true text_sensor: - platform: wifi_info ip_address: name: ${device_name}_ip icon: mdi:ip-outline internal: true mac_address: name: ${device_name}_mac icon: mdi:map-marker-outline internal: true button: - platform: restart name: ${device_name}_reboot internal: true - platform: uart name: ${device_name}_ep_reset data: [0x01, 0x10, 0x00, 0x02, 0x00, 0x01, 0x02, 0x00, 0x01, 0x66, 0x72] time: - platform: sntp id: ${device_name}_time uart: id: ${device_name}_uart rx_pin: 5 tx_pin: 4 baud_rate: 9600 data_bits: 8 stop_bits: 1 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 sensor: - platform: wifi_signal name: ${device_name}_signal icon: mdi:signal internal: true - platform: debug free: name: ${device_name}_free unit_of_measurement: "KB" internal: true filters: - lambda: |- return x / 1024; block: name: ${device_name}_max_block unit_of_measurement: "KB" internal: true filters: - lambda: |- return x / 1024; loop_time: name: ${device_name}_loop_time internal: true - platform: internal_temperature name: ${device_name}_cpu_temprature icon: mdi:thermometer internal: true - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_u name: ${device_name}_u address: 0x2000 register_count: 2 unit_of_measurement: V register_type: holding value_type: FP32 accuracy_decimals: 1 device_class: voltage - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_i name: ${device_name}_i address: 0x2002 register_count: 2 unit_of_measurement: A register_type: holding value_type: FP32 accuracy_decimals: 3 device_class: current - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_p name: ${device_name}_p address: 0x2004 register_count: 2 unit_of_measurement: W register_type: holding value_type: FP32 accuracy_decimals: 1 filters: - multiply: 1000 device_class: power - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_q name: ${device_name}_q address: 0x2006 register_count: 2 unit_of_measurement: var register_type: holding value_type: FP32 accuracy_decimals: 1 filters: - multiply: 1000 device_class: power - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_s name: ${device_name}_s address: 0x2008 register_count: 2 unit_of_measurement: VA register_type: holding value_type: FP32 accuracy_decimals: 1 filters: - multiply: 1000 device_class: power - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_pf name: ${device_name}_pf address: 0x200A register_count: 2 register_type: holding value_type: FP32 accuracy_decimals: 3 device_class: power_factor - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_freq name: ${device_name}_freq address: 0x200E register_count: 2 unit_of_measurement: Hz register_type: holding value_type: FP32 accuracy_decimals: 2 - platform: modbus_controller modbus_controller_id: ${device_name}_modbus_controller id: ${device_name}_ep name: ${device_name}_ep address: 0x4000 register_count: 2 unit_of_measurement: kWh register_type: holding value_type: FP32 accuracy_decimals: 2 device_class: energy state_class: total_increasing filters: - median: window_size: 3 send_every: 3
电量重置按钮的地址要和表地址一致,如果地址不是0x01,最后两位CRC校验码需要重新生成
可以在这里生成MODBUS CRC16
-
透传模式(有空更新)
通过 ESP 的 IP 和端口 666 透传数据,测试工具可以使用 SSCOM
substitutions: device_name: esp485_stream esphome: name: ${device_name} external_components: - source: github://liwei19920307/esphome-stream-server components: [stream_server] stream_server: port: 666 esp32: board: esp32-c3-devkitm-1 framework: type: arduino logger: api: encryption: key: !secret api_encryption_key ota: password: !secret ota_password 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: 5 tx_pin: 4 baud_rate: 9600 data_bits: 8 stop_bits: 1 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: internal_temperature id: ${device_name}_cpu_temprature name: ${device_name}_cpu_temprature - platform: stream_server connection_count: name: ${device_name}_connection_count binary_sensor: - platform: stream_server connected: name: ${device_name}_connected
Modbus 一般分 Modbus-TCP 和 Modbus-RTU 两个种,收发报文有所区别,这里不做过多介绍网上资料很多。我这里介绍 Modbus-RTU 的,Modbus-TCP 由于没有设备无法测试。一般设备厂商设备说明书里都会提供地址说明(有的可以从官网下到),直接看图
外壳和变压器安装注意做好绝缘
欢迎提交其他设备适配文件,麻烦按以上设备目录结构提交