RS485 communication interface

Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

Yes it is a polled interface, you have to request data from a register or range of registers using modbus (RTU) protocol and it will respond at 9600 baud (N,8,1).

The easiest way to get data out in a meaningful way is to use a home assistant (raspberry pi, mini pc, odroid etc..) - there is an excellent integration that polls the inverter via RS485 and provides all of the inverter sensors, i’ll put a link below for you to take a look.

If you want to do it yourself, there are resources that show the register map so you can read (or write) to the inverter.

You will need to connect an RS485 to ethernet converter to the port and then you can address the inverter through it - if you have a windows pc or linux box download the modpoll application https://www.modbusdriver.com/modpoll.html

And then you will be able to address the device using: modpoll.exe -m tcp -p 502 -a 247 -t 3 -0 -1 -c 16 -r 11000 192.168.0.200

Replace the 192.168.0.200 with the IP address of you RS485 ethernet device.

This is the best integration for getting data into a home assistant https://github.com/nathanmarlor/foxess_modbus

If you look at the wiki for this integration it lists a number of RS485->Ethernet converters that have been proven.

This link is to Foxess documents for the various protocols and the bottom link has the protocol described in detail

https://github.com/nathanmarlor/foxess_ ... -Documents

Hopefully that will give you plenty to think about, but if you have any questions, fire away and i’ll do my best to answer (the site email notifications don’t work so you will need to check back here for updates)
ChrisH
Posts: 4
Joined: Fri Jun 23, 2023 12:15 pm

Finally I’m getting a response from my inverter using modbus RTU, but it’s not what I’m expecting!

I’m trying to read 24 register values starting from address 1000 so I’m sending F7 04 03 E8 00 18 64 E6

(F7 = device address, 04 = register read, 03 E8 = address 1000, 00 18 = read 24 values, 64 E6 = check sum).

The response I receive is F7 83 02 20 C3. This seems sensible because it starts with the matching device address and the checksum calculated from all the response including the checksum, is zero. If I change the device address or corrupt the checksum I’m sending, I get no response. However, I’m only seeing one register value and it doesn’t change if I change the requested address.

Any idea what I can try next? I have an H1/AC1 series inverter.
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

A couple of quick thoughts, try changing your ‘04’ to ‘03’ depending on your inverter some reply differently to this message depending on whether you use input or holding registers.

And for the H1 shouldn’t the start address be 10000 or 11000 (not 1000)
canton7
Posts: 42
Joined: Sun Oct 23, 2022 12:17 pm

It's responding with exception code 02, Illegal Data Address. (as you're requesting 1000 not 10000)
ChrisH
Posts: 4
Joined: Fri Jun 23, 2023 12:15 pm

Many thanks Dave!

That’s made all the difference. I now have a RS485 wired connection giving readings that look likely.

Function code 4 is right. I had a little early confusion about the radix of the register addresses and I mentally masked out bits that are required. Recognising that they really are decimal addresses sorted that out.

Now to interface it to my boiler controller!
jbee
Posts: 7
Joined: Tue Jan 16, 2024 10:18 pm

Sorry to resurrect this thread, but I'm just trying to wrap my head around this.

I have the Elfin EW11 wired into the h1 inverter with the A and B connections in what I'm fairly certain is the right place 485A and 485B respectively?

I also have the EW11 powered via USB and all settings as per HA guide. I can connect to unit via it's IP address on home WiFi.

However I can't seem to get HA to recognise it. Is there another piece of kit I should be using between the raspberry pi and the EW11?

thanks!
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

Are you using this integration on HA to connect to it? https://github.com/nathanmarlor/foxess_modbus

If you click on the wiki there is a wiring guide which confirms the pins on the inverter, a common mistake is connecting them to the meter RS485A/B when it should be the RS485A/B pin

There is the connection that you make to the Elfin via web browser that allows you to configure it, but this is different to the one used to communicate with the inverter - you should be able to use a program called modpoll to test the inverter responds.

If you post which inverter you have I can provide a cmd line to use with modpoll to test the inverter is able to reply.
jbee
Posts: 7
Joined: Tue Jan 16, 2024 10:18 pm

Thanks Dave.

I've tried a few of those integrations, and currently have that one installed. HA is installed via docker if that makes any difference.

I've definitely got them wired to 485A/B, and not the meter one. After trying your suggestion below, I think I'll need to switch A and B round and see if that works.

My inverter is H1-5.0-E. Installed in spring 2021 so I need to get the firmware updated, but I don't think that's the issue.

If you could send over that please, I'll try it.

Thanks again.
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

Ok, that is the best integration to use.

Your inverter firmware shouldn't affect it on RS485.

