How to connect via Modbus (RS485) a Samsung HVAC external unit with MIM-B19N

So I’ve created this post where I mentioned this USB device that I bought.

Now I have more details about what I actually want to do, but it’s the first time I will do this so I kind of don’t know where to start! :smiley:

So this is the documentation for the HVAC external unit Modbus board that is installed already: MIM-B19N - Modbus.pdf (761.7 KB)

The guys that sold and installed this, said that if I wanted they could try to book a meeting with an engineer from Samsung, although it would take time for that. So since I already know how these things work, if I go for that option I might be prepared to wait months.

So if a kind soul can shed some light on how to do this, I would really appreciate. :slight_smile:

Thank you once again guys.

Update

It seems I got it communicating, since the “Modbus Poll” bridge that is connected to my “Modbus Serial Slave” bridge is “Online” and in my “Modbus Data” thing I get this message:

Thing modbus:data:modbus:modbusdata invalid readValueType: Only readValueType=‘bit’ (or undefined) supported with coils or discrete inputs. Value type was: int16 (here for whatever option, the error message is always the same)

My setup for “Modbus Data” is:
Read Address = 50
Read Transform = default
Read Value Type = (tried all of them already, none worked)

My setup for “Modbus Serial Slave” is:
Serial Port = /dev/ttyRS485 (yes, I’ve setup this port as binding documentation says)
Id = 1
Baud = 9600
Stop Bits = 1
Parity = Even
Data Bits = 8
Encoding = RTU
Discovery Enabled = Yes
Flow Control In = XON/XOFF
Flow Control Out = XON/XOFF
Time Between Transactions = 35

My setup for “Modbus Poll” is:
Poll Interval = 500
Start = 1
Length = 100
Type = coil, or digital out(DO)
Maximum Tries When Reading = 3

So I’m stuck at this point now.

I wouldn’t go that far, yet :slight_smile:

Bridge online only means the binding can see the host port/dongle

If your dongle or device has twinkly LEDs this is the best guide to something happening - but with a broken config I doubt it’s trying to poll yet.

Don’t try stuff at random, find out or ask.

Your poller definition as “coil”-

means that you must use binary bit data type in associated data Things.

Because this a polling binding, it uses your configuration to set up future scheduled read polls. If the config is messed up, a simple edit might not clear that properly.
Once you’ve got your config as wanted, try reloading the binding (or if you don’t know how, reload openHAB) and see what’s left afterwards.

1 Like

First of all, thank you so much for taking your time once again. :slight_smile:

I’ve looked into the document and searched online but I can’t find anywhere the proper type I should be using here. :frowning:

Maybe I do need to ask directly to Samsung for help here.

Ok, but can it be that if I change the poller definition, it might also work and in that case use a different read type?

Cool, that’s a good advice, I will do that.

Thanks, I will update here with more news in an hour or so.

I’ve looked at the device manual now. It’s not very helpful, that is typical for Modbus docs that tend to assume you’re already an engineer.

So I see -

Read functions:
• 3 read holding registers
etc.

It looks like this Modbus slave only supports holding type registers, 16-bit read-write registers.

Your poller will need to be edited for that type, and to read a whole register into a number your data Thing would need to be uint16 type.

It’s going to be quite fiddly to set up some of the encoded bit and byte stuff, but in the first place just get a whole register polled.

Now after rebooting (and even without changing any settings), I get this error message in my “Modbus Poll”:

Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message=‘I/O exception: IOException Error reading response (EOF)’, cause2=null

See my last post. You’re not going to get it to work with poller type ‘coil’, your device has holding registers.

The error message is a step forward - you’ve tried to poll the target device and it has ignored the unsuitable request.

Yes, the weird thing is that yesterday I got that error message I posted, on the “Modbus Data” and the “Modbus Poll” was with Online status. Now the “modbus Data” says I have “No Bridge” because my “Modbus Poll” have that error message I mentioned above.

I tried already changing to the Type “holding” and then even rebooted RPi but still always the same error message. :frowning:

I even tried to revert back to the exact settings I had yesterday when this had stopped giving me this error in the “Modbus Poll”, but now I am always getting this message. :frowning:

I am now stuck again.

EDIT:

After I mess with some settings (mostly by simply changing the “Id” of “Modbus Data” and the “Start” on “Modbus Poll”), there is now a new error message:

Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null

EDIT 2:

Ok, now I changed it to “coild, or digital out(DO)” and it stayed online, but it gave me again the same message in “Modbus Data” that I had before.

So then I changed to “holding” as you suggested and now I get a new error message in my “Modbus Data”:

writeType=coil, writeStart=null, and writeValueType=null should be all present, or all missing! Alternatively, you can provide just writeTransformation, and use transformation returning JSON.

EDIT 3:

IT’S ALIVE!!! IT’S ONLINE!!!

Now what? Ahahaha

EDIT 4:

… nope, back again to COMMUNICATION_ERROR in “Modbus Poll” with this error:

Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null

