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

<channel>
	<title>Maartendamen&#039;s blog &#187; jeenode</title>
	<atom:link href="http://www.maartendamen.com/tag/jeenode/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.maartendamen.com</link>
	<description>Blogging on various IT subjects</description>
	<lastBuildDate>Tue, 22 Nov 2011 21:27:03 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Jeenode infrared project part 5: extending IR range</title>
		<link>http://www.maartendamen.com/2010/08/jeenode-infrared-project-part-5-extending-ir-range/</link>
		<comments>http://www.maartendamen.com/2010/08/jeenode-infrared-project-part-5-extending-ir-range/#comments</comments>
		<pubDate>Tue, 10 Aug 2010 13:21:55 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[jeenode]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=353</guid>
		<description><![CDATA[Ok, so my IR controller has been running for a while. Though I was only using it for receiving for now. The range of the IR LED was not sufficient enough to control my devices. Today I had a look into the hardware schematics. I increased the transmitting power by using a NPN transistor (BC549). [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so my IR controller has been running for a while. Though I was only using it for receiving for now.<br />
The range of the IR LED was not sufficient enough to control my devices. Today I had a look into the hardware schematics.<br />
I increased the transmitting power by using a NPN transistor (BC549).<br />
<span id="more-353"></span></p>
<p>Here&#8217;s the schematic I used (all at 5V, USB power):</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/08/ir_transmitter.png"><img src="http://www.maartendamen.com/wp-content/uploads/2010/08/ir_transmitter.png" alt="" title="ir_transmitter" width="343" height="360" class="alignnone size-full wp-image-354" /></a></p>
<p>Using this schematic I doubled the range of my IR LED, the power drawn in the circuit is now 37mA. My former circuit, without using a NPN transistor drew 20mA (JeeNode max per digital pin). So that&#8217;s almost twice the power.<br />
You could increase this even further using smaller valued resistors, but that would push the boundaries of the LED and transistor. I didn&#8217;t need any bigger range anyway as I use IR emitter cables attached to my devices.<br />
Now that I&#8217;m satisfied with the hardware part of sending I can start looking at the software side! </p>
<p>p.s: here&#8217;s a picture of the box right now.. cables anyone?</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/08/2010-08-10_14-04-35_13_Doetinchem.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/08/2010-08-10_14-04-35_13_Doetinchem-1024x575.jpg" alt="" title="2010-08-10_14-04-35_13_Doetinchem" width="1024" height="575" class="alignnone size-large wp-image-356" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/08/jeenode-infrared-project-part-5-extending-ir-range/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Jeenode infrared project part 4: a better home&#8230;</title>
		<link>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-4-a-better-home/</link>
		<comments>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-4-a-better-home/#comments</comments>
		<pubDate>Tue, 22 Jun 2010 20:10:03 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hotglue]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[jeenode]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=321</guid>
		<description><![CDATA[Agreed, a breadboard looks nice and &#8220;hacky&#8221;. But, it doesn&#8217;t really fit nicely into my interior :-) It&#8217;s time to give the Jeenode infrared sender/receiver a better home! The main ingredients to get this going are: Hot glue (love that stuff) Solder Some wires A Jeelabs carrier board with case A drill A lot of [...]]]></description>
			<content:encoded><![CDATA[<p>Agreed, a breadboard looks nice and &#8220;hacky&#8221;. But, it doesn&#8217;t really fit nicely into my interior :-)<br />
It&#8217;s time to give the Jeenode infrared sender/receiver a better home!</p>
<p>The main ingredients to get this going are: </p>
<ul>
<li>Hot glue (love that stuff)</li>
<li>Solder</li>
<li>Some wires</li>
<li><a href="http://cafe.jeelabs.net/lab/cb1/">A Jeelabs carrier board with case</a></li>
<li>A drill</li>
<li>A lot of patience&#8230;</li>
</ul>
<p><span id="more-321"></span></p>
<p>I started out drilling a hole for the power supply. I used an USB cable to power the Jeenode (I cut the unused wires). USB is on a lot of devices nowadays (media boxes, media tanks, sat receivers you name it) so this is an ideal power source for my IR box.</p>
<p>Here is the hole in place (one part of the box is shown):<br />
<a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box1.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box1-300x168.jpg" alt="" title="box1" width="300" height="168" class="alignnone size-medium wp-image-323" /></a></p>
<p>And here is the result of the closed box:<br />
<a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box2.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box2-300x168.jpg" alt="" title="box2" width="300" height="168" class="alignnone size-medium wp-image-326" /></a></p>
<p>The next step I took was to give the IR receiver a nice position, I choose the opposite of the power connector. I did this because I want the power connector, and other connectors out of sight.<br />
Once again I drilled a hole, inside the box I had to make a little piece of plastic tube to lift the IR sensor (I soldered it to a little hobby print board)</p>
<p>Here&#8217;s a picture of the plastic tube, and the IR sensor soldered on the hobby print board:<br />
<a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box3.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box3-300x168.jpg" alt="" title="box3" width="300" height="168" class="alignnone size-medium wp-image-327" /></a></p>
<p>And here is it glued to the box (I am a sloppy solderer, but hey it&#8217;s inside a box anyway :-) )</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box4.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box4-300x168.jpg" alt="" title="box4" width="300" height="168" class="alignnone size-medium wp-image-328" /></a></p>
<p>And this is how it looks on the outside:</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box5.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box5-300x168.jpg" alt="" title="box5" width="300" height="168" class="alignnone size-medium wp-image-329" /></a></p>
<p>Next up was wiring the cables the same way as on the breadboard, this was more work then I expected it to be. Took me quite a while to get everything wired up.<br />
Here&#8217;s the result of the wiring inside the box:</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box6.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box6-300x168.jpg" alt="" title="box6" width="300" height="168" class="alignnone size-medium wp-image-332" /></a></p>
<p>And this is how it looks from the outside:</p>
<p><a href="http://www.maartendamen.com/wp-content/uploads/2010/06/box8.jpg"><img src="http://www.maartendamen.com/wp-content/uploads/2010/06/box8-300x168.jpg" alt="" title="box8" width="300" height="168" class="alignnone size-medium wp-image-336" /></a></p>
<p>That&#8217;s it! The receiver has been put inside the box, I need some more time to fit the sender inside the box. I have some different idea&#8217;s for that instead of drilling holes.<br />
This step in the project required quite some different skills (drilling, glue&#8217;ing, soldering etc)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-4-a-better-home/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jeenode infrared project part 3: sending test</title>
		<link>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-3-sending-test/</link>
		<comments>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-3-sending-test/#comments</comments>
		<pubDate>Sun, 06 Jun 2010 16:03:51 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[jeenode]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=280</guid>
		<description><![CDATA[In the first and second part of this series I introduced my idea&#8217;s about the IR project.I also showed some basic receiving, and even receiving over the air.What was left out, was the sending part. Today I found some time to get a sending setup together.Here&#8217;s the setup: A Jeelink containing a sketch which translates serial [...]]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://www.maartendamen.com/?p=257">first</a> and <a href="http://www.maartendamen.com/?p=265">second</a> part of this series I introduced my idea&#8217;s about the IR project.<br />I also showed some basic receiving, and even receiving over the air.<br />What was left out, was the sending part. <br />Today I found some time to get a sending setup together.<br /><span id="more-280"></span>Here&#8217;s the setup:</p>
<ul>
<li>A Jeelink containing a sketch which translates serial commands to IR codes and sends them over the air;</li>
<li>A Jeenode on the receiving side, which receives the IR commands and sends them out to an IR led;</li>
<li>A python script to send commands to the serial port, to create a basic zapping demo.</li>
</ul>
<p>Here&#8217;s a little video demonstrating the sketches and python script below:</p>
<p><object width="560" height="340"><param name="movie" value="http://www.youtube.com/v/-pKP8Yxzwjo&#038;hl=nl_NL&#038;fs=1&#038;"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-pKP8Yxzwjo&#038;hl=nl_NL&#038;fs=1&#038;" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="560" height="340"></embed></object></p>
<p>The Jeelink has the following sketch:</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * mdRFReceive - Generic home automation RF12 receiver.
 * Version 0.1 June, 2010
 * Copyright 2010 Maarten Damen
 * http://www.maartendamen.com
*/
#include &lt;Ports.h&gt;
#include &lt;RF12.h&gt;

#define MAX_STRING_LEN  20

byte needToSend;
long unsigned int sendbuf;
char buffer[MAX_STRING_LEN];
int bufferIndex = 0;

void setup() {
  Serial.begin(57600);
  rf12_config();
}

static void sendIR(long unsigned int code) {
  sendbuf = code;
  needToSend = 1;
}

char* subStr (char* str, char *delim, int index) {
   char *act, *sub, *ptr;
   char output;
   static char copy[MAX_STRING_LEN];
   int i;

   // Since strtok consumes the first arg, make a copy
   strcpy(copy, str);

   for (i = 1, act = copy; i &lt;= index; i++, act = NULL) {
	sub = strtok_r(act, delim, &amp;ptr);
	if (sub == NULL) break;
   }
   return sub;
}

unsigned long long conv64(char* str)
{
    unsigned long long res = 0;

    // remove 0x or 0X part
    if((strstr(str, &quot;0x&quot;) == str) || (strstr(str, &quot;0X&quot;) == str))
        str += 2;

    // do the conversion...
    for(; *str != 0; str++)
    {
        // multiply by 16 (remember, hexadecimal == base 16)
        res &lt;&lt;= 4;
        if(strchr(&quot;0123456789&quot;, *str) != NULL) // if within 0-9...
            res |= *str - '0';
        else if(strchr(&quot;ABCDEF&quot;, *str) != NULL) // if within A-F...
            res |= *str + 10 - 'A';
        else if(strchr(&quot;abcdef&quot;, *str) != NULL) // if within a-f...
            res |= *str + 10 - 'a';
        else
        {
            res &gt;&gt;= 4;
            break;
        }
    }

    return res;
}

static void handleInput (char* command, char* argument) {
  if (strcmp(command, &quot;send_tv&quot;)  == 0)
  {
    long unsigned int test = conv64(argument);
    sendIR(test);
  }
}

void loop() {
    if (Serial.available())
    {
      char ch = Serial.read();
      if (ch == '\n')
      {
        bufferIndex = 0;
        handleInput(subStr(buffer, &quot; &quot;, 1), subStr(buffer, &quot; &quot;, 2));
      } else {
        buffer[bufferIndex++] = ch;
      }
    }

  if (rf12_recvDone() &amp;&amp; rf12_crc == 0) {
    byte n = rf12_len;
    Serial.println(&quot;Packet CRC OK&quot;);
    Serial.print((int) rf12_hdr);
    for (byte i = 0; i &lt; n; i++) {
      Serial.print(' ');
      Serial.print((int) rf12_data[i]);
    }
    Serial.println();
  }

  if (needToSend &amp;&amp; rf12_canSend()) {
    needToSend = 0;
    rf12_sendStart(0, &amp;sendbuf, sizeof sendbuf);
  }
}
</pre>
<p>The Jeenode has the following receiving sketch:</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * mdIR - IR interface for home automation.
 * Version 0.1 May, 2010
 * Copyright 2010 Maarten Damen
 * http://www.maartendamen.com
*/

#include &lt;RF12.h&gt;
#include &lt;Ports.h&gt;
#include &lt;IRremote.h&gt;

IRsend irsend;

int RECV_PIN = 4;
IRrecv irrecv(RECV_PIN);

MilliTimer sendTimer;

byte needToSend;
decode_results results;

long unsigned int sendbuf;
long unsigned int received;

struct {
    byte decode;     // IR decode
} payload;

void setup () {
    Serial.begin(57600);
    Serial.println(57600);
    Serial.println(&quot;mdIR started...&quot;);
    rf12_config();
    irrecv.enableIRIn(); // Start the IR receiver
}

void loop () {
    if (irrecv.decode(&amp;results)) {
      needToSend = 1;
      sendbuf = results.value;

      Serial.println(results.value);
      Serial.println(results.value, HEX);
      irrecv.resume(); // Receive the next value
    }

    /* TODO: rf12_canSend doesn't work if I remove this... (needs to check incoming packets?) */
    if (rf12_recvDone() &amp;&amp; rf12_crc == 0 &amp;&amp; (int) rf12_hdr == 10) {
      byte n = rf12_len;
      Serial.println(&quot;Packet CRC OK&quot;);
      Serial.println((int) n);
      for (byte i = 0; i &lt; n; i++) {
        Serial.print(' ');
        Serial.print((int) rf12_data[i]);
      }
      Serial.println();

      received = ( ((long) rf12_data[3] &lt;&lt; 24)
                       + ((long) rf12_data[2] &lt;&lt; 16)
                       + ((long) rf12_data[1] &lt;&lt; 8)
                       + ((long) rf12_data[0] ) );

      irsend.sendSamsung(received, 32);
      /* Re-enable receiving mode */
      irrecv.enableIRIn();
      Serial.println();
    }

    if (needToSend &amp;&amp; rf12_canSend()) {
        needToSend = 0;
        Serial.println(&quot;need to send&quot;);
        rf12_sendStart(0, &amp;sendbuf, sizeof sendbuf);
    }
}
</pre>
<p>The python scripts looks like this:</p>
<pre class="brush: python; title: ; notranslate">
from twisted.internet.serialport import SerialPort
import sys
from twisted.protocols import basic
if sys.platform == 'win32':
    from twisted.internet import win32eventreactor
    win32eventreactor.install()
from twisted.internet import reactor

class IRProtocol(basic.LineReceiver):
    def __init__(self):
        # Power on the tv
        reactor.callLater(10.0, self.send_tv, &quot;0xE0E040BF&quot;)

        # Zap a bit
        reactor.callLater(15.0, self.send_tv, &quot;0xE0E020DF&quot;)
        reactor.callLater(20.0, self.send_tv, &quot;0xE0E0A05F&quot;)
        reactor.callLater(25.0, self.send_tv, &quot;0xE0E0609F&quot;)
        reactor.callLater(30.0, self.send_tv, &quot;0xE0E010EF&quot;)
        reactor.callLater(35.0, self.send_tv, &quot;0xE0E0906F&quot;) 

    def lineReceived(self, line):
        &quot;&quot;&quot; Do nothing with received lines yet &quot;&quot;&quot;

    def send_tv(self, command):
        &quot;&quot;&quot;
        Send's an IR command.
        &quot;&quot;&quot;
        self.transport.write('send_tv ' + command + '\n')            

SerialPort(IRProtocol(), 6 , reactor, '57600')
reactor.run()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/06/jeenode-infrared-project-part-3-sending-test/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Green Jeenode</title>
		<link>http://www.maartendamen.com/2010/06/green-jeenode/</link>
		<comments>http://www.maartendamen.com/2010/06/green-jeenode/#comments</comments>
		<pubDate>Mon, 31 May 2010 23:30:43 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[green]]></category>
		<category><![CDATA[it]]></category>
		<category><![CDATA[jeenode]]></category>
		<category><![CDATA[power]]></category>
		<category><![CDATA[solar]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=275</guid>
		<description><![CDATA[I have just powered my first Jeenode with solar power.This node has been running for 5 days now. The solar panel is one normally used to charge cell phones.It supplies 5v and has a accu pack of 2800mah, this should keep this node running for quite a while&#8230;Click on &#8220;More&#8221; for a image of this [...]]]></description>
			<content:encoded><![CDATA[<p>I have just powered my first Jeenode with solar power.<br />This node has been running for 5 days now. <br />The solar panel is one normally used to charge cell phones.<br />It supplies 5v and has a accu pack of 2800mah, this should keep this node running for quite a while&#8230;<br />Click on &#8220;More&#8221; for a image of this Jeenode.<br /><span id="more-275"></span></p>
<p><img class="alignnone" style="display: block;" src="http://www.maartendamen.com/wp-content/uploads/2010/06/wpid-2010-05-31-20.19.38.jpg" alt="image" width="499" height="373" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/06/green-jeenode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Jeenode infrared project part 2: going wireless</title>
		<link>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-2-going-wireless/</link>
		<comments>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-2-going-wireless/#comments</comments>
		<pubDate>Mon, 31 May 2010 17:09:42 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[jeenode]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=265</guid>
		<description><![CDATA[In part 1 of this series I blogged about receiving infrared signals using an IR led. This blog post will focus on getting the signals up in the air (and off course receiving them on the other side, in my case my home automation server with a Jeelink attached) The Jeenode&#8217;s have a HopeRF wireless [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.maartendamen.com/?p=257">In part 1 of this series</a> I blogged about receiving infrared signals using an IR led. This blog post will focus on getting the signals up in the air (and off course receiving them on the other side, in my case my home automation server with a Jeelink attached)<br />
The Jeenode&#8217;s have a HopeRF wireless receiver/transmitter on board, which makes life easy.<br />
<span id="more-265"></span>Jeelabs provides a RF12 library for really easy sending over the air, the receiver in my case is a Jeelink (which is basically a Jeenode but in nice small USB stick format)</p>
<p>I modified my existing source code to enable wireless transmitting:</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * mdIR - IR interface for home automation.
 * Version 0.1 May, 2010
 * Copyright 2010 Maarten Damen
 * http://www.maartendamen.com
*/

#include &lt;RF12.h&gt;
#include &lt;Ports.h&gt;
#include &lt;IRremote.h&gt;

int RECV_PIN = 4;
IRrecv irrecv(RECV_PIN);

MilliTimer sendTimer;

byte needToSend;
decode_results results;

long unsigned int sendbuf;

struct {
    byte decode;     // IR decode
} payload;

void setup () {
    Serial.begin(57600);
    Serial.println(57600);
    Serial.println(&quot;mdIR started...&quot;);
    rf12_config();
    irrecv.enableIRIn(); // Start the IR receiver
}

void loop () {
    if (irrecv.decode(&amp;results)) {
      needToSend = 1;
      sendbuf = results.value;

      Serial.println(results.value);
      Serial.println(results.value, HEX);
      irrecv.resume(); // Receive the next value
    }

    /* TODO: rf12_canSend doesn't work if I remove this... (needs to check incoming packets?) */
    if (rf12_recvDone() &amp;&amp; rf12_crc == 0) {
    }

    if (needToSend &amp;&amp; rf12_canSend()) {
        needToSend = 0;
        Serial.println(&quot;need to send&quot;);
        rf12_sendStart(0, &amp;sendbuf, sizeof sendbuf);
    }
}
</pre>
<p>Here&#8217;s a screenshot of my Jeelink receiving the packets send by the Jeenode receiving the infrared signals:</p>
<p><img class="alignnone size-full wp-image-268" title="jeelink_ir" src="http://www.maartendamen.com/wp-content/uploads/2010/05/jeelink_ir.png" alt="jeelink_ir" width="518" height="598" /><br />
<em>Image 1: Jeelink receiving IR signals send by another Jeenode.</em> Notice the different buttons pressed.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-2-going-wireless/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Jeenode infrared project part 1: getting started</title>
		<link>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-1-getting-started/</link>
		<comments>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-1-getting-started/#comments</comments>
		<pubDate>Thu, 27 May 2010 21:43:35 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[jeenode]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=257</guid>
		<description><![CDATA[Today I received new Jeenodes, so it&#8217;s time for more electronics fun :-) One thing that I head in my head for a while was an infrared receiver and sender. I want it to be like an advanced Logitech Harmony, the main downside on the Logitech Harmony is that there is no status tracking. What [...]]]></description>
			<content:encoded><![CDATA[<p>Today I received new Jeenodes, so it&#8217;s time for more electronics fun :-)<br />
One thing that I head in my head for a while was an infrared receiver and sender.<br />
I want it to be like an advanced Logitech Harmony, the main downside on the Logitech Harmony is that there is no status tracking.<br />
What happens if the TV is already on, and your Harmony tries to turn it &#8220;on&#8221;? (right.. *poof* your TV just got powered off)</p>
<p>So, in my opinion an ideal remote has integration with my home automation system, and keeps tracking of device statuses (I can use Plugwise for example to determine if my TV is powered on or off)<br />
And what to think about turning on the TV on at your preferred time on your preferred channel? (imagine waking up, stepping inside the living room and have the morning news ready for you.. )<br />
Enough introduction, let&#8217;s dive into the hardware&#8230;</p>
<p><span id="more-257"></span><strong>Hardware used</strong></p>
<p>1 x Jeenode<br />
1 x USB-BUB<br />
1 x Vishay TSOP 1838 IR receiver (datasheet: <a href="http://www.datasheetcatalog.org/datasheets/134/301155_DS.pdf">http://www.datasheetcatalog.org/datasheets/134/301155_DS.pdf</a>)<br />
1 x Breadboard<br />
Some jumper cables, to connect stuff around&#8230;</p>
<p>Here&#8217;s a picture of my initial setup:</p>
<p><img class="alignnone size-full wp-image-258" title="106807950" src="http://www.maartendamen.com/wp-content/uploads/2010/05/106807950.jpg" alt="106807950" width="600" height="448" /><br />
<em>Image 1: Jeenode connected to IR receiver module. </em></p>
<p><strong>Software</strong></p>
<p>I quickly wanted to get started, so I google&#8217;ed around a bit.. until I found this nice IR library: <a href="http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html">http://www.arcfn.com/2009/08/multi-protocol-infrared-remote-library.html</a> (nice work Ken!)<br />
This library provides a few basic IR protocols (NEC, Sony and RC5+6)<br />
There is a test sketch included with the IR library called IRrecvDump which is nice for debugging.<br />
I tested out several remotes I had laying around here (logitech, xtreamer, samsung tv, dreambox sat receiver) unfortunately only the xtreamer remote uses the standard IR protocol.</p>
<p>My main goal is to control my TV so I started &#8216;hacking&#8217; on that IR protocol first&#8230;</p>
<p><strong>Samsung IR protocol</strong></p>
<p>My TV remote is a Samsung BN59-00609A, I had some luck that this remote is included within LIRC (<a href="http://www.lirc.org">http://www.lirc.org</a>) which has an excellent library of remotes.<br />
&#8220;All&#8221; I had to do is modify some of the existing IRlibrary code. This took me well over 2 hours :-(</p>
<p>This is the modified routine to receive the Samsung IR protocol (it looks like an extended NEC protcol):</p>
<pre class="brush: cpp; title: ; notranslate">
long IRrecv::decodeSamsung(decode_results *results) {
 long data = 0;
 int offset = 1; // Skip first space
 // Initial mark
 if (!MATCH_MARK(results-&gt;rawbuf[offset], SAMSUNG_HDR_MARK)) {
 return ERR;
 }
 offset++;

 // Check bits
 if (irparams.rawlen &lt; 2 * SAMSUNG_BITS + 4) {
 return ERR;
 }

 // Initial space
 if (!MATCH_SPACE(results-&gt;rawbuf[offset], SAMSUNG_HDR_SPACE)) {
 return ERR;
 }
 offset++;
 Serial.println(&quot;OFFSET&quot;);
 Serial.println(offset);

 for (int i = 0; i &lt; SAMSUNG_BITS; i++) {
 if (!MATCH_MARK(results-&gt;rawbuf[offset], SAMSUNG_BIT_MARK)) {
 return ERR;
 }
 offset++;
 if (MATCH_SPACE(results-&gt;rawbuf[offset], SAMSUNG_ONE_SPACE)) {
 data = (data &lt;&lt; 1) | 1;
 }
 else if (MATCH_SPACE(results-&gt;rawbuf[offset], SAMSUNG_ZERO_SPACE)) {
 data &lt;&lt;= 1;
 }
 else {
 return ERR;
 }
 offset++;
 }
 // Success
 results-&gt;bits = SAMSUNG_BITS;
 results-&gt;value = data;
 results-&gt;decode_type = SAMSUNG;
 return DECODED;
}
</pre>
<p>And here are the used variables:</p>
<pre class="brush: cpp; title: ; notranslate">
#define SAMSUNG_HDR_MARK 4500
#define SAMSUNG_BITS 32
#define SAMSUNG_HDR_SPACE 4500
#define SAMSUNG_BIT_MARK 560
#define SAMSUNG_ONE_SPACE 1600
#define SAMSUNG_ZERO_SPACE 600
</pre>
<p>Here is an example decoded button press (on/off button):</p>
<p><img class="alignnone size-full wp-image-260" title="ir_decode" src="http://www.maartendamen.com/wp-content/uploads/2010/05/ir_decode.png" alt="ir_decode" width="586" height="372" /><br />
<em>Image 2: Example key press in Arduino serial monitor.</em></p>
<p>According to the LIRC file 40BF maps to:</p>
<p>POWER            0x40BF</p>
<p>Voila! We got a match.<br />
Next up is actually sending out the actual commands for my remote, to completely replace it. To be continued!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/05/jeenode-infrared-project-part-1-getting-started/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Automating/reading sensorbin status using JeeNode/Arduino</title>
		<link>http://www.maartendamen.com/2010/01/automating-a-sensor-bin-using-jeenodearduino/</link>
		<comments>http://www.maartendamen.com/2010/01/automating-a-sensor-bin-using-jeenodearduino/#comments</comments>
		<pubDate>Sat, 30 Jan 2010 13:16:31 +0000</pubDate>
		<dc:creator>Maarten</dc:creator>
				<category><![CDATA[Home automation]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[jeenode]]></category>
		<category><![CDATA[sensorbin]]></category>

		<guid isPermaLink="false">http://www.maartendamen.com/?p=129</guid>
		<description><![CDATA[I&#8217;m currently playing around with Jeenode boards. The JeeNode is a small wireless board with an 8-bit Atmel RISC microprocessor. JeeNodes are compatible with the Arduino platform and can be programmed under Windows, Mac OS X, or Linux using sketches created with the Arduino IDE. As a first test of it&#8217;s capabilities, I wanted to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently playing around with Jeenode boards. The JeeNode is a small wireless board with an 8-bit Atmel RISC microprocessor. <a href="http://www.jeelabs.org">JeeNodes</a> are compatible with the <a href="http://arduino.cc/">Arduino</a> platform and can be programmed under Windows, Mac OS X, or Linux using sketches created with the Arduino IDE. As a first test of it&#8217;s capabilities, I wanted to read out the state of the cover of my recycle bin.</p>
<p>I have one of these recycle bins:<br />
<a href="http://www.easybin.nl/Easybin_2009-2010/assortiment.html">http://www.easybin.nl/Easybin_2009-2010/assortiment.html</a><br />
(deluxe 50)</p>
<p>The cover automatically opens when it detects motion over it.. this is nice and hygienic.</p>
<p>I decided to open up my bin. Once opened I quickly notices the most interesting part of the bin.. the motion sensor and the LED that flashes when the bin is in the open state.</p>
<p><span id="more-129"></span></p>
<p>The LED has the following states:</p>
<ul>
<li>Short red flashes when the device is alive;</li>
<li>constantly green lid when the cover is open;</li>
<li>constant red lid when the cover is closing.</li>
</ul>
<p>This led is a so called bi-color LED. It has 3 pins, one pin supplies power for the green color.. the other pin supplies power for the red color. The middle pin is the neutral/GND pin.<br />
Using a multimeter I measured the voltages on the pins.. turns out there was 2 volt on it. Great! This could be connected to the analog ports of the JeeNode.</p>
<p>I soldered some leads on the existing sensorbin board:<br />
<img class="alignnone size-full wp-image-131" title="sesnsorbin1" src="http://www.maartendamen.com/wp-content/uploads/2010/01/sesnsorbin1.png" alt="sesnsorbin1" width="563" height="422" /></p>
<p><em>Image 1: the sensorbin board with additional wires connected.</em></p>
<p>The orange wire is the green led color, the middle wire is the ground and the blue wire is the red color.<br />
Now that I connected the leads to the exisiting board I connected the orange wire to analog port 1 of the jeenode. The middle wire to ground port 1. And the blue wire to analog port 2.</p>
<p>I was now ready to go ahead and upload a &#8216;sketch&#8217; (this is a program that runs on the microprocessor) to my JeeNode.<br />
This is what I came up with:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;Ports.h&gt;
#include &lt;RF12.h&gt;

Port input (1);

/* is the bin open? */
byte isopen = 0;

void setup () {
 // initialize the serial port and the RF12 driver
 Serial.begin(57600);
 Serial.print(&quot;\n[SensorBin]&quot;);
 rf12_config();
 // set up easy transmissions at maximum rate
 rf12_easyInit(0);
}

void loop () {
 int state = input.anaRead();

 if (state &gt; 600 &amp;&amp; isopen == 0) {
 Serial.print(&quot;Cover is opened!&quot;);
 Serial.println();
 isopen = 1;
 } else if (state &lt; 600 &amp;&amp; isopen == 1) {
 Serial.print(&quot;Cover is closed again..&quot;);
 Serial.println();
 isopen = 0;
 }

 delay(1000);
}
</pre>
<p>And here is the test result:</p>
<p><img src="file:///C:/Users/Maarten/AppData/Local/Temp/moz-screenshot-3.png" alt="" /><img class="alignnone size-full wp-image-134" title="sensorbin2" src="http://www.maartendamen.com/wp-content/uploads/2010/01/sensorbin2.png" alt="sensorbin2" width="654" height="608" /></p>
<p><em>Image 2: output log from Arduino serial port monitor</em></p>
<p>Excellent! So, I can now read the status of my recycle bin.. is this life saving? No.. not really but atleast it gave me some insight on the JeeNode and Arduino platform.<br />
I want to extend this concept with the following:</p>
<ul>
<li>Sending the status of RF;</li>
<li>reading out the battery status (percentage left) of the recycle bin (this is handy to get e-mail notifications from home automation software);</li>
<li>putting in a light sensor so I can read the light status of the room the recycle bin is placed in;</li>
<li>putting in a motion sensor so I can get the motion status of the room the recycle bin is placed in;</li>
<li>etc.</li>
</ul>
<p>Oh btw.. just for for fun.. this is my test setup (JeeNode connected to USB-BUB in front, sensorbin hardware board in the back):</p>
<p><img class="alignnone size-full wp-image-135" title="sensorbin3" src="http://www.maartendamen.com/wp-content/uploads/2010/01/sensorbin3.png" alt="sensorbin3" width="704" height="528" /></p>
<p><em>Image 3: test setup in action :-)</em></p>
]]></content:encoded>
			<wfw:commentRss>http://www.maartendamen.com/2010/01/automating-a-sensor-bin-using-jeenodearduino/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