If you had ever used a LAN connection on the inverter it is best to make sure that is disabled Settings, (enter password), Communication, Ethernet, DHCP = Disabled
*ignore this if you haven't ever used it.*

It should be wired A->A and B->B (not crossed over)

This command will read the charge times registers from the inverter

modpoll.exe -m tcp -p 502 -a 247 -t 4 -0 -1 -c 6 -r 41001 192.168.0.xxx

change the IP address at the end to match your Elfin, and the response should look something like -
modpoll 3.10 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2021 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41001 (PDU), count = 6
Communication.........: 192.168.0.xxx, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
[41001]: 1
[41002]: 5918
[41003]: 1310
[41004]: 0
[41005]: 0
[41006]: 0
Which is what you get for charge period 1 with grid charge enabled between 23:30-05:30

Any kind of error is bad but sometimes the message is helpful to decode the problem.
jbee
Posts: 7
Joined: Tue Jan 16, 2024 10:18 pm

Hi Dave,

Cheers for that. I've ran modpoll and this is what it's coming back with:

modpoll 3.11 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2024 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41001 (PDU), count = 6
Communication.........: 192.168.0.42, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
[41001]: 1
[41002]: 0
[41003]: 0
[41004]: 1
[41005]: 0
[41006]: 0
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

jbee wrote: Fri Feb 09, 2024 2:57 pm Hi Dave,

Cheers for that. I've ran modpoll and this is what it's coming back with:

modpoll 3.11 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2024 proconX Pty Ltd
Visit https://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP, FC3
Slave configuration...: address = 247, start reference = 41001 (PDU), count = 6
Communication.........: 192.168.0.42, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, output (holding) register table

-- Polling slave...
[41001]: 1
[41002]: 0
[41003]: 0
[41004]: 1
[41005]: 0
[41006]: 0
That's a good response (no errors), according to that you have your charge periods 1 & 2 both set 00:00-00:00 and with the enable grid charge switched on (it should really be off), in which case 41001 & 41004 would be 0.

So that is connected and it is working, in which case you should be able to get data at your home assistant.

Make sure you have no other integratons installed other than Nathan's (restart HA if you change anything).

You should have added Foxess - Modbus in HACS, then go to Settings, Devices & Services and 'Add Integration' search for Foxess - Modbus and install, it will ask you some configuration questions so you need to enter your Elfins IP address - don't add an inverter name unless you have multiple inverters and when you submit it should setup all the sensors you need - if it raises an error can you copy and paste the logs it generates Settings, System, Logs here.
jbee
Posts: 7
Joined: Tue Jan 16, 2024 10:18 pm

Dave,

With your guidance I have got it working! Much appreciated. I wasn't adding it after adding it through HACS.

I will need to look at charge periods and the setting you've advised should be disabled. Presumably these are easily changed via home assistant now.

Thanks again.
Dave Foster
Posts: 822
Joined: Thu Oct 13, 2022 7:21 pm

Great, glad you’ve got it working.

If you go back into HACS in home assistant and search for the frontend foxess modbus charge card - download that and add it to one of your dashboards and you’ll get an easy to use charge period settings card 👍
IanR007
Posts: 1
Joined: Sun Feb 18, 2024 11:14 pm

jbee wrote: Thu Feb 08, 2024 8:53 am Sorry to resurrect this thread, but I'm just trying to wrap my head around this.

I have the Elfin EW11 wired into the h1 inverter with the A and B connections in what I'm fairly certain is the right place 485A and 485B respectively?

I also have the EW11 powered via USB and all settings as per HA guide. I can connect to unit via it's IP address on home WiFi.

However I can't seem to get HA to recognise it. Is there another piece of kit I should be using between the raspberry pi and the EW11?

thanks!
I also have the Elfin Ew11 wired into an H1 inverter through the A & B connections. I had an issue with the Elfin EW11 not communicating with Home Assistant. I followed ALL of the recommendations for setting up the Elfin EW11 to communicate through the RS485 port on the H1 inverter. Still no communication. I found quite by accident the following hack which kick started the Elfin EW11 into communication with the H1 Inverter; The process is as follows;
Settings you must make on the inverter before the logging device (EW11) will talk to the inverter, you must ensure the following is carried out to run your automation on a new install;
In Inverter Settings "communications" ensure Ethernet is set to "DHCP". This reveals 3 settings which must match your Modbus logging device set up as follows;
IP (LAN) Address: 10.10.100.254
Subnet (Mask) Address: 255.255.255.0
Gateway (DNS): 223.5.5.5
Once the Elfin EW11 is communicating go back into settings set Ethernet to “disabled” in communications. The Elfin EW11 will continue to log through the RS485 connection.
Post Reply