So I just realized that this little power meter im using has a RS485 output and apparently puts out RS485 modbus data.
dds-80a.pdf (carrel-electrade.co.nz)
I have worked very little with RS485 and also modbus, but is it possible to input this data to homeassistant?
The hardware I will use to connect will be a Kinkony KC868-A8 with the RS485 port, using ESPHome.
Thanks
Looks like its only two registers as one 32 bit integer that you will be reading from, so that is straight forward and will work.
But can’t find much on the Kinkony Modbus setup.
If the Kinkony is difficult to setup, remember there are plenty of options for Modbus <–> HA including ESPHome or even a USB RS485 cable plugged into your HA setup.
Thanks, I’m still a little unsure of how to actually set it up. Like, completely lost in the dark haha.
I’m guessing if I can use modbus with esphome, no reason why I can’t use the kinkony being esp based?
Thanks
Wire the power meter to your Kinkony - RS485 is normally 2 wires and while it’s recommended to use a twisted pair, it will run on almost anything. Just make sure you comply with your local codes /end-disclaimer.
If it doesn’t work, switch the wires at one end and try again. There is no polarity as they are a differential pair, so you won’t blow anything up.
Then you will have to see how the Kinkony requires things to be programmed for a Modbus register.
The register type will be holding, address will be 1 & data type will be U_DWORD (I think)
Untested but if the Kinkony works like ESPhome, this is a modded example from the ESPhome Modbus Controller page.
Hope that gets you started.
sensor:
- platform: modbus_controller
id: power_meter
name: "power_meter"
address: 0x1
unit_of_measurement: "kWh"
register_type: read
value_type: U_WORD
filters:
- multiply: 0.1
Excellent, thanks I’ll give this a shot and let you know how I get on.
1 Like
Ok, so I just confirmed that the Kinkony does not have a RS485 port.
So, my next question is can I read RS485 with a ESP32?
I also do have a space I2C port on the Kinkony, not sure if I could convert RS485 to I2C?
Thanks for your help!
I haven’t used ESP board with RS485, but that board is the same as the example on ESPhome so it should do the job.
Edit: One caveat they do say on the guide is to make sure you’re using hardware UART pins if using an ESP8266. Don’t know if the issue is the same for an ESP32 -
If you are using an ESP8266, serial logging may cause problems reading from UART. For best results, hardware serial is recommended. Software serial may not be able to read all received data if other components spend a lot of time in the loop()
.
For hardware serial only a limited set of pins can be used. Either tx_pin: GPIO1
and rx_pin: GPIO3
or tx_pin: GPIO15
and rx_pin: GPIO13
.
Ok, I have everything wired the way I would imagine it needs to be.
I’ve swapped TX and RX around between ESP32 and TTL.
Ive used GPIO1 and GPIO3 as my ports for the modbus configuration.
Here is my code which is literally a copy paste off the esphome modbus page.
Could you tell me how I need to configure this now.
Thanks!
uart:
id: mod_bus
tx_pin: 17
rx_pin: 16
baud_rate: 9600
stop_bits: 1
modbus:
flow_control_pin: 5
id: modbus1
modbus_controller:
- id: epever
## the Modbus device addr
address: 0x1
modbus_id: modbus1
setup_priority: -10
text_sensor:
- name: "rtc_clock"
platform: modbus_controller
modbus_controller_id: epever
id: rtc_clock
internal: true
register_type: holding
address: 0x9013
register_count: 3
raw_encode: HEXBYTES
response_size: 6
switch:
- platform: modbus_controller
modbus_controller_id: epever
id: reset_to_fabric_default
name: "Reset to Factory Default"
register_type: coil
address: 0x15
bitmask: 1
sensor:
- platform: modbus_controller
modbus_controller_id: epever
name: "Battery Capacity"
id: battery_capacity
register_type: holding
address: 0x9001
unit_of_measurement: "AH"
value_type: U_WORD