raw binary example

412 views
Skip to first unread message

Jan Schmidt

unread,
Sep 25, 2022, 12:13:24 PM9/25/22
to TasmotaUsers
Hi all,

I'm trying to decode a Kamstrup water meter which talks with "kamstrup meter protocol". It should be possible to decode it with tasmota sml.

The script I use is as follows and should read out the serial number of the  device.

>D
>B
->sensor53 r
>M 1
+1,3,rN2,0,1200,WASSER,1,20,803F100103E97CD40D
1,xxxxxx03E9330400uuUUuuUUxxx@100000000,serial no,,serial_no,0

But I cannot find the correct decoder syntax (always 0).

enabling debugging I get

16:59:02.302 : 40
16:59:02.349 : 3f 10 03 e9 33
16:59:02.396 : 04 00 04 83 da
16:59:02.443 : 69 cc a0 0d

the parameter number of the serial number is 03e9, serial number itself in this example is 0483DA69 - the hex reprensentation of  75749993.

The starting 40 is regarding of the docu the last byte of the previous telegram. So it can be part of the answer at first position like in example above or as the last byte.

It is possible to read out more than one parameter. Here an example with 7 parameters

send string:

803F 10 07 0044 03EC 0063 004A 00F3 0124 012B E2C3 0D

which meen:
rd 7 params
0044: volumen
03ec: hour count
0063: (info)
004a: flow
00f3: (volumen reverse)
0124: (water temp)
012b: (meter temp)

the answer is

3F10
0044 280443 000CAFAB
03EC 330400 0000D668
0063 330200 0000
004A 290200 0000
00F3 280443 00000000
0124 250100 14
012B 250100 15
912B 0D40

and should be decoded to

