Ultrasonic heatmeter and Modbus

(stephen krywenko) #1

Hi there i was going to redo my hydronic heating system this spring and I was wonder if anyone has used one of these before: did not cost much $50 on sale on aliexpress which if you add everything together is cheaper then me building the same

it has RS485 on it and I am a little unsure how one would works with it…
the registry doc here 热量表MODBUS协议.zh-CN.en.doc (56.5 KB)

I tried minimalmodbus example :

#!/usr/bin/env python
import minimalmodbus

instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) # port name, slave    address (in decimal)
#instrument.serial.port          # this is the serial port name
instrument.serial.baudrate = 2400   # Baud
#instrument.serial.bytesize = 8
#instrument.serial.parity   = serial.PARITY_NONE
#instrument.serial.stopbits = 1
#instrument.serial.timeout  = 0.05   # seconds
print instrument

status = instrument.read_register(0020, 1) # Registernumber, number of decimals
print status

but i do not get any out put

also what would it be for the ones the use multiple registries if anyone has an idea or thoughts would be nice

(Paul) #2

I was just about to hit the hay and noticed your post. If you still need help tomorrow I can try.

Looking VERY briefly at your code, the timeout is very short and there is a debug setting that is very helpful so try

#!/usr/bin/env python
import minimalmodbus

instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1) # port name, slave    address (in decimal)
#instrument.serial.port          # this is the serial port name
instrument.serial.baudrate = 2400   # Baud
#instrument.serial.bytesize = 8
#instrument.serial.parity   = serial.PARITY_NONE
#instrument.serial.stopbits = 1
instrument.serial.timeout  = 1.0   # seconds
instrument.debug = True

#print instrument

status = instrument.read_register(0020, 1) # Registernumber, number of decimals
print status

also review the register address in the function call, it needs to be the decimal address eg 0x0600 = 1536, so 0020 might be 32 perhaps?

see Autometers DDSD285 Smart Meter Modbus RS485 interfacing and monitoring
we have just been discussing this tonight.

I also have a modbus heatmeter here, I made some progress with it today, it’s not the same model, but it looks quite similar. I will look at your spec sheet tomorrow if I can.

Please add a link to the listing for this heatmeter, I want to find another cheap supplier.

(stephen krywenko) #3

you can buy them here

I never tried your suggestion as of yet was just about to hit the hay myself just thought I provide you with a link first. and I let you know what happens tomorrow

(Paul) #4

Hope you don’t mind I converted .doc file to a .pdf
TailKuKe_heatmeter_modbus.pdf (200.7 KB)

And I also just grabbed the register table below to save keep referencing the docs once you get it communicating, the first thing I notice is that the reg addresses do not appear to be hex despite the leading zero’s (0009 is followed by 0010 not 000A) so I now think your function call should be

#!/usr/bin/env python
import minimalmodbus

instrument = minimalmodbus.Instrument('/dev/ttyUSB0', 1)
instrument.serial.baudrate = 2400
instrument.serial.timeout  = 1.0
instrument.debug = True

status = instrument.read_register(20, 1)
print status

ie it was already decimal(ish) not hex, but the leading zero’s may not be recognized correctly minimalmodbus (I do not know for sure, but it’s an odd way to present an integer).

I also note there are some “xxx flow unit” values which would appear to be a dynamic scale factor, most of the cheaper meters use a fixed scale factor (or floats) but I have been writing code to accomadate dynamic scale factors too as there have been discussions elsewhere on the forum about modbus inverters using dynamic scale factors. I’m not operating at 100% at the moment due to an annoying cold, but when I can I will write a short test script for you if you wouldn’t mind trying it, just to see if my dynamic scale factor solution works ok. But first we need to get it talking I guess. Adding the debug option will hopefully give you more info to get up and running.

My attempts at a universal script doesn’t (yet?) cater for the BCD data types, IMO the time and date read/write operations would be a setup thing like baud and id, not something that you would read each nSecs. For a timestamp I would prefer to use the “polled at” time from the master than the “I believe it’s” time of the meter, it’s just neater and faster.

Register Address Register number The corresponding value name type of data Remark
0001-0001 1 Instantaneous flow INTEGER *
0002-0002 1 Set aside (not enabled) INTEGER
0003-0003 1 Instantaneous flow unit INTEGER *
0004-0005 2 power LONG
0006-0006 1 Power Units INTEGER *
0007-0008 2 Cumulative flow LONG *
0009-0009 1 Cumulative flow units INTEGER *
0010-0011 2 Cumulative heat LONG *
0012-0012 1 The cumulative thermal units INTEGER *
0013-0014 2 The cumulative amount of cold LONG *
0015-0015 1 Cumulative cold units INTEGER *
0016-0017 2 Inlet temperature T1 LONG x0.01 ℃
0018-0019 2 Return water temperature T2 LONG x0.01 ℃
0020-0020 1 status INTEGER *
0021-0022 2 operating hours LONG *
0023-0024 2 clock BCD MMSS - -HH
0025-0026 2 date BCD MMDD YYYY
0027-0027 1 4-20mA output current value INTEGER x0.01mA
0028-0029 2 4mA base value LONG *
0030-0031 2 20mA base value LONG *
0032-0032 1 caliber INTEGER Example 0x0100: diameter of DN100
0033-0034 2 Table No. BCD No. 8 188 Low
0035-0035 1 MODBUS address INTEGER *
0036-0036 1 Table Type INTEGER 0: meter
0037-0037 1 Type of Communication INTEGER 0: MODBUS
0038-0038 1 version number INTEGER 0

