I’ve been using minimalmodbus for about 4 years. (started with version 0.6)
Haven’t had any problems reading modbus based energy meters from 3 different manufacturers.
(Elkor WattsOn, Continental Control Systems WattNode, Peacefair (cheap Chinese) PZEM-016.
So I’m a bit puzzled as to why it’s not working for you ATM.
Looking at the python code I grabbed from the github above, it seems like it is written for an older version of minimalmodbus: Realtime_DCV = instrument.read_register(33021, numberOfDecimals=0, functioncode=4, signed=False)
And from the api docs:
There may be other syntax issues like this (though it still executed even with numberOfDecimals instead of number_of_decimals) so I will try and go through and validate it against latest version of minimalmodbus first.
Renamed method arguments ‘numberOfDecimals’, ‘numberOfRegisters’ to ‘number_of_decimals’, ‘number_of_registers’
Removed example drivers for Eurotherm 3500 and Omegacn 7500, as I no longer have access to these instruments for testing. It would great if someone would pick up support for these instruments in a separate project.
Requires pyserial 3.0 or later.
Removed module level constants for default values, as they were confusingly named.
The rest of that page doesn’t show any other breaking changes.
I don’t know if this will help any, but here’s the Python sketch I use to read my WattNode:
Thanks for that might help to compare.
Also got the official modbus docs from the manufacturer so it seems like the register numbers are more or less the same as the unofficial doc.
Attaching here as it might help someone.
One question, I will be connecting both the official wifi logger and my usb adapter to the inverter at the same time so I can continue to use both.
Do I need to change instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) to something like instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 2) ? Or what’s the correct way to do it?
Looks like the manual is translation from Chinese so I am not 100% sure it is translated correctly, lost in translation and all that.
Hopefully I get a bit of time to test things out today
Some progress.
I am able to read the modbus registers directly from Home Assistant using the usb rs485 cable but I have come across a new issue.
I have connected my rs485 adapter cable to the A/B/GND pins of the wifi logger so they are both connected to the inverter at the same time which should be fine in theory but I think they are tripping over each other.
Sometimes as I can see the logger log some crazy values like this:
And I am pretty sure I’m not using as much power as a small city
Is the connection A → A, B → B correct (Logger → rs485 adapter)? Or to connect the slaves in series you need something like A → B, B → A?
Not sure I understand 100% but I think I might have the 3rd diagram in my scenario.
This is how I did it, I soldered the usb rs485 adapter cables to A/B/GND on these pins below (on the logger that’s currently installed, this is a spare)
No idea, no mention in the super basic guide that came with it.
There is a good chance the software doesn’t know to wait/delay messages and both the logger and the rs485 adapter try to get data at the same time and I assume that’s happening with the bogus data.
But the rs485 adapter reads the data just fine, only the logger is tripping.
I know this is connecting 3 inverters together using one rs485 cable but maybe same needed for me?
(Not sure that the IN and OUT mean as there is only one COM port on the inverter)
Also does the wire size matter, I used a standard 6 core alarm cable that I had laying around?
I’m not familiar with HA, but if HA has a way to insert a delay between requests, you could try
that.
Modbus requires each of the two devices to have a unique address. Modbus is a polled system.
i.e. the slave doesn’t respond unless it’s polled by the master.
Yes tried delays of 15s to 60s, did not make a difference from Home Assistant but that doesn’t mean the wifi logger is doing a delay when it expects to be the only slave.
I have also tried different slave IDs in Home Assistant because they can be set there.
Here: https://electrical-engineering-portal.com/correct-cabling-modbus-rs485#connection-port it says to use shielded twisted pairs, use a 3 pairs from the cat5/6 cable for the 3 wires?
It also says 120ohm resistor not needed if the run is less than 50m, my rs485 cable is 150cm.
The article does mention a terminator, but they’re simply mentioning the need for one.
Some devices have the terminator built into them. In that case there will be either a physical connection
e.g. a jumper on a pair of pins, or a software command that “connects” the terminator to the bus.
I thought perhaps the datalogger might the the type controlled by a software command.
WRT the ground connection, yes. It should be connected only at one end.
Size, not really.
What’s important here is impedance. The Modbus spec calls for an impedance of 120 Ohms.