0044 280443 000CAFAB -> 831.403 (unsigned long int 831403 divided by 1000
03EC 330400 0000D668 -> 54888 (uint)
0063 330200 0000 -> 0
004A 290200 0000 -> 0
00F3 280443 00000000 -> 0
0124 250100 14 -> (unsigned char) 20
012B 250100 15 -> (unsigned char) 21

How should be the right decoder syntax?

Thanks for any suggestion.
Jan

Philip Knowles

unread,
Sep 26, 2022, 3:10:14 AM9/26/22
to Jan Schmidt, TasmotaUsers
Which meter is it?


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Jan Schmidt <jan.sc...@gmail.com>
Sent: Sunday, September 25, 2022 5:13:23 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: raw binary example
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/5290caf6-bba7-4221-b146-0443c93e705dn%40googlegroups.com.

Jan Schmidt

unread,
Sep 26, 2022, 11:29:58 AM9/26/22
to TasmotaUsers
I want to use it for Multical 21 (water flow meter) and Multical 302 (heat energy meter).

But for MC302 an additional PWM output for activating the communication modul (i.e. via servo motor) is required.

Jan

Philip Knowles

unread,
Sep 26, 2022, 11:50:24 AM9/26/22
to Jan Schmidt, TasmotaUsers

Doesn’t it use Wireless-MBus if so would rtl-433 be a better option?

 

Sent from Mail for Windows

 

From: Jan Schmidt
Sent: 26 September 2022 16:30
To: TasmotaUsers
Subject: Re: raw binary example

 

I want to use it for Multical 21 (water flow meter) and Multical 302 (heat energy meter).

But for MC302 an additional PWM output for activating the communication modul (i.e. via servo motor) is required.

Jan

knowles...@gmail.com schrieb am Montag, 26. September 2022 um 09:10:14 UTC+2:

Which meter is it?

 

Jan Schmidt

unread,
Sep 26, 2022, 3:31:08 PM9/26/22
to TasmotaUsers
Both meters use W-Mbus as well. But with encrypted AES.

This could not be decoded by rtl_433. And my energy provider won't provide my the AES key. So the only way to read out the meter is the optical eye with kamstrup meter protocol (or a camara with less information).

Krummtal Digital Services

unread,
Jan 19, 2024, 10:09:24 AM1/19/24
to TasmotaUsers
Hi,
were you able to decode the readings from the MC21?
I'm having the same problem. I'm getting useful infos from register 0x0044 which is volume as shown in display in hex format, but i can't decode it to correct decimal value and send it via mqtt.
Known registers for Multical21:
0x0044: "Volume register"  (m3, as shown on the display of the meter)
0x004A: "Current flow" (liters per hour)
0x00EF: "Volume" (liters)
0x03EA: "Time"
0x03EB: "Date"
0x03E9: "Serial number"

Unfortunately i can't manage to simply decode the incoming hex values (i can see them in dump with "sensor d1") to decimal format or as workaround send the received hex values directly and unchanged via MQTT so that the calculation part could be done elsewhere f.e in Node-RED.
Thanks
Ralf

Philip Knowles

unread,
Jan 20, 2024, 1:45:49 AM1/20/24
to Krummtal Digital Services, TasmotaUsers
Don't know if this helps
The first 3 bytes set the units and data format
29 = l/hr
02 = number of bytes
00 = Sign & exponent

The next 2 bytes would be the data MSB LSB




From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Krummtal Digital Services <ralf....@gmail.com>
Sent: Friday, January 19, 2024 3:09:23 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: raw binary example
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Krummtal Digital Services

unread,
Jan 20, 2024, 6:27:41 AM1/20/24
to TasmotaUsers
Hey, thank you Philip.
Interesting document about the Kamstrup protocol. Haven't found that so far.
Now I know what the 3 Bytes between registerID and the register value mean.
In my case they give
28 = m^3
04 = for 4 Bytes 
43 = "my" Sign & exponent, which probably says I have to divide the result by 1000, but that's only guessing from the difference between the readout and the meter display, since I couldn't really understand that one.

Now my last problem is how to formulate that in the Tasmota script to deliver the result via MQTT, since I couldn't work out how the meter metrics have to be set in Tasmota script.
The received message from my meter is
40 3f 10 00 44 28 04 43 00 03 35 5f 15 35 0d
and I know it says that the result is 0003355fh = 210271d divided by 1000 and that results in 210,271 m^3 which is exactly the value the display shows on the watermeter.
But I can't get Tasmota to convert the received hex string to dec and  send the result via MQTT.
I tried multiple versions of
1,3F100044kstr@i0:100,Volumenstrom,m³,Volume,2
1,3F100044kstr@i1:100,Volumenstrom,m³,Volume,2
1,3F100044280443uuuuuuuu@10, Verbrauch1uu,m³, Verbrauch1uu,16
1,3F100044280443bcd3@10, Verbrauchbcd3,m³, Verbrauchbcd3,16
1,3F100044280443xxuuuuuu@10, Verbrauch2uu,m³, Verbrauch2uu,16
1,3F100044280443xxxxuuuu@10, Verbrauch3uu,m³, Verbrauch3uu,16
1,3F100044280443xxxxxxuu@10, Verbrauch4uu,m³, Verbrauch4uu,16
but no success.
Probably someone can give me a hint.
Even a simple raw export of the hex value will help me, so I'll be able to convert the value later f.e. in Node-RED or st. similar.
Thanks

Jan Schmidt

unread,
Jan 20, 2024, 2:51:32 PM1/20/24
to TasmotaUsers
currently there is no need for digging with raw binary with kamstrup.
The Kamstrup protocol is fully supported (including checksum).


BTW: slow down your cycle time for reads to (much) more than a minute. I killed the battery within a year and 30s cycle time.

Jan

Philip Knowles

unread,
Jan 20, 2024, 11:53:36 PM1/20/24
to Jan Schmidt, TasmotaUsers
If you're extracting a word you should use UUuuUUuu or uuUUuuUU or U32 or u32 depending on whether it's LSB-MSB or MSB-LSB. If it's 'signed' it should be a variant of SSssSSss etc. Tasmota then does the calculation of the raw value from the bytes.
From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Jan Schmidt <jan.sc...@gmail.com>
Sent: Saturday, January 20, 2024 7:51:32 PM

To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Re: raw binary example
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.

Krummtal Digital Services

unread,
Jan 21, 2024, 9:55:15 AM1/21/24
to TasmotaUsers
Thanks @all
I can report success with my Kamstrup Multical 21 water meter.
Aim was to periodically read the total volume of consumed water as also shown on the meter display with my D1 mini based Tasmota wifi IR-Reader .
I had success with following tasmota script settings:
+1,5,kN2,0,1200,KSMC21,4,3600,3F100100444DC00D  (where 5 is RX GPIO and 4 is TX GPIO)
1,3F100044kstr@i0:1000,Zählerstand,m³,Zählerstand,19
Result is consumed water in m³

Reply all
Reply to author
Forward
0 new messages