Electronics > Beginners

Temperature sensor RS485 MODBUS RTU?

(1/2) > >>

onesixright:
Hi All,

Maybe someone can shed some light on this.  TBT didn't go threw the modbus rtu protocol, maybe thats where the problem lies  :-[ Just a case of RTFM?

I have a RS485 sensor, which I hooked to to a USB / RS485 adapter. Seems to work fine, but I don't fully understand how this operates.

I connect the sensor, open an serial program, and data starts to flow. Basically it is pushed every second.


--- Code: ---data:
T: 22.2  H: 56.1T: 22.2  H: 56.1T: 22.2  H: 55.3T: 22.2  H: 55.3T: 22.2  H: 54.7T: 22.2  H: 54.7T: 22.2  H: 54.7T: 22.2  H: 54.1
--- End code ---

Now this I can easily parse, yet i thought I needed to pull the data out of the sensor? When I try that (pulling), i'm getting some checksum errors.


--- Code: ---# Python 3
import minimalmodbus
instr = minimalmodbus.Instrument('/dev/tty.SLAB_USBtoUART', 1, minimalmodbus.MODE_RTU)
instr.serial.baudrate=9600
print(instr.read_register(287, 1))

# response
ValueError: Checksum error in rtu mode: '.3' instead of 'M«' . The response is: 'T: 23.3' (plain response: 'T: 23.3')

--- End code ---


I tried changing registers, but it doesn't not seem to matter. I'm guesing the request is sent, yet since the sensor pushes on its own all gets mixed up.

Since it was a cheap sensor from eBay, of course no datasheet. So i'm a bit in the dark how to configure this. Like changing the address (want to use multiple sensors on the bus).

Maybe it's possible to change the mode, but without a proper databasheet it is hard. Or is this all speced in the modbus rtru protocol?

Anybody that knows whats going on?

Thanks!

Sensor:

https://www.ebay.com/itm/RS485-Temperature-and-Humidity-Transmitter-Sensor-High-Precision-Monitor/123234164113?ssPageName=STRK%3AMEBIDX%3AIT&_trksid=p2057872.m2749.l2649

capt bullshot:
The data you receive from the sensor clearly isn't modbus. It's just some kind of readable ASCII.
Better go ask the seller for some dokumentation how to switch the thing to Modbus mode and which registers to read / write (Modbus is all about registers, but there's no standard how to use the registers).

onesixright:

--- Quote from: capt bullshot on November 22, 2018, 02:31:04 pm ---The data you receive from the sensor clearly isn't modbus. It's just some kind of readable ASCII.
Better go ask the seller for some dokumentation how to switch the thing to Modbus mode and which registers to read / write (Modbus is all about registers, but there's no standard how to use the registers).

--- End quote ---

WILCO.

Thanks, yeah I got this feeling something is not right. So modbus (rtu) would not push on its own data right?

capt bullshot:
No. Modbus is a strict master/slave protocol, the master addresses a particular slave and asks for a register content, then the slave answers / the master writes a register, the slave confirms.

onesixright:

--- Quote from: capt bullshot on November 22, 2018, 04:13:11 pm ---No. Modbus is a strict master/slave protocol, the master addresses a particular slave and asks for a register content, then the slave answers / the master writes a register, the slave confirms.

--- End quote ---

Thanks, thats what I thought.
He did write:

--- Quote --- Automatic output, connection RS485 through serial debugging tool will automatically output temperature and humidity.
--- End quote ---

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod