Modbus TCP, Pokeys57E and DS18B20

I found these in the protocol manual of pokeys and the datasheet of DS18B20.

Is this the output that I get?

Knipsel

Also this script that i found:

I suggest to read the data using external tool, outside of OH.
For example, with modpoll it could be something like this:

./modpoll -a 111 -r 400 -c 2 -1 -t 3 192.168.178.250

This is what I get:

C:\>modpoll -a 111 -r 400 -c 1 -1 -t 3 -p 502 192.168.178.250
modpoll 3.4 - FieldTalk(tm) Modbus(R) Master Simulator
Copyright (c) 2002-2013 proconX Pty Ltd
Visit http://www.modbusdriver.com for Modbus libraries and tools.

Protocol configuration: MODBUS/TCP
Slave configuration...: address = 111, start reference = 400, count = 1
Communication.........: 192.168.178.250, port 502, t/o 1.00 s, poll rate 1000 ms
Data type.............: 16-bit register, input register table

-- Polling slave...
Illegal Data Address exception response!

Illegal Data Address

The data address received in the query is not an allowable address for the slave. More specifically, the combination of reference number and transfer length is invalid. For a controller with 100 registers, a request with offset 96 and length 4 would succeed, a request with offset 96 and length 5 will generate exception 02.

Tried other length combination with no succes

Try this

poll=200
tcp.slave1.connection=192.168.178.250:502
tcp.slave1.type=input
tcp.slave1.id=111
tcp.slave1.start=400
tcp.slave1.length=2
tcp.slave1.valuetype=float32_swap

Reason why I want you to try this.
I got myself over 400 modbus items.
Some are encoded with LSB some with MSB which is a pain in the A**
I had crazy values to like 2001365010340160 to -164215124345
The swap function solved this for me. So I suggest maybe its that

Docs

This one worked :), I only changed float to uint32

But now the value is 100 times to big.
An easy way to convert the number dividing by 100?

Number temperature "Test [%d °C]" <temperature> (gTemperature) { modbus="slave1:0" }

Yes with javascript transfrom service

save as div100.js in openHAB2/transfrom/div100.js

(function(i){
        return (i/100)
})(input)
Number temperature "Test [JS(div100.js):%d °C]" <temperature> (gTemperature) { modbus="slave1:0" }

Transformation may be used within { } as described here

Ready-to-use example is here

This is a diffrent type of transformation. Its modbus binding specific. The other one is generall js transformation
But could be used also, nevery tryed :slight_smile:
http://docs.openhab.org/addons/transformations/javascript/readme.html

@sjief So this is Solved?
If yes please don’t forget to mark your Topic as Solved

Just click the first button on the response that solved your Issue.

Have a nice day :slight_smile:

Strange the conversion isn’t worked. Tried both methods. The value keeps the same :sweat:

@sjief Please show your current configuration. Make sure you have no errors in the log.

There may be a clue from earlier. Changing int with float cannot produce the value, so that tells you that changes do not always take immediate effect. Same probably applies to your transform.

You must at the very least restart OH, and might need to see

Modbus:

poll=200
tcp.slave1.connection=192.168.178.250:502
tcp.slave1.type=input
tcp.slave1.id=111
tcp.slave1.start=400
tcp.slave1.length=2
tcp.slave1.valuetype=uint32_swap

Items:

Number temperature "Test [JS(div100.js):%d °C]" <temperature> (gTemperature) { modbus="slave1:0" }

Sitemap:

sitemap demo label="Main Menu" {
	Frame label="Date" {
		Text item=Date
	}
	Frame label="Demo" {
		Text item=temperature icon="temperature" 

How do I get the log file?

Tried to restart several times, also deleted the modbus.config by going to the directory with cd and than rm modbus.config but no succes.

as described here

Sound like your Modbus config is cached.
I will gladly use @Dim here

@AndrewZ i get this in the log file:

12:26:19.185 [WARN ] [.core.transform.TransformationHelper] - Cannot get service reference for transformation service of type JS
12:26:19.187 [WARN ] [nding.modbus.internal.Transformation] - couldn't transform response because transformationService of type 'JS' is unavailable

Seems that the JS conversion isnt going right

Just to be sure. The value from modbus i.e temperature is right, just decimals are wrong?

Do you have JavaScript Transformation installed?PaperUI -> Add-ons -> Javascript transformation.
Where did you save the div100.js file?

Try to use the transformation like this. In channel config part:

Number temperature "Test [%.1f °C]" <temperature> (gTemperature) { modbus="<[slave1:0:transformation=JS(div100.js)]"}

Notice that format option “%.1f” gives you one decimal. E.g 21.5 °C.

Javascript wasn’t installed :sweat_smile::sweat_smile:

It is working now with “%.1f” instead of “%d” :slight_smile:

1 Like

Good to hear it’s working!

Did you mark your own post as solution? :slight_smile: