define(`TITLE', `M-Bus Master, Part 2 (Electricity)')
define(`DATE', `2013-09-09')
define(`CONTENT', `
<a href="http://a385e-5.de/wp-content/uploads/2013/09/Foto-3.jpg"><img class="alignnone size-medium wp-image-145" alt="Foto 3" src="http://a385e-5.de/wp-content/uploads/2013/09/Foto-3-300x225.jpg" width="300" height="225" /></a>

Finally, this MeterBus transceiver is connected to an Arduino Ethernet board and talks to an M-Bus equipped electric powermeter

<a href="http://a385e-5.de/wp-content/uploads/2013/09/kettle.jpg"><img src="http://a385e-5.de/wp-content/uploads/2013/09/kettle-300x221.jpg" alt="kettle" width="300" height="221" class="alignnone size-medium wp-image-167" /></a>

<a href="http://a385e-5.de/wp-content/uploads/2013/09/Foto-2.jpg"><img class="alignnone size-medium wp-image-144" alt="Foto 2" src="http://a385e-5.de/wp-content/uploads/2013/09/Foto-2-300x225.jpg" width="300" height="225" /></a>

The power meter was configured to M-Bux address 0x21, and so the initialize command, sent through the Arduino and the transceiver has been answered correctly:

<code>
so 10 40 21 61 16
success
SO RESP: E5
</code>

<code>so</code> is the command for the firmware to send the following octets on the bus, <code>success</code> is the acknowledgement, that this has been done and <code>SO RESP:</code> is the prefix for the octets received from the bus.

According the the manufacturers <a href="http://gfinder.findernet.com//assets/Series/388/S7EM-BusDE.pdf" target="_blank">documentation</a> the M-Bus command <code>REQ_UD2</code> (see <a href="http://http://www.m-bus.com/mbusdoc/md5.php" target="_blank">here in the M-Bus documentation</a> should be used to request all the measurement data from the powermeter, and it works:

Here without any consumer load:
<code>
so 10 5b 21 7c 16
success
SO RESP: 68 38 38 68 08 21 72 99 51 00 13 2E 19 21 02 01 00 00 00 8C
10 04 <strong>06 00 00 00</strong> 8C 11 04 00 00 00 00 02 FD C9 FF 01 <strong>E3 00</strong> 02 FD DB
FF 01 <strong>00 00</strong> 02 AC FF 01 <strong>00 00</strong> 82 40 AC FF 01 00 00 EB 16
</code>

Here with an electric kettle as consumer load:
<code>
so 10 5b 21 7c 16
success
SO RESP: 68 38 38 68 08 21 72 99 51 00 13 2E 19 21 02 02 00 00 00 8C
10 04 <strong>06 00 00 00</strong> 8C 11 04 00 00 00 00 02 FD C9 FF 01 <strong>DE 00</strong> 02 FD DB
FF 01 <strong>56 00</strong> 02 AC FF 01 <strong>CD 00</strong> 82 40 AC FF 01 00 00 0A 16
</code>

In the above answer of the powermeter the important measurement values are highlighted:

[table]
Data,measurement category,multiplicator and unit,
<code>06 00 00 00</code>,total consumption,0.01kWh,0.06kWh
<code>DE 00</code>,voltage,1V,222V
<code>56 00</code>,current,0.1A,8.6A
<code>CD 00</code>,power,0.01kW,2.05kW
[/table]


<a href="http://files.a385e-5.de/files/NetMeterBusMaster-0.9.tar.gz" target="_blank">Here</a> is the firmware for the Arduino.


This is a closer look into the response data structure:

(Manufacturer IDs can be found <a href="http://dlms.com/organization/flagmanufacturesids/index.html" target="_blank">here</a>.)

[table]
Octet(s), Field, Meaning
<code>68 38 38 68</code>, Preamble with lentgh,
<code>08</code>,          C Field,
<code>21</code>,          A Field,
<code>72</code>,          CI Field, variable data response

<code>99 51 00 13</code>, Ident. No.,
<code>2E 19</code>,       Manufacturer, FIN = Finder GmbH
<code>21</code>,          Version,
<code>02</code>,          Medium, Electricity
<code>02</code>,          Access No,
<code>00</code>,          Status,
<code>00 00</code>,       Signature,

<code>8C</code>,          DIF, ext; instantaneuos value; 8 digit BCD
<code>10</code>,          DIFE, tariff 1; storage 0
<code>04</code>,          VIF, Energy; 10^(4-3)Wh
<code>06 00 00 00</code>, Value, 0.06kWh
<code>8C</code>,          DIF, ext; instantaneuos value; 8 digit BCD
<code>11</code>,          DIFE, tariff 1; storage 1
<code>04</code>,          VIF, Energy; 10^(4-3)Wh
<code>00 00 00 00</code>, Value, 0
<code>02</code>,          DIF, 16bit integer
<code>FD</code>,          VIF, ext; true VIF is next; see table for secondary VIF
<code>C9</code>,          VIFE, ext; Voltage; 10^(9-9)V
<code>FF</code>,          VIFE, manufacturer specific next VIFE
<code>01</code>,          VIFE, 
<code>DE 00</code>,       Value, 222V
<code>02</code>,          DIF, 16bit integer
<code>FD</code>,          VIF, ext; true VIF is next; see table for secondary VIF
<code>DB</code>,          VIFE, ext; Current; 10^(11-12)A
<code>FF</code>,          VIFE, manufacturer specific next VIFE
<code>01</code>,          VIFE,
<code>56 00</code>,       Value, 8.6A
<code>02</code>,          DIF, 16bit integer
<code>AC</code>,          VIF, ext; Power; 10^(4-3)W
<code>FF</code>,          VIFE, manufacturer specific next VIFE
<code>01</code>,          VIFE,
<code>CD 00</code>,       Value, 2.05kW
<code>82</code>,          DIF, ext; 16bit integer
<code>40</code>,          DIFE, tariff 0; storage 4
<code>AC</code>,          VIF, ext; Power; 10^(4-3)W
<code>FF</code>,          VIFE, manufacturer specific next VIFE
<code>01</code>,          VIFE,
<code>00 00</code>,       Value, 0

<code>0A</code>,          Checksum,
<code>16</code>,          Stopbyte,
[/table]
')