<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Maartendamen&#039;s blog &#187; Plugwise unleashed</title>
	<atom:link href="http://www.maartendamen.com/category/plugwise-unleashed/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maartendamen.com</link>
	<description>Blogging on various IT subjects</description>
	<lastBuildDate>Tue, 22 Nov 2011 21:27:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Plugwise unleashed document released</title>
		<link>http://www.maartendamen.com/2010/08/plugwise-unleashed-document-released/</link>
		<comments>http://www.maartendamen.com/2010/08/plugwise-unleashed-document-released/#comments</comments>
		<pubDate>Thu, 12 Aug 2010 18:34:42 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Plugwise unleashed]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=359</guid>
		<description><![CDATA[Today I am releasing the Plugwise Unleashed document. This document describes most of the Plugwise protocol. The document can be downloaded from the downloads section on my site, or in the bottom of this post. If you would like to know any more detail about the protocol, please drop a comment so I can have [...]]]></description>
			<content:encoded><![CDATA[<p>Today I am releasing the Plugwise Unleashed document. This document describes most of the Plugwise protocol.<br />
The document can be downloaded from the downloads section on my site, or in the bottom of this post.<br />
If you would like to know any more detail about the protocol, please drop a comment so I can have a look.<br />
This is version 0.1 of the document so there might be some mistakes in it, please also let me know.</p>
<p>And last but not least if you like the document and use it, please at least reference my site/my document. Or, you could drop a donation that would be nice.</p>
<a class="downloadlink" href="http://www.maartendamen.com/wp-content/plugins/download-monitor/download.php?id=5" title="Version0.1 downloaded 1575 times" >Plugwise Unleashed (1575)</a>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/08/plugwise-unleashed-document-released/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
		<item>
		<title>Plugwise protocol unleashed part 3: internal clock information</title>
		<link>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-3-internal-clock-information/</link>
		<comments>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-3-internal-clock-information/#comments</comments>
		<pubDate>Sat, 06 Feb 2010 19:35:57 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Plugwise unleashed]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Plugwise]]></category>
		<category><![CDATA[POL]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=149</guid>
		<description><![CDATA[Introduction In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version! DISCLAIMER: use of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version!</p>
<p><strong><span style="text-decoration: underline;">DISCLAIMER: use of the information in these articles is at your own risk.<br />
This information is not supported by Plugwise B.V. in any way.</span></strong></p>
<p>In this part of the series we will have a look at the device information request and response.</p>
<p><strong>Circle internal clock</strong></p>
<p><strong><span id="more-149"></span></strong>This blog post is about the internal clock of the Plugwise circle. This internal clock is used to for example log information about kWh usage per hour.<br />
It&#8217;s important to keep the internal clock in sync with your PC, for correct data readings. Imagine this going wrong: logged kWh information about an device appears in a different hour. Not something you want.</p>
<p>So, how to test this? Well I just fiddled around a bit with my PC&#8217;s date and time.<br />
Using a serial port sniffer I was able to see the following (unknown) data:</p>
<p><img class="alignnone size-full wp-image-150" title="clock_info1" src="http://www.maartendamen.com/wp-content/uploads/2010/02/clock_info1.png" alt="clock_info1" width="619" height="176" /><br />
<em>Image 1: serial port sniffing log after the clock change.</em></p>
<p>Following after that is the following data:<em> </em></p>
<p><em><img class="alignnone size-full wp-image-151" title="clock_info2" src="http://www.maartendamen.com/wp-content/uploads/2010/02/clock_info2.png" alt="clock_info2" width="660" height="172" /><br />
Image 2: more data following the clock change.</em></p>
<p>So looking at this I realized that code 003E must be some kind of extra check, to see if the clock is out of sync.<br />
The 0016 must be the clock set command as it contains extra data in the command.</p>
<p><em><strong>The clock information request (003E)</strong></em></p>
<p>The request is fairly easy:</p>
<p>003E000D6F000055XXXXBF07</p>
<p>003E -&gt; This is the request command code.<br />
000D6F000055XXXX -&gt; This is the mac address of the circle.<br />
BF07 -&gt; This is the CRC16 checksum</p>
<p>The response looks like this:</p>
<p>003F0D52000D6F0000552XXX1325350401457A0EFF</p>
<p>Split up for readability:</p>
<p>003F 0D52 000D6F0000552XXX 13 25 35 04 01 457A 0EFF</p>
<p>003F -&gt; request return command code.<br />
0D52 -&gt; reverse checksum<br />
000D6F0000552XXX -&gt; mac address<br />
13 -&gt; internal clock hour (HEX)<br />
25 -&gt; internal clock minutes (HEX)<br />
35 -&gt; internal clock seconds (HEX)<br />
04 -&gt; internal clock day of the week (HEX)<br />
01 -&gt; ?<br />
457A -&gt; ? looks like some kind of checksum to me.<br />
0EFF -&gt; CRC16 checksum</p>
<p><em><strong>The clock set command</strong></em></p>
<p>The clock set request looks like this:</p>
<p>0016000D6F0000551C140A021501FFFFFFFF112536043B11</p>
<p>Split up for readability:</p>
<p>0016 000D6F0000551XXX 0A 02 1501 FFFFFFFF 11 25 36 04 3B11</p>
<p>0016 -&gt; Command code<br />
000D6F0000551XXX -&gt; Mac address<br />
OA -&gt; Year (HEX) note this is the year in the plugwise style: 2010 = 10 (always substract 2000)<br />
02 -&gt; Month (HEX)<br />
1501 -&gt; Number of minutes (HEX)<br />
FFFFFFFF -&gt; Log buffer address (you can use this to reset your log buffers, more on this in later posts), FFFFFFFF won&#8217;t reset a thing!<br />
11 -&gt; Hour (HEX)<br />
25 -&gt; Minute (HEX)<br />
36 -&gt; Second (Hex)<br />
04 -&gt; Day of the week (HEX)<br />
3B11 -&gt; CRC16 checksum</p>
<p>So now we know how to read and set the internal clock of the plugwise circle.<br />
See you guys next week!<br />
Let me know if you have any questions, and also if there is anything specific you would like to see in the next plugwise unleashed post!</p>
<p>This is a multipart series, the other parts can be found here:<br />
<a title="Part 1" href="http://www.maartendamen.com/?p=89">Plugwise protocol unleashed part 1:  introduction</a><br />
<a href="http://www.maartendamen.com/?p=106">Plugwise protocol unleashed part 2: device information</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-3-internal-clock-information/feed/</wfw:commentRss>
		<slash:comments>17</slash:comments>
		</item>
		<item>
		<title>Plugwise protocol unleashed part 2: device information</title>
		<link>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-2-device-information/</link>
		<comments>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-2-device-information/#comments</comments>
		<pubDate>Mon, 01 Feb 2010 21:36:38 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Plugwise unleashed]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Plugwise]]></category>
		<category><![CDATA[POL]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=106</guid>
		<description><![CDATA[Introduction In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version! DISCLAIMER: use of [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version!</p>
<p><strong><span style="text-decoration: underline;">DISCLAIMER: use of the information in these articles is at your own risk.<br />
This information is not supported by Plugwise B.V. in any way.</span></strong></p>
<p>In this part of the series we will have a look at the device information request and response.</p>
<p><strong>Device information request</strong></p>
<p>The device information request looks like this:</p>
<p><span id="more-106"></span></p>
<p><code>0023000D6F000023XXXX231B</code></p>
<p><strong><code>0023</code></strong> &#8211; indicates the request code, in this case it&#8217;s the device information request code.<br />
<strong><code>00D6F000023XXXX</code></strong> &#8211; is the mac address of the device we are requesting information about.<br />
<strong><code>231B</code> </strong>- is the CRC checksum.</p>
<p><strong>Device information response</strong></p>
<p>The device information response looks like this:<br />
<code>00240025000D6F000023XXXX0A01866F0004DFE801850000047300074AA663800136EE</code><br />
<code>0024 0025000D6F000023XXXX 0A 01 866F 0004DFE8 01 85 0000 0473 0007 4AA66380 01 36EE</code></p>
<p><strong><code>0024</code> </strong>- indicates the response code, in this case it&#8217;s the device information response code.<br />
<strong><code>0025</code> </strong>- unknown, reverse checksum? Not interesting anyway.<br />
<strong><code>000D6F000023XXXX</code> </strong>- mac address of the device we requested information about.<br />
<strong><code>0A</code> </strong>- Year of the internal Plugwise clock, convert 0A to integer and you get 10.. add 2000 to it and you have 2010.<br />
<strong><code>01</code> </strong>- Month of the internal Plugwise clock, convert 01 to integer and you get 1.<br />
<strong><code>866F</code> </strong>- Number of minutes of the internal Plugwise clock, convert 886F to integer and you get 34415. You can use this to calculate the days, hours and minutes, to get a datetime value.<br />
<strong><code>0004DFE8</code> </strong>- Latest log buffer address, each log buffer contains 4 hours of information about the power usage. Convert this to integer, Then use: (logaddress &#8211; 278528) / 32 to get the log address. In this example the log address is: (319464 &#8211; 278528) / 32 = 1279<br />
<strong><code>01</code> </strong>- Relay status (power on/power off) 01=ON, 00=OFF.<br />
<strong><code>85</code> </strong>- Amount of herz the plugin operates on.<br />
I use the following python code to determine the amount of hz:</p>
<pre class="brush: python; title: ; notranslate">
    def determinehz(self, herz):
        &quot;&quot;&quot;
        Determines number of hz of a plugwise device.
        &quot;&quot;&quot;
        if herz == '85':
            return 50
        elif herz == 'C5':
            return 60
        else:
            return 0
</pre>
<p><strong><code>000004730007</code> </strong>- This indicates the hardware version of the circle. No conversion is needed. In this case the hardware version is: 0000-0473-0007.<br />
<strong><code>4AA66380</code> </strong>- This is the firmware version of the circle. The datetime is a POSIX (epoch) timestamp. The following python function converts it to a datetime object:</p>
<pre class="brush: python; title: ; notranslate">
datetime.fromtimestamp(timestamp[, tz])
</pre>
<p>If you have any questions regarding the device information please let me know.. till next week! And happy plugwising! :-)</p>
<p>This is a multipart series, the other parts can be found here:<br />
<a title="Part 1" href="http://www.maartendamen.com/?p=89">Plugwise protocol unleashed part 1: introduction</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/02/plugwise-protocol-unleashed-part-2-device-information/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Plugwise protocol unleashed part 1: introduction</title>
		<link>http://www.maartendamen.com/2010/01/plugwise-protocol-unleashed-part-1-introduction/</link>
		<comments>http://www.maartendamen.com/2010/01/plugwise-protocol-unleashed-part-1-introduction/#comments</comments>
		<pubDate>Sun, 24 Jan 2010 20:53:16 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Plugwise unleashed]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Plugwise]]></category>
		<category><![CDATA[POL]]></category>
		<category><![CDATA[Reverse engineering]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=89</guid>
		<description><![CDATA[Introduction In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version! DISCLAIMER: use of [...]]]></description>
			<content:encoded><![CDATA[<p><code><br />
</code></p>
<p><strong>Introduction</strong></p>
<p>In the Plugwise protocol unleashed series, I will describe the plugwise protocol. As far as I have been able to re-engineer it. I did this re-engineering work because there is no Linux/OSX software available to control your plugwise devices. All information in these series are based on the 2.0 firmware version!</p>
<p><strong><span style="text-decoration: underline;">DISCLAIMER: use of the information in these articles is at your own risk.<br />
This information is not supported by Plugwise B.V. in any way.</span></strong></p>
<p><strong>So what is plugwise anyway?</strong></p>
<p><strong><span id="more-89"></span><br />
</strong></p>
<p>Plugwise is a smart way of measuring power usage using a device called the Circle.<br />
It&#8217;s basically a plug between your device and the power socket.<br />
The device can be used to keep track of the following:</p>
<p>- Current power usage;<br />
- historic power usage, using buffers in the device itself;<br />
- you can also use it to power on/power off a device;<br />
- you can also use it as standby killer (using a schema).</p>
<p>For more information visit: <a title="Plugwise homepage" href="http://www.plugwise.com">http://www.plugwise.com</a></p>
<p><strong>General information</strong></p>
<p>Before we can dive deep into the plugwise protocol, we are first going through some basics of the protocol in part one of this series.<br />
Plugwise uses the zigbee protocol to communicatie over the air.<br />
Once all of your devices have been setup using Plugwise source (the default Plugwise software) you can control your devices using the plugwise stick (this is a little USB stick)</p>
<p><img class="size-full wp-image-90 alignnone" style="margin-top: 1px; margin-bottom: 1px;" title="Plugwise stick" src="http://www.maartendamen.com/wp-content/uploads/2010/01/plugwise_stick.jpg" alt="Plugwise stick" width="320" height="186" /></p>
<p><em>Image 1: the plugwise stick</em></p>
<p>To send commands to the Plugwise stick, plugwise uses a serial communication protocol.<br />
Actually the Plugwise stick has a FTDI FT232 UART aboard. The following information shows up when plugged into a Linux machine:</p>
<p><code>Bus 006 Device 003: ID 0403:6001 Future Technology Devices International, Ltd FT232 USB-Serial (UART) IC</code></p>
<p>The serial communication takes place with the following settings:</p>
<ul>
<li>Baud rate: 115200</li>
<li>Data bits: 8</li>
<li>Stop bits: 1</li>
<li>Parity: none</li>
</ul>
<p><strong>Plugwise data packet</strong></p>
<p>The Plugwise data packet looks like this:</p>
<p><img class="alignnone size-full wp-image-97" title="plugwise_packet" src="http://www.maartendamen.com/wp-content/uploads/2010/01/plugwise_packet.png" alt="plugwise_packet" width="606" height="70" /></p>
<p><em>Image 2: the Plugwise protocol frame.</em></p>
<p>The start frame must be sent before sending any other data, the hexadecimal presentation of the start frame looks like this:</p>
<p><code>\x05\x05\x03\x03</code></p>
<p>The data formats varies, an example might look like this:</p>
<p><code>0017000D6F0000236XXX01</code></p>
<p>This actually is an example of the power change command (switch a device on or off, in this case a device on command)<br />
0017 is the command, <code>00D6F0000236XXX the mac address and 01 the power code (power on)</code></p>
<p>Followed by the data, is the CRC checksum.<br />
The used CRC checksum by Plugwise is a CRC16 checksum (often reffered to as ymodem or zmodem), it has the following properties:</p>
<ul>
<li>Polynomial: 0&#215;11021</li>
<li>Seed value: 0&#215;00000</li>
<li>Xor mask: 0&#215;00000</li>
<li>Width: 16</li>
</ul>
<p>The checksum is generated over the data piece of the packet.<br />
Last part of the packet is the end frame, this is basically a control feed followed by a linefeed. Which looks the following way, in hexadecimal:</p>
<p><code>\x0d\x0a</code></p>
<p>This concludes the first part of the Plugwise protocol unleashed series. If you have any specific protocol questions, please leave them in the comments so I can talk about it in the next part of this serie.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/01/plugwise-protocol-unleashed-part-1-introduction/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

