Modbus – TEMP/HUM meter – F2000TSM – AT-TRH-M-200-V-RS
Maatwerk apparaat/sensor door Feenstra
Informatie:
TESTS:
- Werkt al vanaf 8V
- Gemeten verbruik is 0.014A
Foto’s
Modbus registers
Uitlezen
Modbus gegevens (kort)
Omschrijving: | Waarde: |
---|---|
Modbus type | RS485 |
Modbus protocol | RTU |
Baudrate | 19200 |
Stopbits | 1 |
Bytesize | 8 |
Parity | N |
Omschrijving: | Eenheid: | Register locatie: | Modus functie: | Bytes (eigenlijk x2 (16 bit)): | Formule: | Opmerkingen: |
---|---|---|---|---|---|---|
Temperatuur | C | 0 | 04 | 2 (Float, Big endian > ABCD) | nvt | |
Luchtvochtigheid | % | 2 | 04 | 2 (Float, Big endian > ABCD) | nvt |
READ Voorbeelden (ter info)
DEBUG:pymodbus.transaction:send: 0xb 0x4 0x0 0x0 0x0 0x2 0x71 0x61
1 2 3 4 5 6 7 8 9 10 11 12 |
True DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0xb 0x4 0x0 0x0 0x0 0x2 0x71 0x61 DEBUG:pymodbus.client.sync:will sleep to wait for 3.5 char DEBUG:pymodbus.transaction:recv: 0xb 0x4 0x4 0x41 0xc0 0xcc 0xcd 0xd1 0x11 DEBUG:pymodbus.factory:Factory Response[4] DEBUG:pymodbus.transaction:adding transaction 0 DEBUG:pymodbus.transaction:getting transaction 1 ReadRegisterResponse (2) waarde_0: 16832 waarde_1: 52429 waarde_float: 24.1000003815 |
0x41 0xc0 0xcc 0xcd =Â 41c0cccd = 24.1 graden
WRITE Voorbeelden (ter info)
Adres 20Â instellen met het volgende commando:
1 2 3 4 |
builder = BinaryPayloadBuilder(endian=Endian.Big) builder.add_32bit_float(20.00) payload = builder.build() data = client.write_registers(16, payload, skip_encode=True, unit=11) |
1 2 3 4 5 6 7 8 |
DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0xb 0x10 0x0 0x10 0x0 0x2 0x4 0x41 0xa0 0x0 0x0 0xc7 0x65 DEBUG:pymodbus.client.sync:will sleep to wait for 3.5 char DEBUG:pymodbus.transaction:recv: 0xb 0x10 0x0 0x10 0x0 0x2 0x40 0xa7 DEBUG:pymodbus.factory:Factory Response[16] DEBUG:pymodbus.transaction:adding transaction 0 DEBUG:pymodbus.transaction:getting transaction 1 WriteMultipleRegisterResponse (16,2) |
Zet naar 9600Â baudrate met het commando:
1 2 3 4 |
builder = BinaryPayloadBuilder(endian=Endian.Big) # endian=Endian.Little / endian=Endian.Big builder.add_32bit_float(2.00) payload = builder.build() data = client.write_registers(18, payload, skip_encode=True, unit=11) |
1 2 3 4 5 6 7 8 |
DEBUG:pymodbus.transaction:Running transaction 1 DEBUG:pymodbus.transaction:send: 0xb 0x10 0x0 0x12 0x0 0x2 0x4 0x40 0x0 0x0 0x0 0x47 0x62 DEBUG:pymodbus.client.sync:will sleep to wait for 3.5 char DEBUG:pymodbus.transaction:recv: 0xb 0x10 0x0 0x12 0x0 0x2 0xe1 0x67 DEBUG:pymodbus.factory:Factory Response[16] DEBUG:pymodbus.transaction:adding transaction 0 DEBUG:pymodbus.transaction:getting transaction 1 WriteMultipleRegisterResponse (18,2) |
Python scripts
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/usr/bin/env python # Script gemaakt door S. Ebeltjes (domoticx.nl) # Kopieren (of delen hiervan) is verboden zonder toestemming van de eigenaar! import f2000tsmth #f2000tsmth.setadres(11, 16) # Adres instellen oudadres,nieuwadres #f2000tsmth.setbaud(11, 4) # Baudrate instellen apparaat adres,baudrate (raadpleeg handleiding) # Aanroep: f2000tsmth.[functie](apparaat id) print f2000tsmth.temp(11) print f2000tsmth.hum(11) |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
#!/usr/bin/env python # Script gemaakt door S. Ebeltjes (domoticx.nl) # Kopieren (of delen hiervan) is verboden zonder toestemming van de eigenaar! method = "rtu" port = "/dev/ttyUSB0" baudrate = 19200 stopbits = 1 bytesize = 8 parity = "N" timeout = 1 retries = 2 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
#!/usr/bin/env python # Modbus uitlezen # Apparaat: F2000TSM - AT-TRH-M-200-V-RS (TEMP/HUM meter) # # Script gemaakt door S. Ebeltjes (domoticx.nl) # Kopieren (of delen hiervan) is verboden zonder toestemming van de eigenaar! from __future__ import division import pymodbus import serial from pymodbus.pdu import ModbusRequest from pymodbus.client.sync import ModbusSerialClient as ModbusClient #initialize a serial RTU client instance from pymodbus.transaction import ModbusRtuFramer from pymodbus.constants import Endian # Nodig voor 32-bit float getallen (2 registers / 4 bytes) from pymodbus.payload import BinaryPayloadDecoder # Nodig voor 32-bit float getallen (2 registers / 4 bytes) from pymodbus.payload import BinaryPayloadBuilder # Nodig om 32-bit floats te schrijven naar register import f2000tsmth_conf try: client = ModbusClient(method = f2000tsmth_conf.method, port = f2000tsmth_conf.port, stopbits = f2000tsmth_conf.stopbits, bytesize = f2000tsmth_conf.bytesize, parity = f2000tsmth_conf.parity, baudrate = f2000tsmth_conf.baudrate, timeout = f2000tsmth_conf.timeout, retries = f2000tsmth_conf.retries) connection = client.connect() except: print "Modbus connectie error / F2000TSM - AT-TRH-M-200-V-RS" # LEES Temperatuur uit def temp(appid): try: data = client.read_input_registers(0, 2, unit=appid) decoder = BinaryPayloadDecoder.fromRegisters(data.registers, endian=Endian.Big) client.close() return round(decoder.decode_32bit_float(), 2) except: print "Modbus register error (temp)" return 0 # LEES Luchtvochtigheid uit def hum(appid): try: data = client.read_input_registers(2, 2, unit=appid) decoder = BinaryPayloadDecoder.fromRegisters(data.registers, endian=Endian.Big) client.close() return round(decoder.decode_32bit_float(), 2) except: print "Modbus register error (hum)" return 0 # SCHRIJF nieuw adres def setadres(appid, newid): try: builder = BinaryPayloadBuilder(endian=Endian.Big) # endian=Endian.Little / endian=Endian.Big builder.add_32bit_float(newid) payload = builder.build() data = client.write_registers(16, payload, skip_encode=True, unit=appid) client.close() print "Adres aangepast van", appid, "naar", newid return 1 except: print "Modbus register error (setadres)" return 0 # SCHRIJF andere baudrate def setbaud(appid, baudrate): try: builder = BinaryPayloadBuilder(endian=Endian.Big) # endian=Endian.Little / endian=Endian.Big builder.add_32bit_float(baudrate) payload = builder.build() data = client.write_registers(18, payload, skip_encode=True, unit=appid) client.close() print "Baudrate aangepast naar", baudrate return 1 except: print "Modbus register error (setbaud)" return 0 |
[#/handleidingen/modbus_F2000TSM_AT-TRH-M-200-V-RS_prive” ]