# RPi ModBus - Openhab does not read data

**URL:** <https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378>\
**Category:** Bindings\
**Created:** [September 28, 2022, 7:59am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378 "2022-09-28T07:59:47Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![sliver001](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@sliver001](https://community.openhab.org/u/sliver001)\
**Post date:** [September 28, 2022, 7:59am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/1 "2022-09-28T07:59:47Z")

</div>

After two days of fighting, I will ask you for help.  
It reads the data from the energy meter through the usb adapter connected to the RPi. They use a python script to read register values. The problem arises when I want to read data through Openhab.

Things:

```csv
Bridge modbus:serial:localSerial [port="/dev/ttyUSB1", id=1, baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu"]
{
         Bridge poller Licznik [start=512, length=3, refresh=10000, type="holding"]
{
            Thing data Faza1 [readStart="512", readValueType="int16"]
            Thing data Faza2 [readStart="513", readValueType="int16"]
            Thing data Faza3 [readStart="514", readValueType="int16"]
 }
}

```

Items:

```csv
Number Licznik_Faza1 "Voltage1 [%.1f V]" <energy> {channel="modbus:data:localSerial:Licznik:Faza1:number"}
Number Licznik_Faza2 "Voltage2 [%.1f V]" <energy> {channel="modbus:data:localSerial:Licznik:Faza2:number"}
Number Licznik_Faza3 "Voltage3 [%.1f V]" <energy> {channel="modbus:data:localSerial:Licznik:Faza3:number"}

```

Here is permissions on serial port:

```yaml
[09:31:31] openhabian@openHABianPi:~$ ls -lhS /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 1 Sep 28 09:27 /dev/ttyUSB1

```

In /etc/default/openhab2 I added:

```csv
EXTRA_JAVA_OPTS="-Dgnu.io.rxtx.SerialPorts=/dev/ttyUSB1"

```

The only difference is that when reading a script, I give the HEX address value, e.g. 0x200 and in Openhab DEC

---

<div class="post-metadata">

**Author:** ![stamate\_viorel](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@stamate\_viorel](https://community.openhab.org/u/stamate_viorel)\
**Post date:** [September 28, 2022, 8:30am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/2 "2022-09-28T08:30:14Z")

</div>

more explanation would help to figure what you want. First are you able to connect or not ? second its normal that your item display a decimal because of this [%.1f V]. What are you expecting to receive as value if what you receive is not correct ?

---

<div class="post-metadata">

**Author:** ![sliver001](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@sliver001](https://community.openhab.org/u/sliver001)\
**Post date:** [September 28, 2022, 9:20am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/3 "2022-09-28T09:20:49Z")

</div>

I can’t connect to Modbus. I have such an error.

```csv
2022-09-28 11:19:19.227 [ERROR] [et.wimpi.modbus.net.SerialConnection] - open port failed: gnu.io.PortInUseException: Modbus Serial Master

2022-09-28 11:19:19.233 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/1 error: open port failed: Modbus Serial Master. Connection SerialConnection@53b02[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@12ae85e[portName=/dev/ttyUSB1]

2022-09-28 11:19:19.238 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - re-connect reached max tries 1, throwing last error: open port failed: Modbus Serial Master. Connection SerialConnection@53b02[portName=/dev/ttyUSB1,port=<null>]. Endpoint ModbusSerialSlaveEndpoint@12ae85e[portName=/dev/ttyUSB1]

2022-09-28 11:19:19.242 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - Error connecting connection SerialConnection@53b02[portName=/dev/ttyUSB1,port=<null>] for endpoint ModbusSerialSlaveEndpoint@12ae85e[portName=/dev/ttyUSB1]: open port failed: Modbus Serial Master

2022-09-28 11:19:19.249 [WARN] [rt.modbus.internal.ModbusManagerImpl] - Could not connect to endpoint ModbusSerialSlaveEndpoint@12ae85e[portName=/dev/ttyUSB1] -- aborting request ModbusPollerThingHandlerImpl.ModbusPollerReadRequest@1b54382[slaveId=1,functionCode=READ_MULTIPLE_REGISTERS,start=512,length=3,maxTries=3] [operation ID bad6bba6-1bb2-449d-a53f-38e74d6ded9b]

```

I have one more idea. Maybe the problem is Modbus Binding. In OH 2.5, I installed it by copying it to /user/share/openhab2/addons/ from 2.5.0 and I’m not sure if it’s correct.  
Could someone please share the files from the newer version with me?  
Now I added such because I did not find others.  
org.openhab.binding.modbus-2.5.0-SNAPSHOT.jar  
org.openhab.io.transport.modbus-2.5.0-SNAPSHOT.jar

---

<div class="post-metadata">

**Author:** ![stamate\_viorel](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@stamate\_viorel](https://community.openhab.org/u/stamate_viorel)\
**Post date:** [September 28, 2022, 10:23am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/4 "2022-09-28T10:23:46Z")

</div>

are planning on staying on 2.5 or upgrade to 3 openhab? for openhab 3 depending on your choise of install enviroment you can see here  
[https://www.openhab.org/docs/administration/serial.html](https://www.openhab.org/docs/administration/serial.html)  
if you plan on staying on 2.5 afraid the new binding will not work on 2.5 so you have to follow this link for configuration  
[https://v2.openhab.org/addons/bindings/modbus/](https://v2.openhab.org/addons/bindings/modbus/)  
Now if you can post more details of the device that you want to connect to like registers id baud. The manual of that device will help establish if you are using the correct parameters to connect to it.  
Sometimes the polarity of the data wires can be wrong also and you dont get anything.  
Post as much information as you can about your setup to get more help

---

<div class="post-metadata">

**Author:** ![sliver001](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@sliver001](https://community.openhab.org/u/sliver001)\
**Post date:** [September 28, 2022, 10:39am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/5 "2022-09-28T10:39:38Z")

</div>

I plan to stay at OH 2.5. I can’t find these files anywhere to install the new binding modbus:  
org.openhab.binding.modbus-2.5.12.jar  
org.openhab.io.transport.modbus-2.5.12.jar

The connections to the adapter are correct because I can read the data from the meter via the phyton script.

```csv

#! /usr/bin/python
from pymodbus.client.sync import ModbusSerialClient as ModbusClient

client = ModbusClient(method='rtu', port='/dev/ttyUSB1', timeout=1, stopbits = 1, bytesize = 8, parity='N', baudrate= 9600)
client.connect()
request = client.read_holding_registers(0x200,1,unit=1)
print(request.registers)

```

At hex 0x200, there is voltage on L1. Here is the modbus documentation from the energy meter that I’m trying to connect to: [LINK](https://vcx.com.pl/wp-content/uploads/2022/02/DTS1946-4P-INSTRUKCJA-KOMUNIKACJI.doc)

I tried to reinstall bindings modbus version 2.5.0 but I have this error:

```csv
2022-09-28 12:52:28.585 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-modbus': Error:

	Resource mvn:org.openhab.addons.bundles/org.openhab.io.transport.modbus/2.5.0 does not contain a manifest

	Resource mvn:org.apache.commons/commons-pool2/2.4.3 does not contain a manifest

```

---

<div class="post-metadata">

**Author:** ![stamate\_viorel](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@stamate\_viorel](https://community.openhab.org/u/stamate_viorel)\
**Post date:** [September 28, 2022, 11:03am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/6 "2022-09-28T11:03:18Z")

</div>

hmm from what i can see in the manual for modbus rtu for voltage the register you need is between 0000-0001 and also its a float value  
so this will be

```auto
Bridge modbus:serial:localSerial [port="/dev/ttyUSB1", id=1, baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu"]
{
         Bridge poller Licznik [start=0000, length=4, refresh=10000, type="input"]
{
            Thing data Faza1 [readStart="0000", readValueType="float32"]
            Thing data Faza2 [readStart="0002", readValueType="float32"]
            Thing data Faza3 [readStart="0003", readValueType="float32"]
 }
}

```

Now for the connection to it please read carrefully  
[https://www.openhab.org/docs/administration/serial.html](https://www.openhab.org/docs/administration/serial.html)

---

<div class="post-metadata">

**Author:** ![sliver001](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@sliver001](https://community.openhab.org/u/sliver001)\
**Post date:** [September 28, 2022, 11:21am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/7 "2022-09-28T11:21:19Z")

</div>

> [@stamate\_viorel](#):
>
> hmm from what i can see in the manual for modbus rtu for voltage the register you need is between 0000-0001 and also its a float value  
> so this will be

I have changed but I have this error all the time

```csv
2022-09-28 13:18:28.569 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing 'openhab-binding-modbus': Error:

	Resource mvn:org.apache.commons/commons-pool2/2.4.3 does not contain a manifest

	Resource mvn:org.openhab.addons.bundles/org.openhab.io.transport.modbus/2.5.0 does not contain a manifest

```

---

<div class="post-metadata">

**Author:** ![denominator](https://community.openhab.org/user_avatar/community.openhab.org/denominator/32/37349_2.png) [@denominator](https://community.openhab.org/u/denominator)\
**Post date:** [September 28, 2022, 11:25am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/8 "2022-09-28T11:25:47Z")

</div>

You cant have 2 programs open the tty port at the same time.

---

<div class="post-metadata">

**Author:** ![stamate\_viorel](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@stamate\_viorel](https://community.openhab.org/u/stamate_viorel)\
**Post date:** [September 28, 2022, 11:31am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/9 "2022-09-28T11:31:56Z")

</div>

> [@sliver001](#):
>
> `Resource mvn:org.openhab.addons.bundles/org.openhab.io.transport.modbus/2.5.0 does not contain a manifest`

also  
[https://community.openhab.org/t/failed-installing-addons/122428/4](https://community.openhab.org/t/failed-installing-addons/122428/4)

---

<div class="post-metadata">

**Author:** ![rossko57](https://community.openhab.org/user_avatar/community.openhab.org/rossko57/32/70263_2.png) [@rossko57](https://community.openhab.org/u/rossko57)\
**Post date:** [September 28, 2022, 2:24pm UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/10 "2022-09-28T14:24:45Z")

</div>

> [@sliver001](#):
>
> Could someone please share the files from the newer version with me?

> **[Download openHAB](https://v2.openhab.org/download/)**
>
> a vendor and technology agnostic open source automation software for your home

See also

> [@openHAB 2.5.x and the sunset of Bintray](https://community.openhab.org/t/openhab-2-5-x-and-the-sunset-of-bintray/121839):
>
> All, The [sunset of Bintray on May 1st](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/) caused existing openHAB 2.5.x installations to no longer be able to download add-ons from the remote repository (because this was actually Bintray). The original plan was to move this content to another place and offer a seamless switch for the users, but unfortunately this turned out to be more complicated than thought, so that it didn’t work out - at least until now. There are two options to fix the problem, though: Use the offline version of the add-…

---

<div class="post-metadata">

**Author:** ![sliver001](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@sliver001](https://community.openhab.org/u/sliver001)\
**Post date:** [October 3, 2022, 12:55pm UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/11 "2022-10-03T12:55:29Z")

</div>

I was able to run Modbus reading in Openhab. Installing the missing stuff from the kar file helped. I can already read data about individual identifiers using the code:

```csv
Bridge modbus:serial:localSerial [port="/dev/ttyUSB0", id=1, baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu"]
{
         Bridge poller Licznik [start=512, length=4, refresh=10000, type="input"]
{
            Thing data Faza1 [readStart="512", readValueType="int16"]
            Thing data Faza2 [readStart="513", readValueType="int16"]
            Thing data Faza3 [readStart="514", readValueType="int16"]
 }
}

```

Unfortunately, for some data only such a double code is given, e.g. 0034-0035 or 0x0E-0x0F. How to read it? When I use the code below, I get stupid things.

```csv
Bridge modbus:serial:localSerial [port="/dev/ttyUSB0", id=1, baud=9600, stopBits="1", parity="none", dataBits=8, encoding="rtu"]
{
         Bridge poller Licznik [start=34, length=4, refresh=10000, type="input"]
{
            Thing data Inport1 [readStart="34", readValueType="int16"]
            Thing data Inport2 [readStart="35", readValueType="int16"]
 }
}

```

Documentation with Modbus addresses is here: [LINK](https://vcx.com.pl/wp-content/uploads/2022/02/DTS1946-4P-INSTRUKCJA-KOMUNIKACJI.doc)

---

<div class="post-metadata">

**Author:** ![stamate\_viorel](https://community.openhab.org/letter_avatar_proxy/v4/letter/s/41988e/32.png) [@stamate\_viorel](https://community.openhab.org/u/stamate_viorel)\
**Post date:** [October 6, 2022, 7:22am UTC](https://community.openhab.org/t/rpi-modbus-openhab-does-not-read-data/139378/12 "2022-10-06T07:22:05Z")

</div>

> [@sliver001](#):
>
> Unfortunately, for some data only such a double code is given, e.g. 0034-0035 or 0x0E-0x0F. How to read it? When I use the code below, I get stupid things.

Well that need to be a float32 or float32\_swap insted of int16
