Author Topic: Temperature sensor RS485 MODBUS RTU?  (Read 3250 times)

0 Members and 1 Guest are viewing this topic.

Offline onesixrightTopic starter

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: nl
Temperature sensor RS485 MODBUS RTU?
« on: November 22, 2018, 02:00:34 pm »
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: [Select]
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

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: [Select]
# 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')


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
 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #1 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).
Safety devices hinder evolution
 

Offline onesixrightTopic starter

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: nl
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #2 on: November 22, 2018, 03:09: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).

WILCO.

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

 

Offline capt bullshot

  • Super Contributor
  • ***
  • Posts: 3033
  • Country: de
    • Mostly useless stuff, but nice to have: wunderkis.de
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #3 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.
Safety devices hinder evolution
 

Offline onesixrightTopic starter

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: nl
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #4 on: November 22, 2018, 04:17:38 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.

Thanks, thats what I thought.
He did write:
Quote
Automatic output, connection RS485 through serial debugging tool will automatically output temperature and humidity.
 

Offline onesixrightTopic starter

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: nl
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #5 on: November 23, 2018, 07:55:55 am »
Well found same sensor on banggood, they had some documentation that I could use.

All works now.
 

Offline bingo600

  • Super Contributor
  • ***
  • Posts: 2041
  • Country: dk
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #6 on: November 25, 2018, 07:24:53 am »
Link ??

/Bingo
 

Offline onesixrightTopic starter

  • Frequent Contributor
  • **
  • Posts: 624
  • Country: nl
Re: Temperature sensor RS485 MODBUS RTU?
« Reply #7 on: November 25, 2018, 10:15:14 am »
Link ??

/Bingo

Same sensor:
https://www.banggood.com/Modbus-RS485-Temperature-and-Humidity-Transmitter-Sensor-High-Precision-Monitoring-p-1159961.html?gmcCountry=CZ&currency=CZK&utm_source=googleshopping&utm_medium=cpc_elc&utm_content=zouzou&utm_campaign=pla-cz-ele-cs-pc&gclid=EAIaIQobChMI86fW-aTv3gIVSsKyCh1_KwM3EAQYAyABEgKD0vD_BwE&cur_warehouse=CN

Link to the files:
http://files.banggood.com/2018/04/software-and-protocol.zip

The short:
- if you hookup to serial terminal program, its start spitting out the data in ASCII.
- when you use with modbus protocol (as intended) it works: to read use input_registers (reg 0 = temp, 1 = humidity)
- change slave address: disconnect all sensors but the one you want to change and do a write_register with address "0"
- change slave id is stored (also after power loss)

Tested with pymodbus (working)

I have two sensors There is a little bit of a difference between the 2.
Code: [Select]
Query sensor on address #1
It's 22.7C with 61.7% RH
Query sensor on address #2
It's 23.0C with 54.8% RH


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf