<?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; Arduino</title>
	<atom:link href="http://blog.hekkers.net/tag/arduino/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>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>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>Arduino Workshop?</title>
		<link>http://blog.hekkers.net/2010/07/16/arduino-workshop/</link>
		<comments>http://blog.hekkers.net/2010/07/16/arduino-workshop/#comments</comments>
		<pubDate>Fri, 16 Jul 2010 17:40:15 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Homeseer]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1081</guid>
		<description><![CDATA[Lennart Herlaar and me are really hooked up to all this Arduino(-compatible) stuff; we both started somewhere in September 2009 with our first &#8216;trials&#8217;. My first experiment was with an Arduino Duemilanove and some LEDs; resulting in instant addiction! Once you discover what can be done with this platform and how you can use it, [...]]]></description>
			<content:encoded><![CDATA[<p>Lennart Herlaar and me are really hooked up to all this <a href="http://www.arduino.cc" target="_blank">Arduino</a>(-compatible) stuff; we both started somewhere in September 2009 with our first &#8216;trials&#8217;. My first experiment was with an Arduino Duemilanove and some LEDs; resulting in instant addiction! Once you discover what can be done with this platform and how <em>you</em> can use it, every day new ideas and interesting projects pass by. Exciting!</p>
<p>We decided to see if we could share our enthusiasm with a larger group of Domoticans; cause there are a lot of Domotica related things you can do with the Arduino platform. Normally Domotica related hardware is quite expensive and closed, in the sence that every manufacturer creates its own proprietary protocol and tries to keep it a secret as much as possible; even changing it for the sole purpose of making all knowledge gathered by reverse engineering useless(!). Interaction between products of different companies is still very hard (if at all) to find &#8211; and most Domoticans are forced to use commercial Home Automation software like Homeseer to tie it all together. However, without a Plugin available for that special type of hardware you&#8217;d like to use, you&#8217;re practically doomed&#8230;</p>
<p>So when we started thinking about organizing an Arduino workshop for the members of the <a href="http://www.domoticaforum.eu" target="_blank">Domoticaforum Europe</a>, we knew right away that we couldn&#8217;t do that without also supplying a <a href="http://www.homeseer.com" target="_blank">Homeseer</a> Plugin with it; well at least create a framework that would enable the workshop attendees to connect their new Arduino-based hardware to the most used HA software here in the Netherlands.</p>
<p>And that&#8217;s exactly what&#8217;s going to happen; when we get enough response (a mimimum of 15) to our <a href="http://www.domoticaforum.eu/viewtopic.php?f=63&amp;t=5116" target="_self">post</a> on the Domotica forum and we decide to go ahead with organizing this workshop, we&#8217;ll also have to start thinking about how to create an easy to use, flexible, future proof Plugin that can interface with the Arduino platform and it&#8217;s compatibles like (my favorite) <a href="http://cafe.jeelabs.net/lab/jn4/" target="_blank">JeeNodes</a>..</p>
<p>It will be fun! As always <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/16/arduino-workshop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New motion sensor in use</title>
		<link>http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/</link>
		<comments>http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/#comments</comments>
		<pubDate>Sun, 20 Jun 2010 20:43:11 +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>
		<category><![CDATA[Xbee]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=1021</guid>
		<description><![CDATA[After my problems with the MS13 sensors yesterday, i managed to find some spare time (even though, or maybe because it was father&#8217;s day) to write a sketch for the new motion sensor i created during the last couple of weeks. Always taking one step at a time, i located the first prototype of this [...]]]></description>
			<content:encoded><![CDATA[<p>After my problems with the MS13 sensors yesterday, i managed to find some spare time (even though, or maybe <em>because</em> it was father&#8217;s day) to write a sketch for the new motion sensor i created during the last couple of weeks. Always taking one step at a time, i located the first prototype of this sensor at a place where i can see the enclosure LED from the living room: i want to know how it performs&#8230;</p>
<div id="attachment_1022" class="wp-caption alignleft" style="width: 360px"><img class="size-full wp-image-1022" title="New motion sensor" src="http://blog.hekkers.net/wp-content/uploads/2010/06/dsc_3046_resize.jpg" alt="New motion sensor" width="350" height="232" /><p class="wp-caption-text">New motion sensor</p></div>
<p>Now powered by 3 rechargable NiCd batteries and with all hardware nicely put away in the enclosure. In due time the enclosure will be moved out of sight so only the PIR will be visible. I&#8217;ve decided to use 3.5 mm jack plugs to be able to disconnect the enclosure from the sensor, so i can easily take the enclosure back to my office, because i don&#8217;t think the JeeNode is already running the final version of the &#8216;PIR&#8217; sketch&#8230; <img src='http://blog.hekkers.net/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>A new class, 2 database records and 1 line of code were enough to get the sensor working in my Domotica system:</p>
<pre>procedure TAMN31112.ProcessInterfaceData;
begin
  Pin(1).AsBoolean:= (O.Data[1]='1');
end;</pre>
<p>The new PIR can be viewed from my website (it&#8217;s called BP PIR):</p>
<div id="attachment_1024" class="wp-caption alignnone" style="width: 274px"><img class="size-full wp-image-1024" title="Battery powered PIR" src="http://blog.hekkers.net/wp-content/uploads/2010/06/capture20-6-2010-223357.png" alt="Battery powered PIR" width="264" height="223" /><p class="wp-caption-text">Battery powered PIR</p></div>
<p>The sketch is still under development; for instance, how much difference would it make if i change the DigitalRead() into a bitRead()? I&#8217;ll have to read more about that on <a href="http://news.jeelabs.org/" target="_blank">JeeLabs</a> &#8230; Other questions are: should i increase the heartbeat interval (currently 45 seconds) or the Motion report interval? Can i create some sort of battery power monitoring with the XBee? But that will all be investigated when i&#8217;ve finished building my second motion sensor based on JeeNode and XBee..</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/06/20/new-motion-sensor-in-use/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JeeNode/ZigBee pressure sensor closed</title>
		<link>http://blog.hekkers.net/2010/05/05/jeenode-zigbee-pressure-sensor-closed/</link>
		<comments>http://blog.hekkers.net/2010/05/05/jeenode-zigbee-pressure-sensor-closed/#comments</comments>
		<pubDate>Wed, 05 May 2010 19:35:42 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Xbee]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=843</guid>
		<description><![CDATA[Now that my Zigbee/Jeenode equipped pressure sensor is working for 3 months without any problems, it was time to leave the breadboard stage and move on to something more permanent. While ordering new Jeenodes at Jean-Claude Wipplers shop, i stumbled upon a post (i should read his daily weblog more often!) that showed me just [...]]]></description>
			<content:encoded><![CDATA[<p>Now that my Zigbee/Jeenode equipped <a href="http://blog.hekkers.net/2010/01/30/wireless-pressure-sensor-first-results/" target="_blank">pressure sensor</a> is working for 3 months without any problems, it was time to leave the breadboard stage and move on to something more permanent. While ordering new Jeenodes at Jean-Claude Wipplers <a href="http://shop.jeelabs.com/" target="_blank">shop</a>, i stumbled upon a <a href="http://news.jeelabs.org/2010/03/13/jeenode-enclosure/" target="_blank">post</a> (i should read his daily weblog more often!) that showed me just what i needed: an enclosure that looked just right for this job. I ordered the Jeenodes, 2 enclosures (1 extra for when i mess up the first one and don&#8217;t want to wait for a second delivery..) and some other handy stuff.</p>
<p>First i sawed off the part of the PCB that i didn&#8217;t need, to decrease it&#8217;s size.</p>
<div id="attachment_844" class="wp-caption alignnone" style="width: 380px"><img class="size-full wp-image-844 " title="JeeNode PCB size reduction" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6001015_rotation_resize.jpg" alt="JeeNode PCB without RF part" width="370" height="192" /><p class="wp-caption-text">JeeNode PCB size reduction</p></div>
<p>Guess what? Now the length of the PCB equals the internal width of the enclosure! Nice&#8230; I still had some battery holders laying around that also fitted quite well:</p>
<div id="attachment_845" class="wp-caption alignnone" style="width: 313px"><img class="size-full wp-image-845 " title="Enclosure, batt holder and JeeNode" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6000986_resize.jpg" alt="Enclose, batt holder and JeeNode" width="303" height="321" /><p class="wp-caption-text">Enclosure, batt holder and JeeNode</p></div>
<p>I didn&#8217;t want to leave off the FTDI headers, so i used 6 straight headers and removed the plastic strip from the headers after the headers were soldered onto the PCB. With the plastic headers left on, the completed PCB was just a bit to wide for the enclosure, which caused tension and the enclosure wouldn&#8217;t close well anymore.</p>
<p>Next item that had to be prepared, was the XBee Breakout Board. Normally the top of this Breakout Board contains the 2mm XBee headers and the 0.1&#8243; spaced headers are at the opposite side. I removed the bottom headers i soldered in when i used this board for other purposes and soldered 6 wires on it from the top, only for those pins i really needed:</p>
<div id="attachment_846" class="wp-caption alignnone" style="width: 274px"><img class="size-full wp-image-846" title="XBee Breakout Board" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6000992_resize.jpg" alt="XBee Breakout Board" width="264" height="272" /><p class="wp-caption-text">XBee Breakout Board</p></div>
<p>Pin 1 (labeled Vcc) for Power, Pin 3  (labeled DIN) for transmission, Pin 9 (DTR) for controlling Sleep mode, Pin 10 (GND), Pin 11(CTS) and Pin 12 (ON) for the LED. This makes the Breakout board a lot thinner and the wires are coming out between the board and the XBee module.</p>
<p>After soldering the wires coming from the XBee board to the JeeNode, drilling a hole for the LED (which blinks when a pressure sample is being sent), soldering the wires and gluing the battery holder into the enclosure, it looked like this:</p>
<div id="attachment_847" class="wp-caption alignnone" style="width: 323px"><img class="size-full wp-image-847" title="Almost done!" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6001003_resize.jpg" alt="Almost done!" width="313" height="235" /><p class="wp-caption-text">Almost done!</p></div>
<p>The FTDI headers are very handy now, for uploading the sketch with the JeeNode already inside the enclosure; cause all you have to do is open the enclosure, gently lift up the left side of the JeeNode and connect the cable. So whenever i need to upgrade the JeeNode, i don&#8217;t have to worry about connecting issues.</p>
<div id="attachment_848" class="wp-caption alignnone" style="width: 252px"><img class="size-full wp-image-848" title="FTDI cable connected to the JeeNode" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6001012_resize.jpg" alt="FTDI cable connected to the JeeNode" width="242" height="181" /><p class="wp-caption-text">FTDI cable connected to the JeeNode</p></div>
<p>Now all there was left to do was moving the XBee module and the Pressure Plug from the Breadboard to their new &#8216;home&#8217;, add 4 batteries, click on the other half of the enclosure and.. my first WAF certified sensor was born!</p>
<p><img class="alignnone size-full wp-image-849" title="Zigbee Pressure sensor" src="http://blog.hekkers.net/wp-content/uploads/2010/05/s6001008_resize.jpg" alt="Zigbee Pressure sensor" width="483" height="363" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/05/05/jeenode-zigbee-pressure-sensor-closed/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Battery powered sensors</title>
		<link>http://blog.hekkers.net/2010/02/14/battery-powered-sensors/</link>
		<comments>http://blog.hekkers.net/2010/02/14/battery-powered-sensors/#comments</comments>
		<pubDate>Sun, 14 Feb 2010 20:33:21 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[JeeNodes]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=791</guid>
		<description><![CDATA[Now that i have 2 JeeNodes up and running for more than a week and everything&#8217;s working fine, it&#8217;s time to do some calculations on power usage of the sensors. First thing i wanted to know was how much power a combination of a sensorless Jeenode and XBee module was using, so i created a [...]]]></description>
			<content:encoded><![CDATA[<p>Now that i have 2 JeeNodes up and running for more than a week and everything&#8217;s working fine, it&#8217;s time to do some calculations on power usage of the sensors. First thing i wanted to know was how much power a combination of a sensorless Jeenode and XBee module was using, so i created a sketch that would give me some &#8216;inside&#8217; information about what was going on inside the Jeenode. The sketch i made informs me about a couple of things, like:</p>
<p>- the timespan the JeeNode is awake to power up the XBee, send a packet to the XBee and wait for it to finish transmission;</p>
<p>- the timespan the XBee is powered to send that packet of 10 bytes.</p>
<p><img class="alignnone size-full wp-image-807" title="Battery powered JeeNode" src="http://blog.hekkers.net/wp-content/uploads/2010/02/dsc_2203_resize_resize.jpg" alt="Battery powered JeeNode" width="300" height="200" /></p>
<p>With these numbers i should be able to roughly calculate the power usage of this sensor. The power that is used by the JeeNode while it&#8217;s awake is about 35 mA, while the XBee uses around 40 mA while transmitting. When both the JeeNode and XBee are in deep sleep, the combination of both uses only 60 μA.</p>
<p>The time measurements i did to find out the timespans mentioned above gave me the following figures: the total time the JeeNode is awake to read a sample from the Pressure sensor, wake the XBee, transmit the data and go back to sleep is 40 ms. The time that the XBee is awake is around 25 ms. With a sample interval of 30 seconds, and a 2000 mAh battery, i have calculated a battery life of more than a year; increase the interval to 60 seconds (still good enough for this type of information) and batteries should survive more than 2 years&#8230; <em>i think</em>.</p>
<p>Just ask me in a year or so ..</p>
<p>But good enough to go ahead with the expedition! <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/02/14/battery-powered-sensors/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Digital Code Lock</title>
		<link>http://blog.hekkers.net/2010/01/27/digital-code-lock/</link>
		<comments>http://blog.hekkers.net/2010/01/27/digital-code-lock/#comments</comments>
		<pubDate>Wed, 27 Jan 2010 20:45:20 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=721</guid>
		<description><![CDATA[Last Friday a Digital Code Lock arrived. I want to see if i can do something useful with it. It is intended for use with a door opener. Above the keypad there are 3 LEDs of which 2 are freely usable; the 3rd (middle) bi-color LED shows the status of the code lock.  The code [...]]]></description>
			<content:encoded><![CDATA[<div class="mceTemp">
<p>Last Friday a Digital Code Lock arrived. I want to see if i can do something useful with it. It is intended for use with a door opener.<br />
Above the keypad there are 3 LEDs of which 2 are freely usable; the 3rd (middle) bi-color LED shows the status of the code lock.  The code lock comes with a manual with description of all connections and some connection examples.</p></div>
<div id="attachment_722" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-722" title="Digital Code Lock" src="http://blog.hekkers.net/wp-content/uploads/2010/01/dsc_2173_resize.jpg" alt="Digital Code Lock" width="300" height="186" /><p class="wp-caption-text">Digital Code Lock</p></div>
<div id="attachment_723" class="wp-caption alignnone" style="width: 310px"><img class="size-full wp-image-723" title="dsc_2172_resize" src="http://blog.hekkers.net/wp-content/uploads/2010/01/dsc_2172_resize.jpg" alt="Code Lock Internals" width="300" height="199" /><p class="wp-caption-text">Code Lock Internals</p></div>
<p>It&#8217;s one of the cheaper code locks, but if all goes well and i&#8217;m satisfied i might buy another more eye-catching one.</p>
<p>This model has a sabotage switch inside just like the tamper switch on the inside of Visonic sensors. I&#8217;m going to connect this switch to a Visonic MCT302 aux input located inside my house and any attempt to sabotage the code lock will fire the alarm. One of the freely usable LEDs is going to display the status of the alarm, the other free LED doesn&#8217;t have a function assigned yet. Just a matter of time&#8230;</p>
<p>The Code Lock will be supervised by an Arduino so i can make full use of all the functionality it has to offer.</p>
<p>To be continued&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2010/01/27/digital-code-lock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The power of Arduino and Zigbee</title>
		<link>http://blog.hekkers.net/2009/12/27/the-power-of-arduino-and-zigbee/</link>
		<comments>http://blog.hekkers.net/2009/12/27/the-power-of-arduino-and-zigbee/#comments</comments>
		<pubDate>Sun, 27 Dec 2009 18:44:15 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Xbee]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=681</guid>
		<description><![CDATA[Today i had some spare time to combine a few of the things i&#8217;ve been working on lately: My Zigbee API; Arduino; Pan &#38; Tilt mechanism I wanted to create a small executable that would enable me to control the position of the 2 servo&#8217;s. XBee module I started with programming the XBee: Zigbee End [...]]]></description>
			<content:encoded><![CDATA[<p>Today i had some spare time to combine a few of the things i&#8217;ve been working on lately:</p>
<ul>
<li>My Zigbee API;</li>
<li>Arduino;</li>
<li>Pan &amp; Tilt mechanism</li>
</ul>
<p>I wanted to create a small executable that would enable me to control the position of the 2 servo&#8217;s.</p>
<p><strong>XBee module</strong></p>
<p>I started with programming the XBee: Zigbee End Device AT firmware, the right PAN, Node Identifier ED5 (as in End Device 5), Sleep Mode=1 (Pin Hibernate). I put the module on a breadboard by use of a Breakout Board. Grounded pin 9 and used the 3.3V output of the Arduino to power the module.</p>
<p><strong>Arduino</strong></p>
<p>I strapped the Arduino Duemilanove to the same breadboard and wired the 2 servo&#8217;s. Pins 9 and 10 of the Arduino are used as PWM output for the 2 servo&#8217;s. Arduino pins 2 &amp; 3 were connected to the DIN and DOUT pins of the XBee module.</p>
<p><strong>Sketch</strong></p>
<p>Now it was time to write a sketch that would receive commands from the XBee and move the servo&#8217;s accordingly. The sketch is a real quick and dirty one, low on error handling and validation. I made up a small &#8216;protocol&#8217;: commands have to end with the exclamation mark (&#8220;!&#8221;) and can be either 1 or 2 characters long.</p>
<p><strong><span style="color: #ff0000;">P+!</span></strong> would Pan right 3 degrees, <strong><span style="color: #ff0000;">P-!</span></strong> would Pan left 3 degrees, <strong><span style="color: #ff0000;">T+!</span></strong> would Tilt up 3 degrees and so on. <strong><span style="color: #ff0000;">H!</span></strong> is the command to go back to the Home position. Of course you can extend this as much as you like, e.g. add absolute positioning, presets, you name it.</p>
<p>This is the sketch:</p>
<pre>#include &lt;NewSoftSerial.h&gt;
#include &lt;ServoTimer1.h&gt;
#include &lt;PString.h&gt;

ServoTimer1 PanServo;
ServoTimer1 TiltServo;

int PanAngle = 90;
int TiltAngle = 90;
byte DeltaPan = 3;         // move 3 degrees
byte DeltaTilt = 3;        // move 3 degrees
char cbuffer[40] = "";     // receive buffer
NewSoftSerial XBSerial = NewSoftSerial(2, 3);
PString buffer(cbuffer, sizeof(cbuffer));

void setup() {

  XBSerial.begin(9600);         // set up XBee at 9600 bps
  delay(10000);                 // wait 10 sec. for possible joining

  PanServo.attach(9);
  TiltServo.attach(10);

  PanServo.write(PanAngle);
  TiltServo.write(TiltAngle);
}

void waitforcommand()
{
  while (true)
  {
    if (XBSerial.available())
    {
      int c = XBSerial.read();
      if (c == 0x21)     // command terminator = "!"
      {
        break;
      }
      else
      {
        // add to buffer
        buffer.print(c,BYTE);
      };
    };
  };
}

void loop() {

  buffer="";
  waitforcommand();

  // what's the first character?
  switch (buffer[0])
  {
    case 0x50:             // P for Pan
      {
        // what's the next character?
        switch (buffer[1])
        {
          case 0x2B:       // +
            PanAngle += DeltaPan;
            break;

          case 0x2D:       // -
            PanAngle -= DeltaPan;
            break;
          };
          break;
      };
    case 0x54:            // T for Tilt
      {
        // what's the next character?
        switch (buffer[1])
        {
          case 0x2B:       // +
            TiltAngle += DeltaTilt;
            break;

          case 0x2D:       // -
            TiltAngle -= DeltaTilt;
            break;
          };
          break;
      };
    case 0x48:            // H for Home
      {
        PanAngle=90;
        TiltAngle=90;
        break;
      };  

  };

  // check boundaries for Pan
  PanAngle=(PanAngle &lt; 0)?0:PanAngle;
  PanAngle=(PanAngle &gt; 180)?180:PanAngle;

  // check boundaries for Tilt
  TiltAngle=(TiltAngle &lt; 90)?90:TiltAngle;
  TiltAngle=(TiltAngle &gt; 180)?180:TiltAngle;

  // Set dervo's accordingly
  PanServo.write(PanAngle);
  TiltServo.write(TiltAngle);

}</pre>
<p><strong>PC software</strong></p>
<p>Next item was a small program that would use the API to address the XBee module.</p>
<div id="attachment_682" class="wp-caption alignnone" style="width: 338px"><img class="size-full wp-image-682 " title="XBee servo control" src="http://blog.hekkers.net/wp-content/uploads/2009/12/capture18-8-2009-14285427-12-2009-184734.png" alt="XBee servo control" width="328" height="350" /><p class="wp-caption-text">XBee servo control</p></div>
<p>4  buttons for Left, Rigth, Up and Down, a Home button and a button to connect to the Zigbee network. Not very spectacular, I&#8217;d say.</p>
<p>There are 2 important API functions that are used to communicate with the Zigbee module:</p>
<ul>
<li>Node Discovery</li>
<li>XBee Transmit Request.</li>
</ul>
<p>The code that is executed when the &#8220;Connect&#8221; button is pressed, sends out a Node Discovery command. This will trigger all joined Zigbee modules to respond with information about themselves, like 16- and 64-bit address, node identifier and some more interesting stuff. The code goes something like this:</p>
<pre>  XB:=TXBEE.Create(14,9600);
  XB.Open;
  gXBeeModules.Clear;
  cmd:=TXBee_NodeDiscover.Create('');
  XB.SendPacket(cmd.GetPacket);</pre>
<p>The Node Identifier is used to see if the Zigbee module that is connected to the Arduino, is &#8220;in the air&#8221;. Cause it doesn&#8217;t have to be, it could be disconnected from power or whatever&#8230;</p>
<p>When the Zigbee module with Node Identifier &#8220;&#8221;ED5&#8243; has responded, the 5 buttons are enabled and clicking them will move the servo&#8217;s. This is done with the XBee Transmit Request function; a string is being sent to the XBee and the XBee will take care of transferring it out on the UART.  Below the code for the &#8220;Home&#8221; button:</p>
<pre>i:=gXBeeModules.Indexof('ED5');
if i &gt;=0
then begin</pre>
<pre style="padding-left: 30px;">Module := TXBeeModule(gXBeeModules.Objects[i]);
Addr16:= Module.Addr16 ;
Addr64:= Module.Addr64 ;
TR:=TXBeeTransmitRequest.Create(1,Addr16,Addr64,"<strong><span style="color: #ff0000;">H!</span></strong>");
X.SendPacket(TR.GetPacket);</pre>
<pre>end;</pre>
<p>Et voila, the servo&#8217;s start moving!</p>
<p>To see how (good or bad) it works, i&#8217;ve made a small video.<br />
<span style="text-decoration: underline;"><strong>The power of Arduino and Zigbee!!!</strong></span></p>
<p><object width="425" height="344" data="http://www.youtube.com/v/UyE3TjXRdaQ&amp;hl=nl_NL&amp;fs=1&amp;" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/UyE3TjXRdaQ&amp;hl=nl_NL&amp;fs=1&amp;" /><param name="allowfullscreen" value="true" /></object></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2009/12/27/the-power-of-arduino-and-zigbee/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ATMega328 and its Watchdog Timer</title>
		<link>http://blog.hekkers.net/2009/12/25/atmega328-and-its-watchdog-timer/</link>
		<comments>http://blog.hekkers.net/2009/12/25/atmega328-and-its-watchdog-timer/#comments</comments>
		<pubDate>Fri, 25 Dec 2009 12:15:34 +0000</pubDate>
		<dc:creator>Robert Hekkers</dc:creator>
				<category><![CDATA[Domotica]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Xbee]]></category>
		<category><![CDATA[Zigbee]]></category>

		<guid isPermaLink="false">http://blog.hekkers.net/?p=662</guid>
		<description><![CDATA[Now that i managed to put an XBee ZB module to sleep, all i had left to do was being able to put the RBBB to sleep for a certain amount of time (and have it wake up again!).  It would be very nice if i could use 2 triggers for waking up the controller: [...]]]></description>
			<content:encoded><![CDATA[<p>Now that i managed to put an XBee ZB module to sleep, all i had left to do was being able to put the RBBB to sleep for a certain amount of time (and have it wake up again!).  It would be very nice if i could use 2 triggers for waking up the controller: based on a predefined interval and by some external source (for example an attached motion detector that detects motion).</p>
<div id="attachment_673" class="wp-caption alignleft" style="width: 310px"><img class="size-full wp-image-673" title="Zigbee module" src="http://blog.hekkers.net/wp-content/uploads/2009/12/dsc_2108c_resize.jpg" alt="Zigbee module" width="300" height="332" /><p class="wp-caption-text">Low-power Zigbee &amp; Arduino</p></div>
<p>Both are actually equally important, so i tossed a coin with the outcome that i started with trying to accomplish to wake up the RBBB on a predefined interval. I found an <a href="http://interface.khm.de/index.php/lab/experiments/sleep_watchdog_battery/" target="_blank">article</a> that pretty much did what i wanted. The maximum time that the Watchdog Timer can power down the microcontroller is 8 seconds, after which it will wake up again and carry on with it&#8217;s job. I modified some things so that the power down routine is called multiple times, which results in a power down mode in multples of 8 seconds. Currently the wake up interval is set at 32 (4*8) seconds and it has run flawlessly for 16 hours now. I still have to dig in deeper to the Watchdog code see if my &#8216;modifications&#8217; can be made more efficient, but for now this will be OK.</p>
<p>Now i wonder what the power consumption of this combination of RBBB and Zigbee module is&#8230; should i let it run on a battery and wait till it stops? How long will that be&#8230;. no; i think it&#8217;s better to find a way to estimate battery life by actually measuring the power consumption. That will probably mean i will need extra hardware and tools.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hekkers.net/2009/12/25/atmega328-and-its-watchdog-timer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
