Getting data from inverters via an RS485 connection

Not sure, I asked him on another thread, waiting to find out.

Earlier you mentioned the datalogger sending data every minute.
Is that consistent, or does the interval drift a bit?

This is the export from the cloud app and yes drifting it seems:


What I don’t get is when they “read” at the same time, where does the wifi logger get crazy values like these?

That’s when it happened earlier.

All this sounds to me as if you have two masters on the bus, the datalogger is one and your Pi is the second. “crazy values” is when the responses clash. And that’s not how the bus is supposed to work.

I am not sure, that may be right, but then why am I getting the correct data back from the inverter via the rs485 cable? Shouldn’t that fail when you have 2 masters?
Here is are the docs for the home assistant modbus integration Modbus - Home Assistant
Reading I cannot be sure if it sets itself as the master, but slave id is specified for the sensors as you can see above.

I have not been paying close attention to this topic, so I’m not sure what hardware you have. I think you have an inverter, and a datalogger that obtains data from your inverter and sends it somewhere. I think you want to also connect your Pi to the inverter to obtain the same or different data.

RS485 and Modbus are two completely different things that can be used together. Modbus is a communications protocol that works by having a Master that controls the bus (in this case the bus wiring and signal levels are RS485) and slave devices that respond when told to do something.

If the inverter and data logger can work together, one of them is a Master. If the Pi and the inverter can work together, one of those two is a master. Because you give the Pi a list of devices, the Pi must be the master in that case. The question is, which of the two, inverter or datalogger, is the master in that setup? I think it must be the datalogger, because from everything I’ve seen, it’s not the inverter (and it doesn’t make sense for it to be the inverter, whereas having the datalogger as the master makes a lot of sense to me - it can log any number of inverters on the same bus).

So, if I’m correct, I think you could solve the problem in one of two ways: Either, because you know how often the datalogger requests data, your Pi could wait and listen on the bus for the logger’s request and the inverter’s answer, then it could send its own request to the inverter. That isn’t how the bus is supposed to work, but I think that is almost what you are doing now - except your Pi isn’t waiting for the other transaction to happen. The other way would be if the datalogger could be turned into a slave device and logged data when told to. In that case, you’d need your Pi to be the bus master, it would get all the data from the inverter, then send whatever you wanted logging to the data logger with the instruction to log it. Whether either of these are possible with the software you have, I don’t know. It might need completely new software, even if the hardware (the datalogger and the Pi) can operate in the way you need them to.

Ok short recap:

  1. Device list:
  • Solis Inverter
  • Solis wifi logger
  • USB to RS485 Adapter
  • Raspberry pi4 or Windows laptop to connect the RS485 adapter to read data via modbus
  1. Connections
    The Solis wifi logger is connected to the inverter (4 pins round connector, 5v,A,B,GND)
    One end of the cable that goes to the RS485 adapter is connected to the Solis wifi logger A → A and B → B, soldered the cables on the logger like so
    The other end of the cable is connected to the USB RS485 adapter (A and B pins only)
    The RS485 adapter is connected to a USB2.0 port on the raspberry pi4 and the modbus integration is used to poll the registers

  2. Issues

  • When connecting either the wifi logger or the rs485 adapter on their own (without daisy chaining) they both operate correctly.
  • When connecting the rs485 to the wifi logger (and both are connected to the inverter), the rs485 continues to pull the data correctly via home assistant but the wifi logger sometimes “trips” and logs bogus data (i.e. numbers in the hundreds of thousands)
    See below for the time it happened and the values are all wrong, looks like it lasted 3 minutes (wifi logger logs every 1 min)

My understanding is that the inverter is the master and the wifi logger and the rs485 should be the slaves but maybe the wifi logger and the rs485 adapter are the masters instead? In that case how can I know/listen on the rpi for the wifi logger to finish?
For the wifi logger it is a closed system and I have no control over the software/modbus commands

Here is the modbus doc from the manufacturer, perhaps it helps in determining the master/slave setup but I am not able to tell from it.
RS485_MODBUS(ESINV-33000ID) Hybrid Inverter .pdf (402.3 KB)

I think Robert has hit the nail on the head.