Your serial communication is not working. You can’t guess at this stuff; you’ll need to set the port, baud, parity, bits correctly -then leave that part alone. You will also need toknow the modbus ID that you set on your device.

While you’re experimenting to get your settings correct, it’s going to be much easier to use some third party software tool like mbpoll. These will let you try this and that.
openHAB expects you to know what you want before you configure, so it won’t help you.

1 Like

Thank you for the tip, but although I did installed and run already some tests, it doesn’t seem to be worth nothing. :frowning:

Here is one of the output of the many tests I did:

# mbpoll -a 1 -b 9600 -t 3 -r 1 -c 2 /dev/ttyRS485
mbpoll 1.0-0 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright © 2015-2019 Pascal JEAN, https://github.com/epsilonrt/mbpoll
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions; type 'mbpoll -w' for details.

Protocol configuration: Modbus RTU
Slave configuration...: address = [1]
                        start reference = 1, count = 2
Communication.........: /dev/ttyRS485,       9600-8E1 
                        t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Connection timed out
-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Response not from requested slave
-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Resource temporarily unavailable
-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Invalid CRC
-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Resource temporarily unavailable
-- Polling slave 1... Ctrl-C to stop)
Read input register failed: Response not from requested slave
^C--- /dev/ttyRS485 poll statistics ---
6 frames transmitted, 0 received, 6 errors, 100.0% frame loss

Any other ideas?

EDIT:

Ok, right now this is actually “jumping” with these errors

2022-07-28 01:54:42.936 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException Truncated response: awaited null bytes, but received null', cause2=null
2022-07-28 01:54:43.593 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException Truncated response: awaited null bytes, but received null', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 00 ', cause2=null
2022-07-28 01:54:44.250 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null
2022-07-28 01:54:44.902 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null
2022-07-28 01:54:50.988 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 89 ', cause2=null
2022-07-28 01:54:51.666 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 89 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null
2022-07-28 01:54:52.326 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null
2022-07-28 01:54:54.320 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null
2022-07-28 01:54:54.989 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 00 ', cause2=null
2022-07-28 01:54:55.644 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null
2022-07-28 01:54:58.509 [INFO ] [ab.event.ThingStatusInfoChangedEvent] - Thing 'modbus:poller:modbus:modbuspoll' changed from OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null to OFFLINE (COMMUNICATION_ERROR): Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 01 83 ', cause2=null

EDIT 2:

Now it’s all back online once again…

I even got on my “Modbus data” info on the items I had associated with some channels.

Channel “Value as Number” I got 2 and 2.0 in “Value as String”.

Channel “Last Successful Read” I also got a timestamp.

Now, looking into the documentation, there is something I am not getting. They say the result of the address can go up to 247 (I suppose the address is the number I should use to get different information and therefore I should create multiple “Modbus Data” things, each for each thing I want to do), but in the “Modbus Poll” I can only put the Lenght up to 125.

Maybe I am missing something here?

I should perhaps have explained that you must not try to use openHAB and a tool like Fieldtalk at the same time; they would fight on the serial bus.

There are addresses and addresses in Modbus, representing different things.

An idealised Modbus device has an address, a “Modbus ID” or “Slave ID”, often set by switches at installation time.

Many modbus devices may share the same serial bus, each must be set up with a unique ID to allow them to share.

The Modbus ID remains a necessary part of the Modbus standard whether or not you actually have multiple devices. You have to set a valid one on your device and other boxes will need to know it to talk to your device.

The value of the ID is limited to 1 to 247 - other values like 0 and 256 are reserved.

Your device manual assumes you already knows this, and just describes how to set the ID on the switches of the modbus interface board.
Read what you have set on yours, and use it every time.

This is not related to the address set on any “indoor units”, that is private business for Samsung, on their internal network.

Oh, ok. So I should stop OH service and then I should use the mbpoll, right?

Regarding the other parts you wrote, I honestly didn’t get it (sorry).

So, in the manual they have this “Modbus PDU address” in that table with some kind of basic formula that goes like this, e.g.: (50 + (IU[0…47]*50)) + 0

So by reading this, I interpret the IU from 0 to 47 as being the different possible IDs of, let’s say, an internal unit. Is it correct?

So let’s say I want to set the temperature on one specific unit inside that goes by the ID 12 for instance.

As far as I can understand by the manual, I would need to do this: (50 + 12*50)) + 8 = 658

This is way above 247…

So I definitely don’t get it and I am clearly missing something here.

Also, I still not understanding why I am limited to use on OH a Length up to 125 only.

I am trying to setup a virtual meeting with a technician but, at this stage, it will take time since now everyone’s on holidays. If eventually I could solve this by myself, I would be very pleased (and understanding how I did it, obviously :smiley: ).

EDIT:

My RPi auto reboots every night and now that I noticed, after the last reboot I have, once again, the error message on my “Modbus Poll” (yesterday night I stopped having this message and it was online):

