EW11A 485转wifi模块接到逆变器的通信口,通过家里的wifi网络接入HA。
逆变器的通信口是RJ45网口形态,公开资料(http://support.sungrowpower.com/home)提到3脚是485 B-,6脚是485 A+, 将这4个引脚接到EW11A 485转wifi模块对应引脚,就可以工作。 EW11 IP是192.168.1.13,设置为tcp server模式,在tcp 8813端口监听,转发到串口UART,串口设置为9600 8N1,Protcol设置None。 连接 192.168.1.13 的tcp 8813通信,就可以与逆变器通信,这时使用的rtu over tcp,也就是原始的串口RTU协议。
从网上找了逆变器的modbus寄存器文档 我使用的HA配置文件如下供参考: - name: "hubsungrow" type: rtuovertcp host: 192.168.1.13 port: 8813 sensors: - name: "今日发电" slave: 1 address: 5002 input_type: input device_class: energy unit_of_measurement: kWh scan_interval: 10 data_type: uint16 scale: 0.1 precision: 1 - name: "发电功率" slave: 1 address: 5030 input_type: input count: 2 device_class: energy unit_of_measurement: W scan_interval: 10 data_type: uint32 swap: word - name: "总发电量" slave: 1 address: 5003 input_type: input count: 2 device_class: energy state_class: total unit_of_measurement: kWh scan_interval: 10 data_type: uint32 swap: word - name: "逆变器温度" slave: 1 address: 5007 input_type: input unit_of_measurement: °C device_class: temperature scan_interval: 10 data_type: int16 scale: 0.1 precision: 1 - name: "MPPT1电压" slave: 1 address: 5010 unit_of_measurement: V device_class: voltage scan_interval: 10 input_type: input data_type: uint16 scale: 0.1 precision: 1 - name: "MPPT1电流" slave: 1 address: 5011 unit_of_measurement: A device_class: current scan_interval: 10 input_type: input data_type: uint16 scale: 0.1 precision: 1 - name: "MPPT2电压" slave: 1 address: 5012 unit_of_measurement: V device_class: voltage scan_interval: 10 input_type: input data_type: uint16 scale: 0.1 precision: 1 - name: "MPPT2电流" slave: 1 address: 5013 unit_of_measurement: A device_class: current scan_interval: 10 input_type: input data_type: uint16 scale: 0.1 precision: 1这种方式只能用HA来读取信息,我还想同时用自己写的程序读取信息,就用 ./modbus-multiplexer -n modbus8813 8813 192.168.1.13 8813上述程序在192.168.1.18机器上执行,这样一来,多个客户端访问192.168.1.18 的8813端口, 可以使用modbustcp 协议通信,由modbus-multiplexer转发到192.168.1.13 8813端口 的tru over tcp与逆变器通信。 相应的,HA配置改为类似: - name: "hubsungrow" type: tcp host: 192.168.1.18 port: 8813 sensors: - name: "今日发电" slave: 1 address: 5002 input_type: input device_class: energy unit_of_measurement: kWh scan_interval: 10 data_type: uint16 scale: 0.1 precision: 1 max_value: 40 |