Thanks RW!
thumbsup

I hadn’t thought about “more than 1 master on the bus.”

Makes sense though. When one considers the drawing in post 142 of this thread,
the only way it could work is if the datalogger were master.

The inverter has to be the slave.
Queries from a Modbus master retreive data from the registers in a Modbus slave.

Are there any docs for the datalogger itself?

In that case this seems to be the only possible solution but not sure exactly how to tackle it and let’s say the Pi manages to do the waiting, what if the wifi logger then starts to ask data when the Pi is still getting it (i.e. not wait because it’s programmed to not expect that it has to)?
The Pi would also poll registers with different delays between so more chances of collisions.

None that I could source.

Is there a make and/or model number on it?

I agree. Otherwise, that post no.142 drawing (which I had seen but it hadn’t registered as being the supplier’s explanation) implies one of the inverters is the bus master, and the other 3 devices are slaves. Who decides which inverter is master? That doesn’t make sense in so many ways.

That must be possible. All bus devices except the master must listen on the bus all the time except when they are transmitting. Therefore, in Slave mode, your Pi’s adapter will be listening and sending the data to the Pi. The problem is, the Modbus library (I assume that’s what you’re using) will simply ignore data that isn’t addressed to it. In Master mode, it might not even listen. It’s that part that would need extending to recognise the logger’s transaction: you would need to write special Modbus software to listen as a slave, then turn round and conduct its own transaction as a Master.

I think the only realistic option is to use only one device to extract the data - either the logger or the Pi.

Where does the data from the logger go, and can you get what you want from there? Presumably not, or we wouldn’t be here. Or can you grab the data that the logger sends, and send it from the Pi instead?

There’s only 3 inverters present in that drawing.
It shows the data + and - pairs daisy chanied from one inverter to the next terminating at an RS-485
in the COM box. Looks to me, like the interface in the COM box is where the master is at.

Exactly, that’s why I wrote “devices”. It’s the obvious and the only sensible way to organise the bus.

It makes no sense whatsoever to have an inverter as the master.

D’Oh!
I misunderstood you.
doh

Why use the datalogger when the same data could be retreived via the RS-485 interface?

The official wifi logger has its advantages, such as remote monitoring in case of alarms etc, logging to a database for historical data but unfortunately cannot provide live data (which I can fix with the rpi connection) - it is quite annoying that it does not have a local interface where you can just hit the IP and obtain the data, all is going to the cloud.
@craigcurtin managed to get this working as mentioned in this post so not sure how he got around this issue if at all.
One thing I just noticed in his post here, he says “You have to set yourself a Modbus address (the inverters can only be address 1) so set yourself something like address 10.”
Which makes sense for the inverter to be the slave as I only got back data on rpi when I had set slave: 1 meaning the inverter is slave with id 1.
And looks like he was getting collisions also:

Modbus is a shared bus - so you can continually poll the inverter (say every 10 seconds) - occasionally you will get a collision with the WIFI dongle but they will both recover.

They do recover but it also logs faults, alarms and wrong data which I am trying to resolve.

And that’s almost certainly for exactly the same reason - he too must have two masters on one bus, and that’s not the way that Modbus is designed to operate. Yes, it’s true that Modbus is a shared bus - but that means shared between slaves, with one master device in control regulating the traffic.

If you have two masters, then you’re in the same predicament as you are with the emonPi and several emonTx’s and emonTH’s - there, each sensor node sees itself as a master in control and you get collisions and lost data, which doesn’t happen when you use Modbus correctly.

“it” = the data logger? Is it feasible to do that with your Pi? It should be, because if your Pi can access all the registers, it can have exactly the same data as the data logger.

Yes, I would assume the rpi can extract the same data as long as it can read all the correct registers and do even more such as write to them to be able to change settings on the inverter such as setting a time for when to use/save the battery, something that the inverter’s wifi logger cannot do for some unknown reason.
The inverter’s wiffi logger logs to the cloud in a nice to view/use app and also on top of that, having an extended warranty (for the inverter) which I would lose if no longer logging with that.

I’m not sure if setting any of these additional options in home assistant will help with the collisions