Error with read: org.openhab.core.io.transport.modbus.internal.ModbusSlaveIOExceptionImpl: Modbus IO Error with cause=ModbusIOException, EOF=false, message='I/O exception: IOException CRC Error in received frame. 0 bytes of payload () with invalid CRC of 00 00 ', cause2=null

Now the weird thing is, I went inside that thing (Modbus Poll), hit “Save” and that’s it, it came back online and stayed… What is eventually causing this to happen at each reboot?

It’s not weird if you understand what ‘online’ means for a Thing.
It does NOT mean “working”.
It means the configuration is acceptable (but not necessarily correct) and the resources needed are available e.g. a serial port in this case.
It’ll say ‘online’ with the wires disconnected.

Most Things will set themselves offline if it actually tries to do something and fails, and probably try again later but exact details are very dependent on the technology of the binding involved.

For Modbus serial, “Bridge Thing online” boils down to “the USB RS-485 adaptor is present”. It tells you nothing about the remote device.
This is by design, because there might be several remote devices on the same serial bus, sharing the same Bridge, some working and some not.

Modbus is really simple. That does not make it easy to understand and set up, it requires some technical knowledge.
Let’s see if you can pick some up.

To repeat -

Many Modbus devices can be attached to one serial wire.
There can be only one Master - that’s openHAB or your Fieldtalk tool.
(So you can see why you can only test with one of those at a time)

All the other devices must be Slaves. They lay there doing nothing, until the Master queries them, only speaking when spoken to.

How do they know who the Master is talking to?
Each slave has an ID number set which must be unique on that wire. The rules say that must be 1 to 247.
The rules say that must be used even if there’s only one slave. (Because a slave can have no idea if it is the only one.)

The Master says “Hey you, number 6, gimme some data XYZ”.
All slaves without ID 6 ignore it.
If there isn’t a slave with ID 6, nothing happens.
If there is a slave 6, it decides if it can answer, then it might send a reply, or send a rejection, or ignore if it just can’t do it.

In your case, the slave is your Samsung modbus interface card, and the ID of that is set by switches at installation time.

You must identify what your slave ID has been set to, and use only that with either openHAB or Fieldtalk.

The funny formula (50 + 12*50)) is about register addresses, not ID, and I won’t touch that until you’ve sorted out ID.

That one’s easy. The rules - Modbus rules, not openHAB - say the maximum “packet” size is 256 bytes. With a few bytes taken for management use, you can only fit 125 x 2-byte registers in the packet.
I said it was simple really.

1 Like

You are amazing. Taking your precious time to spend it lecturing a noob what Modbus is and how it works.

Thank you so much man, if you ever come to Portugal, let me buy you a beer or two. :smiley:

PS: I will wait for next week, as that’s when a technician comes back from holidays and I will see if he can help me on knowing what’s the ID, because now I get it that without the ID, I won’t even be able to “talk” with the equipment. :slight_smile:

Can you actually look at the switches on your Modbus card? The manual tells you how to “read” them. The ID is probably set to 1.

I can’t right now, I’m not in that house. Can only access the RPi remotely.

I will take a look into that later on. But now that you mention it, if I remember correctly, the guy that installed it mentioned something that he had setup it to F1, F2, etc.

Does this makes any sense? Because there are like 4 or 5 external units, so probably each external unit has one Modbus and each have an ID.

But I just don’t know how does this controls each individual internal unit, since they did not changed anything internally (maybe it’s not needed).

By the way, does this means that I cannot set my “Modbus Serial Slave” thing to have the ID 1?

Maybe that’s messing up with the unit ID, does this makes any sense?

Should I change my serial thing ID to something like, let’s say, 200?

Nope.

You have one Modbus board. So far as openHAB is concerned, there is only one device, one ID.

The card is acting as a gateway between standard Modbus and whatever Samsung do on their private network. The private network is not visible to openHAB.

The view from openHAB will be one Modbus device , with data available in several blocks of registers, each block being whatever Samsung have decided.

That’s where the funny formula comes in - the Samsung indoor/outdoor units are mapped to that register block according to the private Samsung i.d., which doesn’t interest openHAB. But you have to work out that your unit F1 or whatever it is, is going to appear as Modbus register 1234 or whatever.

Actually I think they installed 5 (one for each external unit), and they are all connected.

This part I honestly did not get.

The formula is for me to use or not? Will that generate a “number” that I should use somewhere in openHAB? If so, should that be the address? Because if it is, then again something does not add up, since the results go way behond 125 as I’ve shown by the example above.

That’s why there’sa complicated manual.
The important picture from there -


Maybe you can draw your own, showing how many indoor/outdoor units you have, and how many Modbus interface.

Note that openHAB has noconnection to indoor/outdoor units at all. It can only talk to the Modbus interfaces, however many you have.

1 Like

Finally I got an answer from the tech support, it seems they haven’t programmed their Modbus and therefore the difficulty from my side in communicating with it…

As soon as I see this with them in person, I will take care of asking all the questions and setup this with them, so that everything can work properly.

I will get back here when I have the final conclusion.

Still, thank you so much once more for your great dedication to this community. :slight_smile:

1 Like