<?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>Digit's Domotica Blog &#187; JeeNodes</title>
	<atom:link href="http://blog.hekkers.net/tag/jeenodes/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hekkers.net</link>
	<description>My Weblog about Domotica and more</description>
	<lastBuildDate>Tue, 07 Sep 2010 17:23:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Going down even more</title>
		<link>http://blog.hekkers.net/2010/09/06/going-down-even-more/</link>
		<comments>http://blog.hekkers.net/2010/09/06/going-down-even-more/#comments</comments>
		<pubDate>Mon, 06 Sep 2010 20:32:09 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1285</guid>
		<description><![CDATA[Now that i have no more PIR sensors in stock, I had to find me an alternative. The requirements: low power of course, it should be able to fit in the PIR enclosure i already have in use and not too expensive, cause I&#8217;ll need a lot of them. The ELV PIR13 seems to be [...]]]></description>
			<content:encoded><![CDATA[<p>Now that i have no more PIR sensors in stock, I had to find me an alternative. The requirements: low power of course, it should be able to fit in the PIR enclosure i already have in use and not too expensive, cause I&#8217;ll need a lot of them. The <a href="http://www.elv.de/output/controller.aspx?cid=74&amp;detail=10&amp;detail2=403&amp;flv=1&amp;bereich=&amp;marke=" target="_blank">ELV PIR13</a> seems to be the right candidate for the job; this would bring down the PIR power usage from <strong>170</strong> µA to <strong>40</strong> µA. I don&#8217;t have to tell you what that will do to battery life <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<div id="attachment_1286" class="wp-caption alignnone" style="width: 280px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/09/pir13.jpg"><img class="size-full wp-image-1286 " title="ELV PIR13: PCB 25 x 37 mm, 13 mm PIR" src="http://blog.hekkers.net/wp-content/uploads/2010/09/pir13.jpg" alt="" width="270" height="270" /></a><p class="wp-caption-text">ELV PIR13: PCB 25 x 37 mm, 13 mm PIR</p></div>
<p>I&#8217;ve ordered a couple of these ELV PIR13&#8242;s and will build a 3rd motion sensor with one of these. In the meantime I also changed some things in the code to reduce the JeeNode power usage in power down mode even more: it went down from <strong>20</strong> µA to <strong>6.5</strong> µA. Calculations show a theoretical battery life of 200 weeks&#8230; well, i think the internal discharge will have screwed up the battery before that&#8230;</p>
<p>BTW, the 2 motion sensors that are currently being used, are still running fine on their first set of batteries.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/09/06/going-down-even-more/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Adding Light and Temperature</title>
		<link>http://blog.hekkers.net/2010/08/07/adding-light-and-temperature/</link>
		<comments>http://blog.hekkers.net/2010/08/07/adding-light-and-temperature/#comments</comments>
		<pubDate>Sat, 07 Aug 2010 21:56:09 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1235</guid>
		<description><![CDATA[Since i removed a bunch of MS13 sensors recently, i am missing some input on what is going on at several places in our home. So while i was making a list of things i need in the near future, i realized i should extend the motion sensors a bit more, or otherwise i would [...]]]></description>
			<content:encoded><![CDATA[<p>Since i removed a bunch of MS13 sensors <a href="http://blog.hekkers.net/2010/06/20/no-more/" target="_self">recently</a>, i am missing some input on what is going on at several places in our home. So while i was making a list of things i need in the near future, i realized i should extend the motion sensors a bit more, or otherwise i would lose the dark/light sensor the MS13 provided. And why not add temperature as well; cause that would mean i could do without the Oregon sensors also. I mean, why use 2 sensor devices (one only for temperature and another one for motion and light) when you can combine it all into one? Let&#8217;s have a look at temperature&#8230;</p>
<p>I still have 10 DS1820 1-Wire sensors somewhere from the days when i started with Domotica, but i never used them; maybe now i finally found a purpose for them? Let&#8217;s connect a few to an Arduino and see if  i can get a temperature reading:</p>
<div id="attachment_1236" class="wp-caption alignnone" style="width: 410px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/08/DSC_3437_resize.jpg"><img class="size-full wp-image-1236" title="Arduino with 3 x DS1820" src="http://blog.hekkers.net/wp-content/uploads/2010/08/DSC_3437_resize.jpg" alt="Arduino with 3 x DS1820" width="400" height="266" /></a><p class="wp-caption-text">Arduino with 3 x DS1820</p></div>
<p>And of course, there&#8217;s a library to use 1-Wire devices with an Arduino.. so before i knew it, i was polling the temperature of 3 DS1820s <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre>Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC

Addr:10 6C 5 CA 0 8 0 C3  Temp=25.50 grC
Addr:10 33 EC 3 1 8 0 E1  Temp=25.50 grC
Addr:10 FB 90 C9 0 8 0 1A  Temp=25.50 grC
</pre>
<p>Add an additional LDR and I&#8217;m done; ready to replace a large part of all my sensors: all remaining MS13s and most of my Oregon Scientific Temperature &amp; Humidity sensors with my own <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/2010/08/07/adding-light-and-temperature/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motion sensor v2 built and in use</title>
		<link>http://blog.hekkers.net/2010/07/29/motion-sensor-v2-built-and-in-use/</link>
		<comments>http://blog.hekkers.net/2010/07/29/motion-sensor-v2-built-and-in-use/#comments</comments>
		<pubDate>Thu, 29 Jul 2010 20:18:43 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1207</guid>
		<description><![CDATA[Two motion sensors v2 are in use right now, yippee! I upgraded an existing v1 sensor to a v2 and built a new one. The v2 sensor specs are very different from the v1 but much more promising, yet all i needed to do to was soldering the digital output of the PIR to another [...]]]></description>
			<content:encoded><![CDATA[<p>Two motion sensors v2 are in use right now, yippee!</p>
<p>I upgraded an <a href="http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/" target="_self">existing v1 sensor</a> to a v2 and built a new one. The v2 sensor specs are very different from the v1 but much more  promising, yet all i needed to do to was soldering the digital output of  the PIR to another JeeNode port (namely ATmega INT1) and use a different digital port for serial I/O with the XBee. Oh, and upload a new  sketch of course. Now i have 2 identical v2 sensors:</p>
<div id="attachment_1215" class="wp-caption alignnone" style="width: 431px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3429_resize.jpg"><img class="size-full wp-image-1215" title="v1 upgraded to v2" src="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3429_resize.jpg" alt="" width="421" height="280" /></a><p class="wp-caption-text">v1 upgraded to v2</p></div>
<p>Looking back at how this motion sensor evolved i am wondering, why didn&#8217;t i think of <a href="http://blog.hekkers.net/2010/07/25/really-powering-down-this-time/" target="_self">interrupts</a> in the first place&#8230; not very smart actually..</p>
<p>Or maybe i <em>did</em> think about interrupts but unconsciously thought it would be to hard for me to handle already, cause that&#8217;s what you read all the time: interrupts are a tough subject! Maybe it is, but i didn&#8217;t notice that yet! <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>So now I&#8217;ve got 2 motion sensors with the following features:</p>
<ul>
<li>powered by 3 * 1.2V, 2000 mAh rechargeable batteries;</li>
<li>PIR with digital output, 100µA standby power usage and 5m detection range;</li>
<li>a JeeNode that&#8217;s effectively running only a total of about 180 seconds per day (0.2 %), even with 350-400 motion reports and lots of heartbeats. The rest of the time the JeeNode is in power down mode;</li>
<li>it&#8217;s ZigBee based which is better than 433 MHz in my opinion, especially when you&#8217;ve got a lot of sensors;</li>
<li>relatively small sensor housing compared to commercial (mostly big and ugly) products;</li>
<li>completely DIY so everything is how i want it to be;</li>
<li>interrupt-based, the best you can get I&#8217;d say;</li>
<li>need i go on?  <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </li>
</ul>
<p>I&#8217;m gonna monitor this sensor very closely in the coming months and learn from it. Here you see one of the sensors being used in the kitchen:</p>
<div id="attachment_1214" class="wp-caption alignnone" style="width: 431px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3432_resize.jpg"><img class="size-full wp-image-1214" title="Motion v2 in the kitchen" src="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3432_resize.jpg" alt="" width="421" height="280" /></a><p class="wp-caption-text">Motion v2 in the kitchen</p></div>
<p>The sketch that&#8217;s currently running on these sensors can be found <a href="http://www.hekkers.net/files/Motionv2_20100729.txt">here</a>.</p>
<p>Finished? Almost; some loose ends in the sketch. Maybe it can be made even smaller/faster/less energy consuming. But I&#8217;ll look into that when the 3rd sensor is built.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/07/29/motion-sensor-v2-built-and-in-use/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Motion Sensor v2</title>
		<link>http://blog.hekkers.net/2010/07/27/motion-sensor-v2/</link>
		<comments>http://blog.hekkers.net/2010/07/27/motion-sensor-v2/#comments</comments>
		<pubDate>Tue, 27 Jul 2010 22:08:34 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1192</guid>
		<description><![CDATA[Here it is, Motion Sensor v2. Not much different from v1 really, the only thing that has changed is that the PIR output has moved to an interrupt pin. And the sketch looks somewhat different here and there. Later this week i&#8217;ll build my 2nd motion sensor and start using it right away; i&#8217;m very [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3425_resize.jpg"><img class="alignnone size-full wp-image-1202" title="Motion Sensor v2" src="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3425_resize.jpg" alt="" width="421" height="280" /></a></p>
<p>Here it is, Motion Sensor v2. Not much different from v1 really, the only thing that has changed is that the PIR output has moved to an interrupt pin. And the sketch looks somewhat different here and there. Later this week i&#8217;ll build my 2nd motion sensor and start using it right away; i&#8217;m very curious about the results! I&#8217;ll also change my 1st motion sensor that&#8217;s already in use, to an interrupt driven model. Don&#8217;t want to wait for what will happen with those batteries&#8230;</p>
<p>The <a href="http://cafe.jeelabs.net/lab/jn4/" target="_blank">JeeNode</a> is completely powered down most of the time. It only gets woken up by the Watchdog timer every 8 seconds or when motion is detected. But even when motion is detected, it&#8217;s powered down most of the time, cause a &#8216;blip&#8217; sent to my <a href="http://www.hekkers.net/domotica/" target="_blank">Domotica System</a> every 4 seconds during continuous motion is more than enough.</p>
<p>When the motion interrupt is triggered, the &#8216;blip&#8217; is sent to my system, followed by a power down for 4 seconds <em>without</em> interrupt trigger set. When those 4 seconds have passed (wake up is done by the watchdog timer) a power down is done <em>with</em> interrupt trigger and the whole loop starts all over again. Capice? It doesn&#8217;t get much easier than this <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>And of course there&#8217;s a heartbeat sent every 64 (8 times 8 ) seconds.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/07/27/motion-sensor-v2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Sense Control</title>
		<link>http://blog.hekkers.net/2010/07/26/adding-sense-control/</link>
		<comments>http://blog.hekkers.net/2010/07/26/adding-sense-control/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 19:18:09 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1184</guid>
		<description><![CDATA[While i was quite happy yesterday with the new way i&#8217;m going to handle things on the JeeNode regarding the motion sensor (PIR), i already knew i wasn&#8217;t finished yet; this was nice, but only a first step. Cause what i had created was an IRQ being fired when the input becomes low. Well, the [...]]]></description>
			<content:encoded><![CDATA[<p>While i was quite happy <a href="http://blog.hekkers.net/2010/07/25/really-powering-down-this-time/" target="_self">yesterday</a> with the new way i&#8217;m going to handle things on the JeeNode regarding the motion sensor (PIR), i already knew i wasn&#8217;t finished yet; this was nice, but only a first step.</p>
<p>Cause what i had created was an IRQ being fired when the input becomes low. Well, the PIR output becomes high when there&#8217;s motion detected, so this is unusable, actually. For a brief moment i considered using a transistor as a NOT gate to invert the PIR output, but there had to be an easier way. Why would you only be able to activate an External Interrupt when a pin becomes low?? I read some topics on various forums, but those were very contradictory; some said i could, some said otherwise. OK, in that case, i&#8217;ll sort it out myself .. cause i really need interrupts based on a rise or a change!</p>
<p>Page 71 of the ATmega datasheet learned me that INT0 and INT1 indeed have Interrupt Sense Control and it&#8217;s only a matter of setting the right bits in the External Interrupt Control Register A, aka EICRA:</p>
<div id="attachment_1187" class="wp-caption aligncenter" style="width: 700px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/Capture26-7-2010-21.06.53.png"><img class="size-full wp-image-1187" title="Bit 3 and 2 of EICRA" src="http://blog.hekkers.net/wp-content/uploads/2010/07/Capture26-7-2010-21.06.53.png" alt="" width="690" height="165" /></a><p class="wp-caption-text">Bit 3 and 2 of EICRA</p></div>
<p>So it can be done, only thing is to figure out how&#8230;</p>
<p>The Arduino attachInterrupt() function has a 2nd parameter with which you can control what triggers an interrupt; the values are the constants LOW, CHANGE, RISING and FALLING (found in wiring.h). So why didn&#8217;t that nice Sleep library i found earlier have this feature? All i can do is call this function:</p>
<pre>void SleepClass::powerDownAndWakeupExternalEvent(uint8_t interruptNumber)
{
 attachInterrupt(interruptNumber, SleepClass::external_event_handler, LOW);
 set_sleep_mode_and_sleep(SLEEP_MODE_PWR_DOWN);
 detachInterrupt(interruptNumber);
}
</pre>
<p>OK; changing things in the library depending on the kind of Sense Control i need for a specific sensor type is not an option of course, so i added a 2nd parameter to that function:</p>
<pre>void SleepClass::powerDownAnd...Event(uint8_t interruptNumber, int mode)
{
 attachInterrupt(interruptNumber, SleepClass::external_event_handler, mode);
 set_sleep_mode_and_sleep(SLEEP_MODE_PWR_DOWN);
 detachInterrupt(interruptNumber);
</pre>
<p>}</p>
<p>That&#8217;s better; now i can choose whatever Sense Control I want; I&#8217;ve checked all of them right away:</p>
<pre>Sleep.powerDownAndWakeupExternalEvent(0, RISING);</pre>
<p>What a surprise, its working, all of them! RISING is just what i need right now for the PIR; CHANGE is what i would need for a door sensor.</p>
<p>Now i&#8217;m already modifying libraries and I can even understand what</p>
<pre>EICRA = (EICRA &amp; ~((1 &lt;&lt; ISC00) | (1 &lt;&lt; ISC01))) | (mode &lt;&lt; ISC00);</pre>
<p>does&#8230; i wonder where or when (if ever) this will end&#8230;</p>
<p>But I&#8217;m still not finished! Cause with all this powering down going on, it has become increasingly hard to keep a notion of time; millis() has become useless cause how can i determine the time that has passed since the last power down? On the other hand, do i really need to know that? Time will tell <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/2010/07/26/adding-sense-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Really powering down this time</title>
		<link>http://blog.hekkers.net/2010/07/25/really-powering-down-this-time/</link>
		<comments>http://blog.hekkers.net/2010/07/25/really-powering-down-this-time/#comments</comments>
		<pubDate>Sun, 25 Jul 2010 15:01:42 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1174</guid>
		<description><![CDATA[Having a first set of batteries empty wasn&#8217;t  funny.. they lasted only 7 weeks! Way to short. And i kept on thinking that it might not have been caused by a bad battery.. what could i do next? Wait another 7 weeks to find out that I&#8217;m wrong? Neh.. that didn&#8217;t feel the right thing [...]]]></description>
			<content:encoded><![CDATA[<p>Having a first set of batteries empty wasn&#8217;t <a href="http://blog.hekkers.net/2010/07/24/new-batteries/" target="_self"> funny</a>.. they lasted only 7 weeks! Way to short. And i kept on thinking that it might <em>not</em> have been caused by a bad battery.. what could i do next? Wait another 7 weeks to find out that I&#8217;m wrong? Neh.. that didn&#8217;t feel the right thing to do; Power down as much as possible and use an external interrupt would possibly give the best results anyway, so why not start with that right now!</p>
<p>I started with attaching a push-button to an Arduino, using a pull-up resistor to keep the input high when the button isn&#8217;t pressed:</p>
<div id="attachment_1176" class="wp-caption aligncenter" style="width: 610px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3424c_resize.jpg"><img class="size-full wp-image-1176" title="Arduino with push-button" src="http://blog.hekkers.net/wp-content/uploads/2010/07/DSC_3424c_resize.jpg" alt="" width="600" height="250" /></a><p class="wp-caption-text">Arduino with push-button</p></div>
<p>After that i started reading about interrupts. Here&#8217;s a table that shows the Wake-up sources that are available in the various sleep modes:</p>
<div id="attachment_1175" class="wp-caption aligncenter" style="width: 628px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/Capture25-7-2010-16.10.27.png"><img class="size-full wp-image-1175 " title="ATmega48PA/88PA/168PA/328P Wake-up sources" src="http://blog.hekkers.net/wp-content/uploads/2010/07/Capture25-7-2010-16.10.27.png" alt="" width="618" height="302" /></a><p class="wp-caption-text">ATmega48PA/88PA/168PA/328P Wake-up sources</p></div>
<p>Both things i need are available: INT0 and/or INT1 and the Watchdog Timer, so it was time to start sketching <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>After 5 different sketches with all the same miserable results (freezing Arduino), i finally found a <a href="http://code.google.com/p/arms22/downloads/detail?name=Sleep003.zip&amp;can=2&amp;q=" target="_blank">sleep library</a> that did exactly what i wanted. I combined this library with code i had found <a href="http://blog.hekkers.net/2009/12/25/atmega328-and-its-watchdog-timer/" target="_self">earlier</a> regarding setting up and using the Watchdog Timer, and what i have now, is just what i need. Below a sample of the Serial Monitor output and <a href="http://www.hekkers.net/files/INTerrupt_6.txt" target="_blank">here</a> is the sketch that produced it.</p>
<pre>39171 I'm awake, caused by the WDT
39205 Sleeping...
39327 I'm awake, caused by the WDT
39362 Sleeping...
39484 I'm awake, caused by the WDT
39519 Sleeping...
39640 I'm awake, caused by the WDT
39674 Sleeping...
39796 I'm awake, caused by INT0
Doing some work...finished!
40257 Sleeping...
40377 I'm awake, caused by INT0
Doing some work...finished!
40839 Sleeping...
40960 I'm awake, caused by INT0
Doing some work...finished!
41421 Sleeping...
41542 I'm awake, caused by the WDT
41577 Sleeping...
41698 I'm awake, caused by INT0
Doing some work...finished!
42160 Sleeping...
42280 I'm awake, caused by the WDT
42315 Sleeping...
42437 I'm awake, caused by the WDT
42472 Sleeping...
42593 I'm awake, caused by the WDT
42628 Sleeping...

etc. etc.
</pre>
<p>Cool stuff! <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  Let&#8217;s see how we can change the <a href="http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/" target="_self">motion sensor</a> to make use of this!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/07/25/really-powering-down-this-time/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dropping fast&#8230;</title>
		<link>http://blog.hekkers.net/2010/07/24/dropping-fast/</link>
		<comments>http://blog.hekkers.net/2010/07/24/dropping-fast/#comments</comments>
		<pubDate>Fri, 23 Jul 2010 23:01:13 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[motion sensor]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Xbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1142</guid>
		<description><![CDATA[Oops&#8230; the Supply Voltage on my motion sensor is already down to 3060 millivolts. Suddenly it&#8217;s dropping very fast; this sensor has been operational for more then 7 weeks now, with IIRC 2 new and 1 older rechargeable battery of a brand with which i&#8217;ve had bad experiences before. I hope that&#8217;s what is causing [...]]]></description>
			<content:encoded><![CDATA[<div id="attachment_1143" class="wp-caption alignnone" style="width: 601px"><a href="http://blog.hekkers.net/wp-content/uploads/2010/07/SupVoltPic_000019.png"><img class="size-full wp-image-1143" title="XBee Supply Voltage dropping fast!" src="http://blog.hekkers.net/wp-content/uploads/2010/07/SupVoltPic_000019.png" alt="" width="591" height="150" /></a><p class="wp-caption-text">XBee Supply Voltage dropping fast!</p></div>
<p>Oops&#8230; the Supply Voltage on my motion sensor is already down to 3060 millivolts. Suddenly it&#8217;s dropping very fast; this sensor has been operational for more then 7 weeks now, with IIRC 2 new and 1 older rechargeable battery of a brand with which i&#8217;ve had bad experiences before. I hope that&#8217;s what is causing this, cause if not, i have some work to do <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_sad.gif' alt=':-(' class='wp-smiley' /> </p>
<p>The other 2 battery powered sensors are still doing fine, BTW:</p>
<div id="attachment_1144" class="wp-caption alignnone" style="width: 838px"><a href="http://www.hekkers.net/domotica/devicestatus.aspx"><img class="size-full wp-image-1144 " title="Supply Voltages" src="http://blog.hekkers.net/wp-content/uploads/2010/07/Capture22-7-2010-22.10.58.png" alt="" width="828" height="66" /></a><p class="wp-caption-text">Supply Voltages (click to view the realtime values)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/07/24/dropping-fast/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Lux sensor finished</title>
		<link>http://blog.hekkers.net/2010/07/17/lux-sensor-finished/</link>
		<comments>http://blog.hekkers.net/2010/07/17/lux-sensor-finished/#comments</comments>
		<pubDate>Sat, 17 Jul 2010 20:46:04 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1088</guid>
		<description><![CDATA[Another project is almost finished; my JeeLabs Lux Plug moved inside an enclosure. The Lux Plug is inside the enclosure with the rest: battery holder, JeeNode and XBee module. In my opinion there was no need to put the sensor in it&#8217;s own small enclosure like i did with the motion sensor; there are enough [...]]]></description>
			<content:encoded><![CDATA[<p>Another project is almost finished; my JeeLabs Lux Plug moved inside an enclosure.</p>
<div id="attachment_1089" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-1089" title="JeeNode Lux Plug" src="http://blog.hekkers.net/wp-content/uploads/2010/07/dsc_3396_resize.jpg" alt="JeeNode Lux Plug" width="300" height="199" /><p class="wp-caption-text">JeeNode Lux Plug</p></div>
<p>The Lux Plug is inside the enclosure with the rest: battery holder, JeeNode and XBee module. In my opinion there was no need to put the sensor in it&#8217;s own small enclosure like i did with the <a href="http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/" target="_blank">motion sensor</a>; there are enough places where i can place this enclosure in such a way that the sensor can measure the light intensity and still be relatively invisible. So this Plug is fitted directly into one of the 4 JeeNode ports and a hole in the enclosure is enough for this sensor to work well.</p>
<p><img class="alignnone size-full wp-image-1095" title="dsc_3396c_resize2" src="http://blog.hekkers.net/wp-content/uploads/2010/07/dsc_3396c_resize2.jpg" alt="dsc_3396c_resize2" width="300" height="259" /></p>
<p>Another fun project! I saw a Z-Wave sensor a few days ago, costing &gt;100 Euros. Ok, it has a LCD and a beep tone ofcourse (who can live without that!), but basically, it does the same thing: measuring lux! In my opinion, i got more value for money&#8230; but hey, who am i <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>With a bit of soldering, some code and a lot of fun you can create your own!</p>
<pre>#include &lt;Ports.h&gt;
#include &lt;RF12.h&gt;
#include &lt;avr/sleep.h&gt;
#include &lt;NewSoftSerial.h&gt;

#define DEBUG 0

NewSoftSerial XBSerial = NewSoftSerial(2, 3);
PortI2C myBus (1);
LuxPlug sensor (myBus, 0x39);

int pinCTS=6;                         // to monitor CTS
int pinXBee=5;                        // to Control XBee on/off

static int SampleInterval = 30000;
static int HeartBeatInterval = 90000;
static int CTS=0;                     // value of XBee CTS pin

static void lowPower (byte mode) {
    // prepare to go into power down mode
    set_sleep_mode(mode);
    // disable the ADC
    byte prrSave = PRR, adcsraSave = ADCSRA;
    ADCSRA &amp;= ~ bit(ADEN);
    PRR &amp;= ~ bit(PRADC);
    // zzzzz...
    sleep_mode();
    // re-enable the ADC
    PRR = prrSave;
    ADCSRA = adcsraSave;
}

EMPTY_INTERRUPT(WDT_vect); // just wakes us up to resume

static void watchdogInterrupts (uint8_t mode) {
    MCUSR &amp;= ~(1&lt;&lt;WDRF); // only generate interrupts, no reset
    cli();
    WDTCSR |= (1&lt;&lt;WDCE) | (1&lt;&lt;WDE); // start timed sequence
    WDTCSR = bit(WDIE) | mode; // mode is a slightly quirky bit-pattern
    sei();
}

static byte loseSomeTime (word msecs) {
    // only slow down for periods longer than twice the watchdog granularity
    if (msecs &gt;= 32) {
        for (word ticks = msecs / 16; ticks &gt; 0; --ticks) {
            lowPower(SLEEP_MODE_PWR_DOWN); // now completely power down
            // adjust the milli ticks, since we will have missed several
            extern volatile unsigned long timer0_millis;
            timer0_millis += 16L;
        }
        return 1;
    }
    return 0;
}

static MilliTimer SampleTimer;     // Interval for reading a sample from the BMP085
static MilliTimer HeartBeatTimer;  // forced maximum interval (Heartbeat)
word payload;

static byte periodicSleep (word msecs) {
    // switch to idle mode while waiting for the next event
    lowPower(SLEEP_MODE_IDLE);
  // see http://news.jeelabs.org/2009/12/18/battery-life-estimation/
  if (loseSomeTime(SampleTimer.remaining()))
    SampleTimer.set(1); // really did a power down, trigger right now

  // return true if the time has come to do something meaningful
  return SampleTimer.poll(msecs);
}

static unsigned long tBusy0;
static unsigned long tBusy1;
static unsigned long tBusyPrev;

static void Send() {

  unsigned long tXB1;    // time XBee was woken up
  unsigned long tXB0;    // time XBee was put to sleep

  HeartBeatTimer.set(0);  // disable heartbeat

  CTS = HIGH;
  tXB0=millis();
  // wake up Xbee
  digitalWrite(pinXBee,LOW);

  // wait for CTS to become LOW
  do
  {
    CTS=digitalRead(pinCTS);
  } while (CTS != LOW);
  tXB1=millis();
  // wait 2 msec otherwise data will be received all messed up
  delay(3);

#if DEBUG
  Serial.print(millis());
  Serial.print(" Send ");
  Serial.print(tXB1-tXB0);
  Serial.print(" ");
  Serial.println(payload);
#endif

  // send dummy data
  XBSerial.print(tBusyPrev);
  XBSerial.print(" ");
  XBSerial.print(tXB1-tXB0);
  XBSerial.print(" ");
  XBSerial.println(payload);

  // wait for XBee to finish transmission
  delay(4);

  // switch off XBee
  digitalWrite(pinXBee,HIGH);    

  HeartBeatTimer.set(HeartBeatInterval);
}

int ReadSensor() {

#if DEBUG
  Serial.print(millis());
  Serial.println(" Readsensor");
#endif

    sensor.begin();
    sensor.getData();
    payload = sensor.calcLux();

    return 1;        // always report for now.
}

void setup() {

  // setup XBee
  pinMode(pinXBee,OUTPUT);
  digitalWrite(pinXBee,LOW);
  pinMode(pinCTS,INPUT);
  digitalWrite(pinCTS,LOW);
  delay(10);

  XBSerial.begin(9600);
#if DEBUG
  Serial.begin(9600);
#endif
  // give XBee some time to join PAN
  delay(5000);

  // let the world know we're here
  XBSerial.println("[Lux002]");
#if DEBUG
  Serial.println("[Lux002]");
#endif
 delay(5);

 watchdogInterrupts(0); // 16ms
}

void loop() {
    if (periodicSleep(SampleInterval)) {
      // sensor values changed or heartbeat interval elapsed?
      tBusy0 = millis();
      if (ReadSensor() || (HeartBeatTimer.poll(HeartBeatInterval)))
      {
         Send();
         tBusy1 = millis();
         tBusyPrev = tBusy1-tBusy0;
       }
    }
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/07/17/lux-sensor-finished/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XBee Supply Voltage monitoring (3)</title>
		<link>http://blog.hekkers.net/2010/06/26/xbee-supply-voltage-monitoring-3/</link>
		<comments>http://blog.hekkers.net/2010/06/26/xbee-supply-voltage-monitoring-3/#comments</comments>
		<pubDate>Sat, 26 Jun 2010 21:45:28 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Xbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1048</guid>
		<description><![CDATA[This is what you get when a battery powered XBee is struggling to stay alive cause the batteries aren&#8217;t supplying enough &#8216;juice&#8217; anymore: FF FF FF FF FF FD 7A 1F 33 40 00 A2 13 00 01 FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF [...]]]></description>
			<content:encoded><![CDATA[<p>This is what you get when a battery powered XBee is struggling to stay alive cause the batteries aren&#8217;t supplying enough &#8216;juice&#8217; anymore:</p>
<pre>FF FF FF FF FF FD 7A 1F 33 40 00 A2 13 00 01 FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF
FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF FF 00 1D 00
01 53 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF FF 00
00 73 A0 73 B6 70 E0 73 CC 73 E2 06 40 75 5C 76 F0 76 3C 76 B4 76 3C
76 3C 73 F8 74 0E 74 22 75 1C 75 EC 75 60 74 2C 46 50 E6 00 01 02 00
00 00 00 E8 00 01 02 00 00 00 00 F3 E0 58 A0 FF FE 00 EC 30 BC 75 CA
A8 D8 B6 D5 9F FD 5A 7B FF FE 00 00 FF FE 00 00 FF FE 00 00 FF FE 00
00 FF FE 00 00 FF FE 00 00 FF FE FF FF 79 BE 01 4A 01 B0 01 62 01 4E
01 66 01 AC 01 60 01 82 01 9C 01 68 01 B2 01 94 08 1C 08 29 08 34 02
etc. etc. ...</pre>
<p>For those not really experienced in recognizing XBee API frames from a byte stream: there&#8217;s not a single valid frame to be found inside all those bytes. But this is what my Coordinator received today.</p>
<p>But that&#8217;s OK; i intentionally left the XBee running on low batteries; I wanted to see what would happen. My code that should recognize valid XBee API packets just got it&#8217;s ultimate real life test. Cause normally, the byte stream coming from the Zigbee Coordinator is so <em>clean</em> you can hardly test it without writing a special tool that creates a mix of garbage, valid and invalid frames. Now i know for sure my code works! <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Another good thing i saw, is that this &#8216;dying&#8217; XBee didn&#8217;t create that much traffic resulting in other XBee&#8217;s not being able to get their messages to the Coordinator anymore.</p>
<p>This is really important actually; imagine you&#8217;re on holiday and a sensor runs out of battery power; do you really want to monitor your Home Automation system for that kind of trouble while you&#8217;re at the other side of the world? Become a slave of your own system? And have to call your neighbor that feeds the cat to remove the batteries or worse ? (&#8220;I don&#8217;t care <em>how</em> you do it, just <span style="text-decoration: underline;">do it</span><em>.. Cut some red wires if you have to</em>!&#8221;) Just to keep the system running? Not me!</p>
<p>In the meantime, this really nice weather only makes you want to play outside; sitting behind a computer with an airco blowing cold air in your neck is not my favorite right now:</p>
<p><img class="alignnone size-full wp-image-1056" title="RC Cars" src="http://blog.hekkers.net/wp-content/uploads/2010/06/dsc_3081_resize.jpg" alt="RC Cars" width="350" height="232" /></p>
<p>Batteries are being charged! <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/2010/06/26/xbee-supply-voltage-monitoring-3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>XBee Supply Voltage monitoring (2)</title>
		<link>http://blog.hekkers.net/2010/06/25/xbee-supply-voltage-monitoring-2/</link>
		<comments>http://blog.hekkers.net/2010/06/25/xbee-supply-voltage-monitoring-2/#comments</comments>
		<pubDate>Fri, 25 Jun 2010 19:38:12 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Xbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1042</guid>
		<description><![CDATA[Here are the results of the test i started 3 days ago. After 3 days of monitoring the XBee supply voltage the alkaline batteries were empty and with a bit of tweaking i got the data out of the logs and into an Excel sheet so i could create a chart: OK, this looks good [...]]]></description>
			<content:encoded><![CDATA[<p>Here are the results of the <a href="http://blog.hekkers.net/2010/06/21/xbee-supply-voltage-monitoring/" target="_blank">test</a> i started 3 days ago. After 3 days of monitoring the XBee supply voltage the alkaline batteries were empty and with a bit of tweaking i got the data out of the logs and into an Excel sheet so i could create a chart:</p>
<div id="attachment_1043" class="wp-caption aligncenter" style="width: 596px"><img class="size-full wp-image-1043" title="XBee Supply Voltage" src="http://blog.hekkers.net/wp-content/uploads/2010/06/capture25-6-2010-210757.png" alt="XBee Supply Voltage" width="586" height="155" /><p class="wp-caption-text">XBee Supply Voltage</p></div>
<p>OK, this looks good and it&#8217;s easy to do; all you need are some changed settings on the XBee, a Domotica system that can fire the &#8216;IS&#8217; remote AT Command to your XBee and your done. Well, almost <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>The JeeNode has been running a small sketch that transmits a dummy string every 5 seconds; without any sleeping and also keeping the XBee on all the time:</p>
<pre>#include &lt;NewSoftSerial.h&gt;

#define SERDBG 1
NewSoftSerial XBSerial = NewSoftSerial(2, 3);

int CTSpin = 7;
int XBpin  = 6;

static void Send () {
  // send a dummy string
  XBSerial.print(millis());
  XBSerial.print(" ");
  XBSerial.println("XBeeaaaaaa");
#if SERDBG
  Serial.print(millis());
  Serial.print(" ");
  Serial.println("XBeeaaaaaa");
#endif
}

void setup() {
  // setup XBee
  pinMode(CTSpin,INPUT);
  pinMode(XBpin,OUTPUT);
  digitalWrite(XBpin,LOW);
  digitalWrite(CTSpin,LOW);
  delay(10);

  XBSerial.begin(9600);
#if SERDBG
  Serial.begin(9600);
#endif
  // give XBee some time to join PAN
  delay(5000);

  // let the world know we're here
  XBSerial.println("[XBeeVoltage]");
#if SERDBG
  Serial.println("[XBeeVoltage]");
#endif
}

void loop() {
  delay(5000);
  Send();
}</pre>
<p>The JeeNode stopped working at around 2/3 of the horizontal axis, so after 48 hours or so where the voltage had already dropped to 2,64 V. The XBee is still working as i write this, with a voltage of 2,3 V. I wonder how long it takes for the XBee to give up too&#8230;</p>
<p>Conclusion: this can definitely be used as a way to remotely monitor my battery powered sensors; Yippee!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/06/25/xbee-supply-voltage-monitoring-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