(stephen krywenko) #5

okay I tried all your suggestions same error

minimalmodbus.Instrument<id=0x61d280, address=1, mode=rtu,       close_port_after_each_call=False, precalculate_read_size=True, debug=True,   serial=Serial<id=0x695260, open=True>(port='/dev/ttyUSB0', baudrate=2400,   bytesize=8, parity='N', stopbits=1, timeout=1.0, xonxoff=False, rtscts=False,  dsrdtr=False)>

    MinimalModbus debug mode. Writing to instrument (expecting 7 bytes back): '\x01\x03\x00\x14\x00\x01\xc4\x0e' (01 03 00 14 00 01 C4 0E)
  MinimalModbus debug mode. No sleep required before write. Time since previous read: 1549375659619.6 ms, minimum silent period: 16.04 ms.
  MinimalModbus debug mode. Response from instrument: '' () (0 bytes), roundtrip time: 1002.1 ms. Timeout setting: 1000.0 ms.

 Traceback (most recent call last):
    File "./testmodbus", line 16, in <module>
status = instrument.read_register(20, 1) # Registernumber, number of decimals
  File "/usr/lib/python2.7/site-packages/", line 258, in read_register
return self._genericCommand(functioncode, registeraddress, numberOfDecimals=numberOfDecimals, signed=signed)
     File "/usr/lib/python2.7/site-packages/", line 697, in _genericCommand
payloadFromSlave = self._performCommand(functioncode, payloadToSlave)
   File "/usr/lib/python2.7/site-packages/", line 795, in _performCommand
response = self._communicate(request, number_of_bytes_to_read)
    File "/usr/lib/python2.7/site-packages/", line 930, in _communicate
raise IOError('No communication with the instrument (no answer)')
IOError: No communication with the instrument (no answer)

so not sure if it the usb rs486 or the heatmeter it has two wire a red and a white the the red has a negative charge and the white a positive so I assume red is B and white is A
but incase it was something weird i tried to gleam some information from the chip set but currently no luck finding reference texas instrument 22cz5kt - tts721a

i currenttly asked for more info from the company but it spring festival so I probably not hear from them for another week or two

(Paul) #6

I see it says “M-bus” on the PCB, M-bus it different to Modbus.

Mbus is not read like Modbus, with Mbus the whole data set is broadcast rather than read by register addresses. It is usually a different/higher voltage (48v?) than Modbus as the meter is powered via the rs485 rather than being a “2-wire” comms only connection (half-duplex).

How did you get the “Modbus” document? That’s definitely Modbus (I think), so I questio whether it is right for that device or if the PCB has a typo?

edit - The sales page says M-Bus too


edit2 - see MBUS Meter Reader, Sontex 531 Heat Meter for info on OEM Mbus reader (if it does turnout to be Mbus).

(also and the Heatpump thread too)

(stephen krywenko) #7

the company sent it to me the info to me when i requested it…

it supports both apparently – Communication interface:M-bus,RS485

or maybe they sent me the m-bus version when i wanted the rs485 version

to bad I can not find the the that chip anywhere to clear it up

(Paul) #8

rs485 is the connection protocol, Mbus and Modbus are both communication protocols that use rs485. So “Mbus,rs485” isn’t an option list, “Mbus,Modbus” would be an options list.

(stephen krywenko) #9

okay my mistake not so familiar with it

(Brian Orpin) #10

There is a node-red m-bus node.

(Paul) #11

It’s not necessarily a problem, just a different approach needed if it is Mbus. Assuming they sent you the wrong docs, try getting the Mbus docs?

I think there are far more Mbus heat meters than Modbus as the heat meter has no way of self powering and Modbus (at 5v over 1.2km) isn’t able to provide enough power. Most electric energy meters are Modbus as they can be self powered. Although the heat meter I have here is definitely Modbus, I have been successfully communicating with it.

(stephen krywenko) #12

okay thankyou I will ask the the company for the M-bus docs but the reply from them will not happen for atleast a week or so from them once spring festival is over and they are all back at work

(Paul) #13

Another couple of links that may be of use.

(stephen krywenko) #14

okay since I am lazy somedays – would you think this would work for communication they have the same chipset tss721–

if you think it can work then I can patch into the usb cable and attach an esp off the serial and and make a simple wifi connected MBus device

(Paul) #15

I’m afraid my Mbus experience is almost non-existent, I wouldn’t know for sure. Hopefully someone else can jump in and advise you better.

(stephen krywenko) #16

no worries I will chance it - $19.00 total for 2week shipping… it not going to break the bank …

now with the use of mbus I found the docs for chipset tss721a.pdf (261.2 KB)

oops I see I had to order master and not a slave so I ordered the master as well for a couple dollars more