The application note aims to help you implement the Kamstrup Multical 602 (or 603 thank's to the similarities with the previous version) and request for class 2 data.
Figures bellow shows how to connect M-bus Module. To connect Acrios M-Bus IoT converter, connect terminals MBUS + and MBUS - to terminals 24 and 25 (in case of Kamstrup modules, the polarity doesn't matter). For more information about Kamstrup Multical 603 have a look here. Datasheet to M-Bus module is here.
Start and Stop Byte has a fixed value.
|Start| | |C Field| | |A Field (Address)| | |Checksum (C+A field)| | |Stop| |
(0x10) | (0x5B) | (0xFE) | (0x59) | (0x16) |
C Field (Control Field, Function Field) - Besides labeling the functions and the actions caused by them, the function field specifies the direction of data flow, and is responsible for various additional tasks in both the calling and replying directions. For short frame it's value is 7B or 5B.
A Field (Address Field) - the address field serves to address the recipient in the calling direction, and to identify the sender of information in the receiving direction. The size of this field is one Byte, and can therefore take values from 0 to 255. The addresses 1 to 250 can be allocated to the individual slaves, up to a maximum of 250. In case of Karmstrup Multical 602 (or 603) If nothing else is specified, the M-Bus module automatically uses last 2 or 3 digits of meter’s customer number as the primary address.
Script below is an example, don't forget to change the M-Bus query accordingly. Address is usually last 2 or 3 numbers of serial number (decimal).
Some version of the Kamstrup needs a higher startup time than 2000 ms (usually it can be more than 6000 ms). Please change it accordingly.
Here's default Lua script:
-----------------------
--- CONFIGURATION -----
-----------------------
----- LoRaWAN ----------
ack = 0 -- 1 for acknowledged, 0 for non-acknowledged
port = 100 -- transmit port
receiveTimeout = 10000 -- the maximum execution time in milliseconds
----- M-BUS -----------
baudrate = 2400 -- baudrate: up to 921600 baud
parity = 2 -- communication parity: 0 for none, 1 for odd and 2 for even parity
stopBits = 1 -- number of stop bits: 1 or 2
dataBits = 8 -- number of data bits: 7 or 8
------ Timing ---------
-- device wakeup interval
periodHours = 2
periodMinutes = 30
-----------------------
-----------------------
-- CONFIGURATION END --
-----------------------
function onWake ()
-- set link parameters - 2400 baud, 8E1
api.mbusSetup(baudrate,parity,stopBits,dataBits)
api.mbusState(1)
api.delayms(2000)
--M-Bus query
b=pack.pack('<b5', 0x10, 0x5B, 0xE3, (0xE3 + 0x5B)%256, 0x16)
status,c,a,ci,ans = api.mbusTransaction(b,3000,1)
api.mbusState(0)
print("From MBus Calorimeter: ")
api.dumpArray(ans)
if #ans < 1 then
buf = "NO DATA RECEIVED"
else
buf = ans:sub(0,6) -- sub(0,6) takes first 6 Bytes from M-Bus answer
end
print("To LoRaWAN: ")
api.dumpArray(buf)
print("Sending to LoRaWAN")
res, rxport, rcvd = api.loraSend(ack, receiveTimeout, buf, port)
print("Done sending")
print("Sleep now, wake in " .. tostring(periodHours) .. "hrs:" .. tostring(periodMinutes) .. "mins.....")
api.wakeUpIn(0,periodHours,periodMinutes,0)
end
function onStartup()
print("Starting up LoRaWAN MBUS default script")
end
Answer:
MBUS: sending command with size of 5 bytes
~>From MBus Calorimeter:
00 : 27 02 08 78 2D 2C 0F 04 00 28 00 00 0C 78 27 02
10 : 08 78 04 07 00 00 00 00 04 15 00 00 00 00 04 22
20 : EE 7D 00 00 04 59 20 4E 00 00 04 5D 20 4E 00 00
30 : 04 61 00 00 00 00 04 2D 00 00 00 00 14 2D 00 00
40 : 00 00 04 3B 00 00 00 00 14 3B 00 00 00 00 84 10
50 : 07 00 00 00 00 84 20 07 00 00 00 00 84 40 15 00
60 : 00 00 00 84 80 40 15 00 00 00 00 84 C0 40 07 00
70 : 00 00 00 04 6D 13 2B B8 28 44 07 00 00 00 00 44
80 : 15 00 00 00 00 54 2D 00 00 00 00 54 3B 00 00 00
90 : 00 C4 10 07 00 00 00 00 C4 20 07 00 00 00 00 C4
A0 : 40 15 00 00 00 00 C4 80 40 15 00 00 00 00 C4 C0
B0 : 40 07 00 00 00 00 42 6C 9F 2C 0F 0C 00 00 00 00
C0 : 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
D0 : 00 00 00 7B 46 A6 02 08 52 00 00 8B 8A 01 00 E3
E0 : 68 A7 04 00 00 00 00 11 13 01 08 01 70 01 0D 00
~>To LoRaWAN:
00 : 27 02 08 78 2D 2C