<?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>Digits Domotica Blog</title>
	<atom:link href="http://blog.hekkers.net/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hekkers.net</link>
	<description>My Weblog about Domotica and more</description>
	<lastBuildDate>Wed, 01 Feb 2012 19:32:52 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Jenkins, unsigned integers and VB.NET</title>
		<link>http://blog.hekkers.net/2012/02/01/jenkins-unsigned-integers-and-vb-net/</link>
		<comments>http://blog.hekkers.net/2012/02/01/jenkins-unsigned-integers-and-vb-net/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 19:31:00 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2595</guid>
		<description><![CDATA[Fotunately I had my hair cut short recently, cause otherwise I&#8217;d have pulled them all out yesterday! For a project I&#8217;m working on, I need to use the so-called &#8220;Jenkins&#8217;s one-at-a-time&#8221; hash. The algorithm looks like this, in C code: uint32_t jenkins_one_at_a_time_hash&#40;char *key, size_t len&#41; &#123; uint32_t hash, i; for&#40;hash = i = 0; i [...]]]></description>
			<content:encoded><![CDATA[<p>Fotunately I had my hair cut short recently, cause otherwise I&#8217;d have pulled them all out yesterday! <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>For a project I&#8217;m working on, I need to use the so-called &#8220;Jenkins&#8217;s <strong>one-at-a-time</strong>&#8221; hash. The algorithm looks like this, in C code:</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">uint32_t</span> jenkins_one_at_a_time_hash<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span>key<span style="color: #339933;">,</span> size_t len<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">uint32_t</span> hash<span style="color: #339933;">,</span> i<span style="color: #339933;">;</span>
  <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">=</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> len<span style="color: #339933;">;</span> <span style="color: #339933;">++</span>i<span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
    hash <span style="color: #339933;">+=</span> key<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    hash <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    hash <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000dd;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  hash <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  hash <span style="color: #339933;">^=</span> <span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&gt;&gt;</span> <span style="color: #0000dd;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  hash <span style="color: #339933;">+=</span> <span style="color: #009900;">&#40;</span>hash <span style="color: #339933;">&lt;&lt;</span> <span style="color: #0000dd;">15</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">return</span> hash<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>No big deal. Right? Until you have to rewrite this to VB.Net. Here&#8217;s what I started with, and when things got weird:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> Jenkins_one_at_a_time_hash<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> data<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> UInt32
&nbsp;
  <span style="color: #0600FF;">Dim</span> hash <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>
&nbsp;
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> b <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span> In data
   hash <span style="color: #008000;">=</span> hash <span style="color: #008000;">+</span> b
   hash <span style="color: #008000;">=</span> hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span>
   hash <span style="color: #008000;">=</span> hash Xor <span style="color: #000000;">&#40;</span>hash &gt;&gt; <span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span>
  <span style="color: #FF8000;">Next</span>
  hash <span style="color: #008000;">=</span> hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span>   
  hash <span style="color: #008000;">=</span> hash Xor <span style="color: #000000;">&#40;</span>hash &gt;&gt; <span style="color: #FF0000;">11</span><span style="color: #000000;">&#41;</span>
  hash <span style="color: #008000;">=</span> hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">15</span><span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #FF8000;">Return</span> hash
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>While looking at the original code, I knew that with all the bit-shifting going on, there would definitely be overflows; this algorithm has overflow written all over it. So I anticipated some small bumps, but not real big ones&#8230;</p>
<p>OK. I don&#8217;t care about bits falling out of the bucket, as long as this doesn&#8217;t result in exceptions. How wrong could I be&#8230;nearly every line gave me exceptions. But, surprisingly, those exceptions weren&#8217;t thrown by the bit-shifting code, but by intermediate results that exceeded the UInt32&#8242;s maximum value, for example:</p>
<p>3281982255 + 2085403648 = 5367385903; yep, that&#8217;s 33 bits.</p>
<p>OK. Nevermind; I&#8217;ll use a UInt64 and only keep the 32 LSBs. That should do the trick. No! The VB.Net OverlowException told me &#8216;Arithmetic operation resulted in an overflow.&#8217; Yeah I know, with 32 bits it does, but not with 64!<br />
What&#8217;s going on here ?. Lets isolate the problem a bit&#8230;</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> a <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">3281982255</span> <span style="color: #008080; font-style: italic;">' 11000011100111110001001100101111</span>
<span style="color: #0600FF;">Dim</span> b <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">2085403648</span> <span style="color: #008080; font-style: italic;">' 01111100010011001011110000000000</span>
<span style="color: #0600FF;">Dim</span> result <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> a <span style="color: #008000;">+</span> b</pre></div></div>

<p>Line 3 also throws the exception I mentioned above. But why?? The result of a+b is 5367385903, which should perfectly fit in 64 bits. This is becoming really weird &#8230;<br />
Changing the result type to Decimal, with a largest possible value of +/-79228162514264337593543950335 didn&#8217;t help either. Same Exception.</p>
<p>This code works though:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> a <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> <span style="color: #FF0000;">3281982255</span>
<span style="color: #0600FF;">Dim</span> b <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> <span style="color: #FF0000;">2085403648</span>
<span style="color: #0600FF;">Dim</span> result <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> a <span style="color: #008000;">+</span> b</pre></div></div>

<p>But why should I have to this; it&#8217;s stupid &#8211; using 64 bits to store 32 bit values; huh? Since I don&#8217;t work with VB.Net that much, I started looking for compiler directives to ignore overflows in this hash routine. The only thing I could find was this:</p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2012/02/Capture_01-2012.02.01-10.56.23.jpg"><img class="aligncenter size-full wp-image-2609" title="Capture_01 2012.02.01" src="http://blog.hekkers.net/wp-content/uploads/2012/02/Capture_01-2012.02.01-10.56.23.jpg" alt="" width="636" height="154" /></a></p>
<p>Yeah, right, remove integer overflow checks&#8230; at project level. Who invented that? Seems I can&#8217;t use compiler directives in the code at all, and I sure don&#8217;t want to remove all the overflow checks from the project of course. I did a little more testing with the Intxx type variables and saw some strange things happening:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #0600FF;">Dim</span> a <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">1073741824</span> 
<span style="color: #0600FF;">Dim</span> b <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">1073741824</span> 
<span style="color: #0600FF;">Dim</span> result1 <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span> <span style="color: #008000;">*</span> a<span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #FF0000;">2</span> <span style="color: #008000;">*</span> b<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Dim</span> result2 <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> a <span style="color: #008000;">+</span> a <span style="color: #008000;">+</span> b <span style="color: #008000;">+</span> b
<span style="color: #0600FF;">Dim</span> result3 <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>a <span style="color: #008000;">+</span> a<span style="color: #000000;">&#41;</span> <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span>b <span style="color: #008000;">+</span> b<span style="color: #000000;">&#41;</span>
<span style="color: #0600FF;">Dim</span> result4 <span style="color: #FF8000;">As</span> UInt64 <span style="color: #008000;">=</span> <span style="color: #FF0000;">5</span> <span style="color: #008000;">*</span> a</pre></div></div>

<p>Line 3 does <em>not</em> result in an Overflow Exception, but line 4 does. Line 5 does too, but line 6 doesn&#8217;t. It looks like only additions can trigger those overflows? What is this??</p>
<p>Finally I found out that the UInt32 and UInt64 types are not CLS-compliant and that CLS-compliant alternative for UInt32 is Int64. Again, I don&#8217;t want to use 64 bits. I only need 32 of them!</p>
<p>I can&#8217;t be the only one having this trouble, so I started searching what this CLS compliance meant. From what I&#8217;ve read about this, I know now that .NET doesn&#8217;t treat UInt32 values as such internally, which results in the MSB getting back its role as sign bit, which in turn results in a sign bit being shifted out during the arithmetic which eventually results in an Exception&#8230;<br />
So .NET doesn&#8217;t natively support unsigned data types! OK..</p>
<p>After multiple hours of trying all kinds of <em>stupid</em> things to get the right results without exceptions, I ended up with this code:</p>

<div class="wp_syntax"><div class="code"><pre class="vbnet" style="font-family:monospace;"><span style="color: #FF8000;">Public</span> <span style="color: #0600FF;">Function</span> Jenkins_one_at_a_time_hash<span style="color: #000000;">&#40;</span><span style="color: #FF8000;">ByVal</span> data<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span><span style="color: #000000;">&#41;</span> <span style="color: #FF8000;">As</span> UInt32
  <span style="color: #0600FF;">Dim</span> hash <span style="color: #FF8000;">As</span> UInt32 <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span>
&nbsp;
  <span style="color: #FF8000;">For</span> <span style="color: #0600FF;">Each</span> b <span style="color: #FF8000;">As</span> <span style="color: #FF0000;">Byte</span> In data
    hash <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash <span style="color: #008000;">+</span> b<span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span>
    hash <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">10</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL
    hash <span style="color: #008000;">=</span> hash Xor <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash &gt;&gt; <span style="color: #FF0000;">6</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span>
&nbsp;
  <span style="color: #FF8000;">Next</span>
&nbsp;
  hash <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">3</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL   
  hash <span style="color: #008000;">=</span> hash Xor <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash &gt;&gt; <span style="color: #FF0000;">11</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span>
  hash <span style="color: #008000;">=</span> <span style="color: #000000;">&#40;</span>hash <span style="color: #008000;">+</span> <span style="color: #000000;">&#40;</span><span style="color: #000000;">&#40;</span>hash &lt;&lt; <span style="color: #FF0000;">15</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL<span style="color: #000000;">&#41;</span><span style="color: #000000;">&#41;</span> <span style="color: #804040;">And</span> <span style="color: #008000;">&amp;</span>HFFFFFFFFL
&nbsp;
  <span style="color: #FF8000;">Return</span> hash
&nbsp;
<span style="color: #0600FF;">End</span> <span style="color: #0600FF;">Function</span></pre></div></div>

<p>So actually, it comes down to &#8216;manually&#8217; preventing overflows wherever they can occur; even in intermediate results; then why did it take me so long to figure this out???</p>
<p>Hurrying back to Delphi again, yuck!</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2012/02/01/jenkins-unsigned-integers-and-vb-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>No more painful toes</title>
		<link>http://blog.hekkers.net/2012/01/24/no-more-painful-toes/</link>
		<comments>http://blog.hekkers.net/2012/01/24/no-more-painful-toes/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 21:42:45 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[motion sensor]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2573</guid>
		<description><![CDATA[This evening I wrote a sketch to protect my toes better. The sketch switches the LED strip on and off based on motion detection by 2 PIRs. It works The blue LED on the Protoshield indicates when there is motion detected by the PIR. The motion detection turns the LED strip on and it will [...]]]></description>
			<content:encoded><![CDATA[<p>This evening I wrote a sketch to <a href="http://blog.hekkers.net/2012/01/22/bedroom-floor-lighting/">protect my toes</a> better. The sketch switches the LED strip on and off based on motion detection by 2 PIRs. It works <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>The blue LED on the Protoshield indicates when there is motion detected by the PIR. The motion detection turns the LED strip on and it will stay on until a period of 15 seconds with no motion has passed &#8211; only then, the LED strip is turned off again.</p>
<p>The sketch takes care of the &#8220;soft on/off&#8221; feature, by gently raising or lowering the brightness during a configurable time-span.</p>
<p><object width="560" height="340" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/Eni_v2JmGvw?fs=1&amp;hl=en_US" /><param name="allowfullscreen" value="true" /><embed width="560" height="340" type="application/x-shockwave-flash" src="http://www.youtube.com/v/Eni_v2JmGvw?fs=1&amp;hl=en_US" allowFullScreen="true" allowscriptaccess="always" allowfullscreen="true" /></object></p>
<p>All that&#8217;s left to do is cleaning up the code, solder some wires, wait for the enclosure to arrive and give the LED strip, PIRs and Arduino enclosure a place under the bed.</p>
<p>Simple, yet <em>very</em> convenient automation <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2012/01/24/no-more-painful-toes/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Bedroom floor lighting</title>
		<link>http://blog.hekkers.net/2012/01/22/bedroom-floor-lighting/</link>
		<comments>http://blog.hekkers.net/2012/01/22/bedroom-floor-lighting/#comments</comments>
		<pubDate>Sun, 22 Jan 2012 22:45:00 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[LED]]></category>
		<category><![CDATA[motion sensor]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2562</guid>
		<description><![CDATA[Last week I had some trouble getting out of bed during the night without hurting myself. So this evening I decided to do something about that; I need something that can light the floor while someone is walking through the bedroom at night. So I made a list of things with which I could make [...]]]></description>
			<content:encoded><![CDATA[<p>Last week I had some trouble getting out of bed during the night without hurting myself. So this evening I decided to do something about that; I need something that can light the floor while someone is walking through the bedroom at night. So I made a list of things with which I could make something useful for that:</p>
<ul>
<li>An Arduino Duemilanove;</li>
<li>a Protoshield;</li>
<li>2 PIR motion sensors;</li>
<li>a LDR;</li>
<li>a  IRLZ34N MOSFET to drive the LED strip;</li>
<li>a 12V power adapter;</li>
<li>about 2 m. of white LED strip;</li>
<li>2 LEDs (one for power and the other for motion detection);</li>
<li>an Arduino enclosure.</li>
</ul>
<p>&nbsp;</p>
<p style="text-align: center;"><a href="http://blog.hekkers.net/wp-content/uploads/2012/01/DSC_6540_b.jpg"><img class="aligncenter size-full wp-image-2564" title="Automatic Bed light for the night" src="http://blog.hekkers.net/wp-content/uploads/2012/01/DSC_6540_s.jpg" alt="Automatic Bed light for the night" width="550" height="365" /></a></p>
<p>There it is&#8230; our automatic bedroom floor lighting is being tested at this moment. The 2 PIR motion sensors will be mounted under the bed in a way that they will only be able to detect motion caused by moving legs, the LDR will be used to detect whether it&#8217;s dark in the bedroom or not and the white LED strips will be glued to the bottom side of the bed and will light the floor when motion is detected.</p>
<p>The fun thing is that this floor lighting is almost completely built from spare parts (except the enclosure). The 2 PIR motion sensors were the first motion sensors I ever bought, but the lenses were too big for my taste to actually use them. Under the bed the size of those lenses doesn&#8217;t matter. The Duemilanove is one of the many Duemilanoves I have laying around for testing/experimenting, so I can easily do with one less &#8211; I could also have picked an RBBB, Teensy or JeeNode. The number of unused protoshields made me decide for an Arduino. And all the other parts were all purchased in the past with the thought they&#8217;d be handy to have around for when you suddenly need them <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>No RF, Zigbee or Ethernet this time &#8211; this will be a solution that doesn&#8217;t need any other external input, nor do I think I&#8217;ll use the fact that someone&#8217;s walking through the bedroom in the rest of my system. Nevertheless, I&#8217;ll reserve some space on the Protoshield for a XBee Breakout board cause this would actually be a very good place for a Zigbee router on the 2nd floor!</p>
<p>The sketch will be a collection of code  from other sketches I&#8217;m already using, so I hope that at the end of this week I can finish this and never hurt my toes again <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2012/01/22/bedroom-floor-lighting/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Nemef Radaris Evolution and Homeseer</title>
		<link>http://blog.hekkers.net/2012/01/15/nemef-radaris-evolution-and-homeseer/</link>
		<comments>http://blog.hekkers.net/2012/01/15/nemef-radaris-evolution-and-homeseer/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 22:05:19 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Homeseer]]></category>
		<category><![CDATA[Nemef Radaris Evolution]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2548</guid>
		<description><![CDATA[Last summer I became the proud owner of a Nemef Radaris Evolution electronic door lock. It&#8217;s in use for 6 months now and has been unlocked almost 1800 times. In that period of 6 months, the Nemef Radaris Evolution has proven itself as a really solid and reliable piece of equipment. I&#8217;ve never seen nor [...]]]></description>
			<content:encoded><![CDATA[<p>Last summer I became the <a href="http://blog.hekkers.net/2011/08/06/the-nemef-radaris-evolution/">proud owner</a> of a Nemef Radaris Evolution electronic door lock. It&#8217;s in use for 6 months now and has been unlocked almost 1800 times. In that period of 6 months, the Nemef Radaris Evolution has proven itself as a really solid and reliable piece of equipment. I&#8217;ve never seen nor heard of a better solution (no, I don&#8217;t work there). If I would have written a full scale review about the Radaris Evolution, the conclusion would have been  &#8221;Highly Recommended&#8221; &#8211; but since I don&#8217;t do reviews, you&#8217;ll have to do with just the conclusion <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>Combine the Nemef Radaris Evolution furniture with a Nemef RF Module and you&#8217;ve got all the the ingredients to fully integrate the Nemef Radaris Evolution door lock(s) into your Domotica system. However, that&#8217;s where things get harder &#8211; as far as I know, there&#8217;s no (consumer) software available for the connection between the Nemef Radaris Evolution and Home Automation systems. No <em>Plugin</em>, <em>module, app</em> or anything like that to monitor and/or control the Nemef Radaris. Only 3 guys (I know of) have implemented this in their own homebrew system; <a href="http://www.bwired.nl/nemefradaris.asp">Pieter Knuvers</a> is one of them.</p>
<p>But this can change very rapidly; I&#8217;m working on a Homeseer Plugin for the Nemef Radaris Evolution.</p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2012/01/Capture_02-2012.01.15-22.17.231.jpg"><img class="aligncenter size-full wp-image-2552" title="Homeseer Plugin screenshot" src="http://blog.hekkers.net/wp-content/uploads/2012/01/Capture_02-2012.01.15-22.17.231.jpg" alt="Homeseer Plugin screenshot" width="512" height="383" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>With this Plugin (and a <a href="http://www.nemef.nl/custom/instanties/inst_549/9999990193%20leaflet%20Radaris_Evolution_RF-module_LR.pdf">Nemef RF Module</a> (dutch link)) it will be possible to monitor and control up to 4 <a href="http://www.nemef.nl/custom/instanties/inst_549/9999990167%20Brochure%20Radaris%20Evolution.pdf">Nemef Radaris Evolution</a> (dutch link) door furnitures. Opening the door, badge management (yep, you can stow away your programming card), viewing historical data (what badge was used where and when), it&#8217;s all in the Plugin. Want to give a badge access only during a certain time period on a certain day? The Nemef Radaris Evolution Plugin and a small script can accomplish just that.</p>
<p>The basis of the Plugin is almost finished now; I already tested the basic functionality by feeding my own historical data to the Plugin and this looks just fine.</p>
<p>Now it&#8217;s time to provide the necessary event triggers to Homeseer, so that the Nemef Radaris Evolution door furnitures can really become a part of that <em>bigger picture,</em> called Home Automation. <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2012/01/15/nemef-radaris-evolution-and-homeseer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Back in business</title>
		<link>http://blog.hekkers.net/2012/01/03/back-in-business/</link>
		<comments>http://blog.hekkers.net/2012/01/03/back-in-business/#comments</comments>
		<pubDate>Tue, 03 Jan 2012 10:00:23 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Windows Server]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2540</guid>
		<description><![CDATA[One thing I really hate is when hardware is not working. Last November and December will be remembered as the &#8220;Blue&#8221; months, because of the amount of Blue Screens (BSOD) I got. And the problem (with me) is that I just can&#8217;t work on anything else, knowing that some piece of hardware can suddenly break [...]]]></description>
			<content:encoded><![CDATA[<p>One thing I really hate is when hardware is not working.</p>
<p style="text-align: center;"><a href="http://blog.hekkers.net/wp-content/uploads/2012/01/Capture_01-2012.01.02-23.43.17.jpg"><img class="aligncenter size-full wp-image-2542" title="Blue screens" src="http://blog.hekkers.net/wp-content/uploads/2012/01/Capture_01-2012.01.02-23.43.17_r.jpg" alt="Blue screens" width="600" height="431" /></a></p>
<p>Last November and December will be remembered as the &#8220;Blue&#8221; months, because of the amount of Blue Screens (<a href="http://en.wikipedia.org/wiki/Blue_Screen_of_Death">BSOD</a>) I got. And the problem (with me) is that I just can&#8217;t work on anything else, knowing that some piece of hardware can suddenly break down (again). These things consume all my time and energy until it&#8217;s fixed.. but I think I&#8217;ve got it fixed now!</p>
<p>This time my<a href="http://blog.hekkers.net/2011/03/16/intel-i3-server-below-30w/"> rather new Hyper-V server</a> was suffering from BSOD&#8217;s. It started in November and it got even worse in December; I even had to show the rest of the family what button had to be presssed to get this server on his feet again for when I was not at home.. big fail! Life did still go on of course, but when your complete Domotica system and Internet connection stops working, you realize how much you&#8217;re used to  all the &#8220;good stuff&#8221; it brings and how fast you <em>think</em> you can&#8217;t live without it anymore.</p>
<p>This time it was one of the SDRAM modules inside the server that was causing these BSODs. But since I didn&#8217;t want to just start replacing hardware components randomly, I had to be sure what exactly was causing these blue screens. So I waited until I had enough BSOD occurrences to justify buying a new set of 4 x 4GB RAM modules. So on December 24th of 2011 I replaced the RAM and the problem disappeared &#8211; I&#8217;m back in business!</p>
<p>I know I&#8217;ll never be able change the fact that my productivity drops below zero when I&#8217;m facing these kind of problems. On the other hand, a few years ago I would have thrown this malfunctioning server out the door and start building a new one <em>immediately</em> &#8211; but now I take my time, observe where the errors come from and solve the problems in a more relativistic way. OK, I will miss some power consumption &#8220;blips&#8221;; I have to turn on the lights manually, etcetera &#8211; but after all, it&#8217;s just a hobby <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>There is one nice side effect of all this, and that&#8217;s that while I was going through all the scenarios to solve the issue, I found a list of components with which I can build a new sub-20W server with even more processing power than I have now. That&#8217;s a reduction of 33% in power consumption&#8230; sounds tempting!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2012/01/03/back-in-business/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Energy flow in Watt</title>
		<link>http://blog.hekkers.net/2011/12/08/energy-flow-in-watt/</link>
		<comments>http://blog.hekkers.net/2011/12/08/energy-flow-in-watt/#comments</comments>
		<pubDate>Thu, 08 Dec 2011 21:01:40 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[HVAC]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2521</guid>
		<description><![CDATA[Now that I have sensors on all the radiators  I can sit back, relax and watch everything happen. I needed some help of the rest of the family to keep the doors upstairs closed, cause that seems to be very hard for some, but after a few days they all knew that when the doors were [...]]]></description>
			<content:encoded><![CDATA[<p>Now that I have <a href="http://blog.hekkers.net/2011/11/29/hb-sensors-finished-and-installed/">sensors on all the radiators</a>  I can sit back, relax and watch everything happen. I needed some help of the rest of the family to keep the doors upstairs closed, cause that seems to be very hard for some, but after a few days they all knew that when the doors were closed, daddy was doing one of his experiments again.. yep, this house is one big laboratory <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>However, doing nothing is not really my style, so I went on reading about radiators, calculations etcetera and found some calculation tools for my <a href="http://www.radson.com/nl/producten/paneelradiatoren/radson-compact.htm">RADSON Compact</a> and <a href="http://www.jaga.co.uk/products/family/tempo-lst">Jaga Tempo</a> radiators. And although it doesn&#8217;t add new data, I thought it would be fun to see if I could use the formulas used in these &#8216;Installer tools&#8217; (in fact Excel sheets) for myself.</p>
<p>And I was right; based on radiator model, dimensions and specific properties it should be possible to calculate the actual heat output performance of the radiators in other circumstances (temperatures) . If you know the heat output conform the European standard <a href="http://www.nos.cybercomm.nl/ltv/en442nl.htm">EN442</a> (dutch) for a specific combination of model &amp; dimensions, the so called n-factor (aka the emission line slope) and the air-temperature, you can calculate the heat output for any combination of flow- and return temperature!</p>
<p>So that&#8217;s what I did last evening &#8211; preparing my system for these semi-realtime heat output calculations.</p>
<p>First I had to add some more flexibility to the database; creating fields for this purpose only didn&#8217;t feel right, so I added a free text field in which I could &#8216;dump&#8217; anything I want &#8211; <em>device specific properties</em>. As an example, here are the properties of one of the radiator devices in my <em>system</em> (it feels like &#8216;<em>Domotica system&#8217;</em> doesn&#8217;t quite cover the capabilities anymore):</p>
<pre>TYPE=RC
QN=1407
N=1.3404
TAIR=BATHROOM.TEMP</pre>
<p>This means this device:</p>
<ul>
<li><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">is of type RC (as in <strong>R</strong>adson <strong>C</strong>ompact), </span></li>
<li><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">has a heat output of 1407 Watt, based on its dimensions and EN442 at 75/65/20 °C (that&#8217;s flow, return and air temperature);</span></li>
<li><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">has an n-factor</span><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;"> of 1.3403;</span></li>
<li><span class="Apple-style-span" style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px; white-space: normal;">and that the air temperature can be taken from the device value called BATHROOM.TEMP (a <a href="http://en.wikipedia.org/wiki/Foreign_key">foreign key</a>, so to speak)</span></li>
</ul>
<p>So every line defines a device specific property, which are dynamically added to the base device class at run-time.</p>
<p>And I had to write 2 Delphi functions to do the math, primarily based on these formulas:</p>
<div><a href="http://blog.hekkers.net/wp-content/uploads/2011/12/Capture_01-2011.12.08-21.10.14.jpg"><img class="alignnone size-full wp-image-2522" title="Capture_01 2011.12.08 21.10.14" src="http://blog.hekkers.net/wp-content/uploads/2011/12/Capture_01-2011.12.08-21.10.14.jpg" alt="" width="198" height="196" /></a></div>
<p>Q is the variable that needs to be calculated, the rest is all known &#8211; piece of cake!</p>
<p>Just make sure you take care of unexpected results, like divisions by zero or raising negative values to a power- working with live data can produce strange results, where a radiator can suddenly start cooling instead of heating <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>I added the calculated heat output (the &#8220;W&#8221; column) in the table with all the other sensor data as can be seen below:</p>
<div><a href="http://blog.hekkers.net/wp-content/uploads/2011/12/Capture_02-2011.12.08-21.18.24.jpg"><img class="alignnone size-full wp-image-2523" title="real-time calculated radiator heat output" src="http://blog.hekkers.net/wp-content/uploads/2011/12/Capture_02-2011.12.08-21.18.24.jpg" alt="real-time calculated radiator heat output" width="406" height="188" /></a></div>
<p>Cool! Although these heat output numbers are based on pretty accurate formulas and properties provided by the manufacturer, the real-life numbers will probably be lower. Dust, bad airflow caused by windowsills and such will always result in deviations. How much? Dunno&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2011/12/08/energy-flow-in-watt/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>RF to Zigbee gateway</title>
		<link>http://blog.hekkers.net/2011/12/02/rf-to-zigbee-gateway/</link>
		<comments>http://blog.hekkers.net/2011/12/02/rf-to-zigbee-gateway/#comments</comments>
		<pubDate>Fri, 02 Dec 2011 17:00:31 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[HVAC]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Xbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2508</guid>
		<description><![CDATA[The last piece of missing hardware is finished. The picture below shows the 2nd RF to Zigbee gateway I had to make to be able to receive all the Hydronic balancing sensors I made earlier this week. One of those sensors just couldn&#8217;t make it through 3 walls all day long, so I created  a [...]]]></description>
			<content:encoded><![CDATA[<p>The last piece of <a href="http://blog.hekkers.net/2011/11/29/hb-sensors-finished-and-installed/">missing hardware</a> is finished. The picture below shows the 2nd RF to Zigbee gateway I had to make to be able to receive all the Hydronic balancing sensors I made earlier this week. One of those sensors just couldn&#8217;t make it through 3 walls all day long, so I created  a temporary solution on a breadboard to solve this.</p>
<p style="text-align: center;"><a href="http://blog.hekkers.net/wp-content/uploads/2011/12/DSC_6393_s.jpg"><img class="aligncenter size-full wp-image-2511" title="RF to Zigbee gateway" src="http://blog.hekkers.net/wp-content/uploads/2011/12/DSC_6393_p.jpg" alt="" width="600" height="399" /></a></p>
<p>A very simple yet effective way (for me) to get the sensor data where I want it (in my Domotica system) with minimal effort.</p>
<p>The <a href="http://jeelabs.net/projects/hardware/wiki/JeeNode">JeeNode</a> acts as a RF receiver and just echoes everything with a valid CRC to the <a href="http://www.digi.com/xbee/">Digi XBee</a>; from there it eventually arrives at my Zigbee Coordinator with which I can communicate over<a href="http://en.wikipedia.org/wiki/TCP/IP_model"> TCP/IP</a>.</p>
<p>The JeeNode runs a slightly modified version of the<a href="http://jeelabs.net/projects/cafe/wiki/RF12demo_sketch"> RF12Demo sketch</a> made by Jean-Claude Wippler. I used the <a href="http://arduiniana.org/libraries/newsoftserial/">NewSoftSerial</a> library to create an additional Serial port, and added a few <span style="color: #ff6600;">print</span> statements for the XBee port, right there where the RF12Demo<span style="color: #ff6600;"><strong> Serial</strong>.println</span>()&#8217;s the received RF data to the Serial port. Compile, Upload, setting the RF band,  group- and node ID and I&#8217;m done!</p>
<p>This JeeNode is powered by a 5V USB adapter and the XBee gets its power from the 3.3V JeeNode ports. The XBee uses a Zigbee End Device AT firmware (2864) with the Sleep Mode set to Pin Hibernate. But because pin 9 is wired to GND, this means that the XBee is permanently on.  Only 3 wires are needed to connect the XBee to the JeeNode: 3.3V, GND and a JeeNode digital pin to the XBee DOUT.</p>
<p>That&#8217;s it &#8211; moving on with where this all <a href="http://blog.hekkers.net/2011/11/12/controlling-the-radiators-is-not-enough/">started with</a>: <em>understanding the flow of  heating energy in our house</em>!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2011/12/02/rf-to-zigbee-gateway/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>HB sensors finished and installed</title>
		<link>http://blog.hekkers.net/2011/11/29/hb-sensors-finished-and-installed/</link>
		<comments>http://blog.hekkers.net/2011/11/29/hb-sensors-finished-and-installed/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 22:29:21 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[HVAC]]></category>
		<category><![CDATA[Remeha]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Thermostat]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2487</guid>
		<description><![CDATA[Almost ready to start investigating hydronic balancing (HB) &#8230; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; &#160; Everything is in place and working except for 1 sensor, which is too far away from the receiving JeeNode (which forwards all the data to my Domotica system). So I&#8217;ll have to build another [...]]]></description>
			<content:encoded><![CDATA[<p>Almost ready to start investigating <a href="http://blog.hekkers.net/2011/11/22/hydronic-balancing/">hydronic balancing</a> (HB) &#8230; <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6384_s.jpg"><img class="alignright size-full wp-image-2489" title="Sensor in a bedroom" src="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6384_p.jpg" alt="" width="300" height="199" /></a><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6380_s.jpg"><img class="alignleft size-full wp-image-2488" title="4 JeeNodes on batteries, equipped with 2 DS18B20 sensors each" src="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6380_p.jpg" alt="" width="300" height="199" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6385_s.jpg"><img class="alignleft size-full wp-image-2491" title="Sensor in the bathroom" src="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6385_p.jpg" alt="" width="300" height="199" /></a></p>
<p><a href="http://www.hekkers.net/domotica/hydronicbalancing.aspx"><img class="alignright size-full wp-image-2493" title="Click to go to my &quot;Hydronic Balancing info&quot; webpage" src="http://blog.hekkers.net/wp-content/uploads/2011/11/Capture_01s.jpg" alt="" width="300" height="182" /></a></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>Everything is in place and working except for 1 sensor, which is too far away from the receiving JeeNode (which forwards all the data to my Domotica system). So I&#8217;ll have to build another RF receiver for that; the missing parts will arrive tomorrow I hope. In the meantime I started creating a <a href="http://www.hekkers.net/domotica/hydronicbalancing.aspx">webpage</a> to display all the information I want to observe, so I don&#8217;t have to switch between browser tabs and go from one page to the other. Another thing that has to be done is program the thermostat, so that the boiler will have to burn at full power for a few hours every day, so that I can see what happens.  I&#8217;ve already seen some things that need to be adjusted!</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2011/11/29/hb-sensors-finished-and-installed/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>It&#8217;s them floats again..</title>
		<link>http://blog.hekkers.net/2011/11/24/its-them-floats-again/</link>
		<comments>http://blog.hekkers.net/2011/11/24/its-them-floats-again/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 23:10:36 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2481</guid>
		<description><![CDATA[I keep a close eye on a lot of things, including my own Domotica system. Not just things like empty batteries in the sensors, but also the software behind it all. Things like exceptions that occur, memory usage, cpu usage and stuff like that. It keeps me informed about the &#8216;health&#8217; of it all, so [...]]]></description>
			<content:encoded><![CDATA[<p>I keep a close eye on a lot of things, including my own Domotica system. Not just things like empty batteries in the sensors, but also the software behind it all. Things like exceptions that occur, memory usage, cpu usage and stuff like that. It keeps me informed about the &#8216;health&#8217; of it all, so I won&#8217;t end up with a system with lots of memory leaks or other nasty bugs scattered throughout the system; and which will be much harder to find once it crashes due to <em>not enough memory</em>&#8230;</p>
<p>Yesterday I saw something strange happening to the memory usage:</p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/MemUPic_000128.png"><img class="aligncenter size-full wp-image-2482" title="Memory usage" src="http://blog.hekkers.net/wp-content/uploads/2011/11/MemUPic_000128.png" alt="Memory usage" width="591" height="150" /></a>Immediately after I upgraded my system, memory usage started to increase to values that I had never seen before. It&#8217;s always a straight line with a variance of +/- 2 KB after 24 hours of up-time.</p>
<p>Strange, cause all I had done was adding a few lines of code to support the <a href="http://blog.hekkers.net/2011/11/22/hydronic-balancing/">hydronic balancing sensors</a>; nothing exciting actually. I checked if all objects were destroyed after use; nothing wrong. I did a restart; same thing happened again. The only thing the code had to do was calculate 2 temperatures out of 4 integer values; what could be wrong here?</p>
<p>Digging a bit deeper I saw these messages in the logs, a few per hour:</p>
<pre>Exception:Database Server Error: SQL State: 01000, SQL Error Code: 3621</pre>
<p>Not very self-explanatory either, but it was evident that something was wrong here. Again strange, since SQL Server has been running without any problem since I use it; that&#8217;s 5 years! I looked up the SQL command that triggered this error response and there it was&#8230; a string value of &#8217;0.689999999999998&#8242; was written to a fixed-length field and it didn&#8217;t fit!</p>
<p>But where does this &#8217;0.689999999999998&#8242; come from? Working with floats of course!</p>
<p>The 2 temperature values are each calculated by dividing a word (2 bytes) by 100; this results in a float with a maximum of 2 decimals (duh). But by storing these 2 temperatures in float variables and subtracting those 2 (to calculate the temperature difference), the result of 28.06 &#8211; 27.37 wasn&#8217;t 0.69 but the error triggering 0.689999999999998&#8230;</p>
<p>Of course, I <em>know</em> this and I should have anticipated on that &#8211; I forgot to round the result of the subtraction to 2 decimals!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2011/11/24/its-them-floats-again/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hydronic balancing</title>
		<link>http://blog.hekkers.net/2011/11/22/hydronic-balancing/</link>
		<comments>http://blog.hekkers.net/2011/11/22/hydronic-balancing/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 21:36:39 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[HVAC]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Remeha]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Thermostat]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=2468</guid>
		<description><![CDATA[This weekend I came to the conclusion that whatever I do, I&#8217;ll never get a well performing central heating without hydronic balancing. I&#8217;ve been watching how the temperatures in all the rooms of our house react and where the energy goes to &#8211; it&#8217;s a mess! No matter how well I&#8217;ll be able to control the [...]]]></description>
			<content:encoded><![CDATA[<p>This weekend I came to the conclusion that whatever I do, I&#8217;ll never get a well performing central heating without <a href="http://en.wikipedia.org/wiki/Hydronic_balancing" target="_blank">hydronic balancing</a>. I&#8217;ve been watching how the temperatures in all the rooms of our house react and where the energy goes to &#8211; it&#8217;s a mess! No matter how well I&#8217;ll be able to control the kettle, temperature control in all the rooms will still be a mess without a hydronicly balanced system.</p>
<p>So this weekend I decided to stop what I was doing (building the <a href="http://blog.hekkers.net/2011/11/12/controlling-the-radiators-is-not-enough/">Opentherm Gateway</a>) and first try to do something about this balancing issue.</p>
<p>Hydronic balancing is not something I&#8217;m familiar with, and I certainly don&#8217;t have the tools for it ; but what i <em>can</em> do is provide enough information with these sensors; I don&#8217;t know if I&#8217;ll succeed, but it&#8217;s worth to give it a try.</p>
<p><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6370_s.jpg"><img class="alignleft size-full wp-image-2472" title="Sensor for Hydronic balancing" src="http://blog.hekkers.net/wp-content/uploads/2011/11/DSC_6370_p.jpg" alt="Sensor for Hydronic balancing" width="320" height="213" /></a> The first thing I need to know is how much energy flows through the radiators. Well, I can do that, I guess&#8230; A <a href="http://jeelabs.net/projects/hardware/wiki/JeeNode" target="_blank">JeeNode with RF</a> transmitter and 2 <a href="http://www.maxim-ic.com/datasheet/index.mvp/id/2812" target="_blank">1-Wire DS18B20</a> sensors can provide me information about how much energy each radiator produces by measuring the flow- and return temperatures of each radiator.</p>
<p>I&#8217;ve got a bunch of JeeNode kits still waiting to be used, enough 1-Wire sensors, batteries and all other components needed, so what am I waiting for??</p>
<p>So this weekend I built a first sensor and a RF-to-Zigbee &#8216;gateway&#8217; so I can receive all the sensors without the need of USB, RS232 or an additional Ethernet port.</p>
<p>The first sensor is operational now; more will follow!</p>
<div id="attachment_2474" class="wp-caption aligncenter" style="width: 601px"><a href="http://blog.hekkers.net/wp-content/uploads/2011/11/TempsPic_000023.png"><img class="size-full wp-image-2474" title="Sensor data" src="http://blog.hekkers.net/wp-content/uploads/2011/11/TempsPic_000023.png" alt="" width="591" height="150" /></a><p class="wp-caption-text">Red = flow temperature, Blue = temperature drop</p></div>
<p style="text-align: center;">
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2011/11/22/hydronic-balancing/feed/</wfw:commentRss>
		<slash:comments>12</slash:comments>
		</item>
	</channel>
</rss>

