Modbus TCP, Pokeys57E and DS18B20

I’m unable to get the correct DS18B20 values from my Pokeys57E through Modbus.
When the sensor value through the Pokeys software is 24,31 °C,
the value in OH is 158924800 °C.

My modbus config:
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=int32

My items config:
Number temperature “Test [%.2f °C]” (gTemperature) { modbus=“slave1:0” }

Anybody an idea what goes wrong?

Thanks

The manual of Pokeys says that the register of the sensor values are 32-bit.
But the value that i get isn’t the temperature.
No more sensors on the pockey, only one ds18b20

The value i get in OH: 169148416.0 °C

Anybody experience with this?

I guess that should be float32
and the value may need additional conversion as the negatives could have the most high bit set (as seen on another device).

float gives the same value.

I think you are right about the conversion.

Anybody a method how to convert?
The value is LSB first i see, don’t know if that has something to do with it.

Can you get the binary values from Pokeys registers 400 and 401?
Then we can try to manually decode it.

Don’t know how to do that?

Maybe this has someting to do with it:

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.