<?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>JeeLabs &#187; JeeMon</title>
	<atom:link href="http://jeelabs.org/tag/jeemon/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeelabs.org</link>
	<description>Computing stuff tied to the physical world</description>
	<lastBuildDate>Tue, 22 May 2012 22:18:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>JeeMon for early birds</title>
		<link>http://jeelabs.org/2011/11/25/jeemon-for-early-birds/</link>
		<comments>http://jeelabs.org/2011/11/25/jeemon-for-early-birds/#comments</comments>
		<pubDate>Thu, 24 Nov 2011 23:01:27 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=15982</guid>
		<description><![CDATA[Time to dive in. Let&#8217;s create a development setup for JeeMon on Mac OSX, in a new folder called &#8220;jee&#8221;: cd ~/Desktop git clone git://github.com/jcw/jeerev.git jee cd jee wget http://jeelabs.org/pub/jeemon/jeemon-macosx.zip unzip jeemon-macosx.zip That gives me the following files: There is more here than strictly needed for production use &#8211; just ignore most of this for [...]]]></description>
			<content:encoded><![CDATA[<p>Time to dive in. Let&#8217;s create a development setup for <a href="http://jeelabs.org/jeemon">JeeMon</a> on Mac OSX, in a new folder called &#8220;jee&#8221;:</p>

<pre><code>    cd ~/Desktop
    git clone git://github.com/jcw/jeerev.git jee
    cd jee
    wget http://jeelabs.org/pub/jeemon/jeemon-macosx.zip
    unzip jeemon-macosx.zip
</code></pre>

<p>That gives me the following files:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-23.21.47.png" alt="Screen Shot 2011 11 23 at 23 21 47" title="Screen Shot 2011-11-23 at 23.21.47.png" border="0" width="399" height="134" /></p>

<p>There is more here than strictly needed for production use &#8211; just ignore most of this for now. The main bits are &#8220;<code>jeemon</code>&#8221; and the &#8220;<code>kit/</code>&#8221; sub-folder with all the JeeRev code in it.</p>

<p>On Linux, the commands will be almost the same, but you&#8217;ll need to get a different JeeMon zip file.</p>

<p><del>Since I don&#8217;t use Windows myself, I&#8217;ll have to rely on help / support from others (yes, you!) to get the details right.</del>
Thanks to @tankslappa, here&#8217;s a first report of an install on XP SP3:</p>

<blockquote>
  <p>cd %homepath%\desktop<br />
  &#8220;C:\Program Files\Git\bin\git&#8221; clone git://github.com/jcw/jeerev.git jee<br />
  Cloning into jee&#8230;<br />
  remote: Counting objects: 1810, done.<br />
  remote: Compressing objects: 100% (670/670), done.<br />
  remote: Total 1810 (delta 1187), reused 1742 (delta 1119)<br />
  Receiving objects: 100% (1810/1810), 1.45 MiB | 87 KiB/s, done.<br />
  Resolving deltas: 100% (1187/1187), done.<br />
  cd jee<br />
  wget http://jeelabs.org/pub/jeemon/jeemon-win.zip</p>
</blockquote>

<p>Then unzip using your favorite zip manager, and you should be good to go (I&#8217;ll optimize further, one day).</p>

<p>Note: on Mac OSX and Linux, if &#8220;.&#8221; is not in your path, you&#8217;ll need to add it or type &#8220;<code>./jeemon</code>&#8221; i.s.o. &#8220;<code>jeemon</code>&#8221; everywhere it is mentioned below.</p>

<p>At this point, JeeMon is ready for use.
There are a few built-in commands &#8211; here&#8217;s a quick sanity check:</p>

<pre><code>    jeemon env general
</code></pre>

<p>The output provides some general details about the current runtime environment:</p>

<pre><code>    GENERAL:
           JeeMon = v1.5
          Library = /Users/jcw/Desktop/jee/kit
         Encoding = utf-8
        Directory = /Users/jcw/Desktop/jee
       Executable = /Users/jcw/Desktop/jee/jeemon
      Tcl version = 8.6b1.1
</code></pre>

<p>If you got this far, then everything is working as intended. If not: you&#8217;ve hit a bug &#8211; please get in touch.</p>

<p>But the normal procedure is to simply launch it:</p>

<pre><code>    jeemon
</code></pre>

<p>If this is the first time, you&#8217;ll get something like this:</p>

<pre><code>    No application startup code found.
    21:22:29.157      app is now running in first-time configuration mode
    21:22:29.189      web server starting on http://127.0.0.1:8181/
</code></pre>

<p>Where &#8220;first-time configuration mode&#8221; means that JeeMon didn&#8217;t find a &#8220;main.tcl&#8221; rig, which is normally used to start up. To get past this step, you need to point your web browser to the indicated URL, which&#8217;ll show this page:</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/11/Screen-Shot-2011-11-23-at-21.28.54.png" alt="Screen Shot 2011 11 23 at 21 28 54" title="Screen Shot 2011-11-23 at 21.28.54.png" border="0" width="396" height="255" /></p>

<p>There&#8217;s not much point in selecting anything else but &#8220;YES&#8221;at this stage. This creates a 3-line &#8220;main.tcl&#8221; file:</p>

<pre><code>    # default JeeMon startup file
    Log main.tcl {in [pwd]}
    Jm needs HomeApp
</code></pre>

<p>From now on, JeeMon will start up using the built-in &#8220;HomeApp&#8221; rig when there are no command-line args.</p>

<p>The next steps depend on what you&#8217;re after &#8211; you can either dive into Tcl programming and explore how JeeRev (i.e. the <code>kit/</code> area) is structured, or you can try out some examples and get a more top-down impression of it all.</p>

<p>To explore Tcl, the thing to keep in mind is that JeeMon will act as a standard no-frills Tcl 8.6 programming environment when launched with a source file as argument (just like <a href="http://www.tcl.tk/man/tcl8.6/UserCmd/tclsh.htm">tclsh</a> and <a href="http://equi4.com/tclkit/">tclkit</a>). Here&#8217;s how to make a hello-world demo &#8211; create a file called &#8220;hello.tcl&#8221; with your favorite text editor and put the following code in it:</p>

<pre><code>    puts "hello, world"
</code></pre>

<p>Then run that code using the command &#8220;<code>jeemon hello.tcl</code>&#8220;. <em>You can probably guess what it does&#8230;</em></p>

<p>If you want to use a convenient interactive shell with scrollback, history, and debugging support, download the <a href="http://tkcon.sourceforge.net/">TkCon</a> script and launch it using &#8220;<code>jeemon tkcon.tcl</code>&#8221; &#8211; this uses Tk to create a mini IDE.</p>

<p>For Tcl manuals, books, and demos, see <a href="http://www.tcl.tk/">http://www.tcl.tk/</a>. To really dive in, check out this <a href="http://www.tcl.tk/man/tcl8.5/tutorial/tcltutorial.html">tutorial</a> or <a href="http://en.wikibooks.org/wiki/Tcl_Programming">this</a>.</p>

<p>But chances are that you just want to get an idea of what JeeMon does in the context of Physical Computing, House Monitoring, or Home Automation. I&#8217;ll describe just two simple examples here, and will point to the <a href="http://jeelabs.org/jeemon">JeeMon homepage</a> for the rest. Note that everything described below is really part of JeeRev, i.e. the standard library used by JeeMon &#8211; or to put it differently, by the source files located inside the &#8220;<code>kit/</code>&#8221; folder.</p>

<p>First, let&#8217;s launch a trivial web server (you can see the code at <a href="https://github.com/jcw/jeerev/blob/master/examples/hello-web/main.tcl">examples/hello-web/main.tcl</a>):</p>

<pre><code>    jeemon examples/hello-web/
</code></pre>

<p>You&#8217;ll see a log output line, similar to this:</p>

<pre><code>    18:23:46.744      web server starting on http://127.0.0.1:8181/
</code></pre>

<p>JeeMon is now running in async event mode, and keeps running until you force it to stop (with ^C, kill, whatever). Leave it running and go to the indicated URL in your browser. You&#8217;ll be greeted with a web page generated by JeeMon. Hit refresh to convince yourself that it really works.</p>

<p>Now quit JeeMon and check out the files in the &#8220;<code>examples/hello-rf12/</code>&#8221; folder. This example connects to a JeeNode/JeeLink running the RF12demo sketch, and displays incoming packets via its web server. But before launching JeeMon, you have to tell it what serial interface (COM or tty port) to use: copy &#8220;config-sample.txt&#8221; to &#8220;config.txt&#8221; and edit it to match your setup. Make sure the JeeNode/JeeLink is plugged in, then start JeeMon:</p>

<pre><code>    jeemon examples/hello-rf12/
</code></pre>

<p>The output will look something like this:</p>

<pre><code>    18:37:57.166      web server starting on http://127.0.0.1:8181/
    18:37:58.154    rf12? [RF12demo.8] A i1* g5 @ 868 MHz 
    [...]
</code></pre>

<p>And two dozen more lines which you can ignore. Now go to that same URL again with your web browser. If your config file defines the proper net group and you have some JeeNodes sending out packets in that net group, you&#8217;ll see them in your browser after a while. This is what I got within a few minutes, here at JeeLabs:</p>

<pre><code>    #1 18:42:21 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #2 18:42:31 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #3 18:42:44 - OK 3 132 43 9 0
    #4 18:42:51 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #5 18:43:11 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #6 18:43:21 - OK 19 186 200 8 1 226 2 32 0 0 213 81 33
    #7 18:43:29 - OK 6 1 95 212 0
    [...]
</code></pre>

<p>Now might be a good time to look at the code in <a href="https://github.com/jcw/jeerev/tree/master/examples/hello-rf12/main.tcl">examples/hello-rf12/main.tcl</a> &#8211; to see how it all works.</p>

<p>Wanna experiment? Easy: quit JeeMon, create a new directory &#8220;<code>blah</code>&#8220;, and copy the files from the example to it. Edit them as you like, then start JeeMon using &#8220;<code>jeemon blah</code>&#8220;. <em>Go ahead, try it!</em> &#8211; the worst that can happen is that you get error messages. Usually, error tracebacks will refer to JeeRev files in the &#8220;<code>kit/</code>&#8221; folder.</p>

<p><em>This concludes my intro for those who want to get their feet wet with JeeMon. We&#8217;ve only scratched the surface!</em></p>

<p>I&#8217;ll work out more examples on the <a href="http://jeelabs.org/jeerev">JeeRev page</a> as I start building up my own setup here at JeeLabs. If you want to try things and run into trouble (there <em>will</em> be rough edges!) &#8211; here are <em>two</em> places to post problems and bugs:</p>

<ul>
<li>the <a href="https://github.com/jcw/jeerev/issues">JeeRev issue tracker</a> is for most issues, really &#8211; when in doubt, post your issues here</li>
<li>the <a href="https://github.com/jcw/jeemon/issues">JeeMon issue tracker</a> is <em>only</em> for platform-specific startup bugs in the JeeMon executable itself</li>
</ul>

<p>Feel free to ask and post anything else on the <a href="http://forum.jeelabs.net/">forum</a>. If it gets out of hand, I&#8217;ll set up a separate area for JeeMon.</p>

<p><em>A quick note about the <a href="http://jeelabs.com/">Shop</a>: I&#8217;m running into some shortages across the board (such as wire jumpers), which also affect the JX and WSP packs. All the missing bits are on order, but some of this might not get in before early December. My apologies for the delay and inconvenience! -jcw</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/11/25/jeemon-for-early-birds/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>JeeRev sits under the hood</title>
		<link>http://jeelabs.org/2011/11/24/jeerev-sits-under-the-hood/</link>
		<comments>http://jeelabs.org/2011/11/24/jeerev-sits-under-the-hood/#comments</comments>
		<pubDate>Wed, 23 Nov 2011 23:01:04 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=16131</guid>
		<description><![CDATA[Here&#8217;s another post about the JeeMonBusRev trilogy, i.e. the JeeMon project I started a few years ago. First, let me go into why there are still two pieces and two names left in this project: JeeMon is two things at once: the name of the entire system, and the name of the executable file to [...]]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s another post about the <a href="http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/">JeeMonBusRev</a> trilogy, i.e. the JeeMon project I started a few years ago.</p>

<p>First, let me go into why there are still two pieces and two names left in this project:</p>

<ul>
<li><p><strong>JeeMon</strong> is two things at once: the name of the entire system, and the name of the executable file to start it up. This exe file contains a general-purpose set of tools &#8211; it has no clue about Physical Computing or Home Automation. It could as well be used to build an accounting system or a CAD system&#8230; if you wanted to.</p></li>
<li><p><strong>JeeRev</strong> is the name of the software which extends the JeeMon executable for domain specific use, i.e. its run time library. This is where the code lives which <em>does</em> know very specifically about Physical Computing and Home Automation. This is also where all the (software development) action is.</p></li>
</ul>

<p>Do these names <em>stand</em> for anything? Yeah, probably &#8211; but I&#8217;ve stopped agonizing about cool acronyms.</p>

<p>JeeRev is used by JeeMon in one of two ways:</p>

<ul>
<li><p><em>Development mode</em> &#8211; as a &#8220;<code>kit/</code>&#8221; folder full of source files, which JeeMon will automatically detect and use.
This is what you get when you grab the code from <a href="https://github.com/jcw/jeerev">GitHub</a>. Easy to browse, tweak, and keep up-to-date.</p></li>
<li><p><em>Production mode</em> &#8211; as a single file called &#8220;<code>jeemon-rev</code>&#8220;. Normally, JeeMon will automatically download the latest official version of that file if it doesn&#8217;t exist yet (if there&#8217;s no &#8220;<code>kit/</code>&#8221; folder to put it in development mode). End users (i.e. <em>normal</em> people!) don&#8217;t care about JeeRev. They just download and launch JeeMon.</p></li>
</ul>

<p>The precise startup process is fully configurable &#8211; it&#8217;s documented in <a href="https://github.com/jcw/jeemon">JeeMon&#8217;s README file</a> on GitHub.</p>

<p>I suggest forgetting about production mode for now. It&#8217;s not going to matter for quite some time, even though that aspect has had a major effect on the &#8220;structural design&#8221; of JeeMon. For now, everything will be happening in development mode, with JeeRev fully exposed &#8211; <em>like a car kept in the garage with the hood open, so to speak.</em></p>

<p>To expose what&#8217;s in JeeRev, I have to describe one more mechanism &#8211; which is the way the different pieces of an application work together in JeeMon. Since I don&#8217;t know how familiar you are with recent implementations of Tcl, I&#8217;ll start from scratch and go through the basics &#8211; it&#8217;ll be easy to follow if you know <em>some</em> programming language:</p>

<p><strong>Commands</strong> &#8211; everything in Tcl is based on commands. The line &lt; <strong><code>puts "hello, world"</code></strong> > (without the &lt;>&#8217;s) is treated as a call to the command <strong>puts</strong> with one argument. The difference with older versions of Tcl, is that commands can also be namespaces (it&#8217;s actually the other way around, and they&#8217;re called &#8220;ensembles&#8221;, but let&#8217;s not be picky for now). That means that a command such as the following can mean different things:</p>

<pre><code>    Interfaces serial connect $device 57600
</code></pre>

<p>The simplest case would be that there is a command called &#8220;Interfaces&#8221; which gets called with 4 arguments. So you might expect to see a command definition somewhere in the code, which looks like this:</p>

<pre><code>    proc Interfaces {type action device baudrate} {
      ...
    }
</code></pre>

<p>But there is another interpretation in Tcl 8.6 (and 8.5): it can also be used to call a &#8220;serial&#8221; command defined in the &#8220;Interfaces&#8221; <em>namespace</em>. And in this particular case, it&#8217;s in fact nested: a command called &#8220;connect&#8221; defined in the &#8220;serial&#8221; namespace, which in turn is defined in the &#8220;Interfaces&#8221; namespace. Perhaps like this:</p>

<pre><code>    namespace eval Interfaces {
      ...
      namespace eval serial {
        ...
        proc connect {device baudrate} {
          ...
        }
        ...
      }
      ...
    }
</code></pre>

<p>Or, more succinctly:</p>

<pre><code>    proc Interfaces::serial::connect {device baudrate} {
      ...
    }
</code></pre>

<p>This is like writing &#8220;<strong>Interfaces.serial.connect(&#8230;)</strong>&#8221; in Python, Ruby, or Lua. But not quite &#8211; it&#8217;s slightly more general, in that callers don&#8217;t need to know how code is structured to be able to perform certain operations. It also allows you to alter the internal organization of the code later, without having to change all the calls themselves. But it can also be a bit more tricky, because you can&#8217;t tell from the appearance of a call where the actual code resides &#8211; you have to follow (or know) the chain in the code.</p>

<p>This is a fairly important concept in Tcl. The command &#8220;<strong>a b c d e</strong>&#8221; can lead to very different code paths (even in the same app, if things are added or re-defined at run-time), depending on whether and how &#8220;a&#8221;, &#8220;b&#8221;, etc are defined. At some point, the command name lookup &#8220;stops&#8221; and the arguments &#8220;begin&#8221;.</p>

<p>Apologies for the lengthy exposé. I really had to do this to introduce the next concept, which is&#8230;</p>

<p><strong>Rigs</strong> &#8211; this is a mechanism I&#8217;ve been refining for the past few years now, which unifies the above nesting mechanism with the way code is arranged in source files. To continue the <em>Interfaces</em> example: there&#8217;s a file in JeeRev called <a href="https://github.com/jcw/jeerev/blob/master/kit/rigs3/Interfaces/serial.tcl">serial.tcl</a>, and inside is &#8211; as you would expect &#8211; a &#8220;<strong>proc connect &#8230;</strong>&#8221; definition.</p>

<p>The point is: that &#8220;serial.tcl&#8221; source file is located in a folder called &#8220;Interfaces&#8221;. So the nesting of command detail is reflected in the way files and folders are organized inside the &#8220;<code>kit/</code>&#8221; area, i.e. JeeRev.</p>

<p>If you&#8217;re familiar with Python, you&#8217;ll recognize the module mechanism. Yep &#8211; &#8220;rigs&#8221; are similar (<em>not</em> identical).</p>

<p>Some rig conventions: 1) definitions starting with lowercase are public (i.e. &#8220;serial&#8221; and &#8220;connect&#8221;), whereas everything else is considered private to that rig, 2) &#8220;child&#8221; rigs can access the definitions in their &#8220;parent&#8221; rigs, and 3) if you don&#8217;t like the way a built-in rig works, you can supply your own and completely override it.</p>

<p>If you look at this in objected-oriented terms: rigs are essentially <em>singletons,</em> like Python / Ruby / Lua modules.
Speaking of objects: the result of the &#8220;Interfaces serial connect &#8230;&#8221; call is a connection object &#8211; Tcl 8.6 finally includes a <em>single</em> OO framework (there used to be tons!), so things are becoming a lot more uniform in Tcl-land.</p>

<p><em>Thanks for reading this far, even though I haven&#8217;t said anything about what&#8217;s inside JeeRev yet.</em></p>

<p>But with this out of the way, that&#8217;s easy: JeeRev consists of a collection of rigs, implementing all sorts of features, such as serial communication (serial), a web server (Webserver), logging (Log), config files (Config), and the very important &#8220;state manager&#8221; (State) which provides an event-based  publish / subscribe mechanism for representing the state of sensors and actuators around the house. There is a rig which manages automatic rig loading for JeeMon (Jm), and one which has some utility code I didn&#8217;t know where else to put (Ju).</p>

<p>There&#8217;s a rig called &#8220;app&#8221;,  which orchestrates startup, general flow of events, and application-wide event &#8220;hooks&#8221;.
This hook mechanism is similar to the Drupal CMS (written in PHP) &#8211; because good ideas deserve to prosper.</p>

<p>And lastly, if you supply a rig called &#8220;main&#8221;, then this will become the first point where your code can take control.</p>

<p><em>I can&#8217;t go into much more detail in this post, but I hope it gives an idea of the basic design of JeeMon + JeeRev.</em></p>

<p>Tomorrow, I&#8217;ll close this series with details about getting started with JeeMon &#8211; for those who care and dare!</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/11/24/jeerev-sits-under-the-hood/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>What&#8217;s in the yellow box?</title>
		<link>http://jeelabs.org/2011/11/23/whats-in-the-yellow-box/</link>
		<comments>http://jeelabs.org/2011/11/23/whats-in-the-yellow-box/#comments</comments>
		<pubDate>Tue, 22 Nov 2011 23:01:30 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=15583</guid>
		<description><![CDATA[So much for the big picture &#8211; but what&#8217;s this JeeMon? JeeMon ties stuff together &#8211; it can talk to serial and network interfaces using event-driven asynchronous I/O. This means that it can talk to lots of interfaces at the same time (like what the Twisted framework does in Python, but more deeply integrated into [...]]]></description>
			<content:encoded><![CDATA[<p>So much for the <a href="http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/">big picture</a> &#8211; but what&#8217;s this <a href="http://jeelabs.org/jeemon">JeeMon</a>?</p>

<p><img src="http://jeelabs.org/wp-content/uploads/2011/11/JeeMon-yellow.png" alt="JeeMon yellow" border="0" width="470" height="396" /></p>

<p><strong>JeeMon ties stuff together</strong> &#8211; it can talk to serial and network interfaces using event-driven asynchronous I/O. This means that it can talk to lots of interfaces at the same time (like what the Twisted framework does in Python, but more deeply integrated into the system).</p>

<p><strong>JeeMon collects data</strong> &#8211; it includes a column-oriented embedded and transactional database. This means that it can store lots of measurement data in a very compact format, using variable int sizes from 1 to 64 bits (usually an order of magnitude smaller than SQL databases, which add extra overhead due to their generality and are less suitable for repetitive time-series data).</p>

<p><strong>JeeMon talks to browsers</strong> &#8211; it has an efficient embedded co-routine based web-server. This means that it can be used with web browsers, delivering rich user interfaces based on JavaScript, HTML 5, CSS 3, Ajax, and SSE. By pushing the logic to the browser, even a low-end JeeMon server can create a snappy real-time UI.</p>

<p><strong>JeeMon likes to network</strong> &#8211; with the built-in event-based background network support, it&#8217;s easy to connect to (or provide) a range of network services. This lets you do remote debugging and create distributed systems based on JeeMon, as well as extract or feed information to other network-based systems.</p>

<p><strong>JeeMon has a pretty face</strong> &#8211; on desktop machines running Windows, Mac OSX, or Linux, the &#8220;Tk&#8221; toolkit is included to quickly create a local user interface which does not require a browser. This means that you can create distinctive front panels showing real-time data or perhaps extensive debugging information.</p>

<p><strong>JeeMon is dynamic</strong> &#8211; it is based on the <em>100% open source</em> Tcl scripted programming language, which is used by several Fortune 100 companies (if that matters to you). This means you can work in a mature and actively evolving programming environment, which gets away from the usual edit-compile-run cycle. Making changes in a running installation means you don&#8217;t have to always stop / restart the system during development.</p>

<p><strong>JeeMon is general-purpose</strong> &#8211; the structure of JeeMon is such that it can be used for a wide range of tasks, from quick command-line one-offs to elaborate long-running systems running in the background. This is possible because all functionality is provided as modules (&#8220;rigs&#8221;) which are loaded and activated on-demand.</p>

<p>Technically, JeeMon consists of the following parts:</p>

<ul>
<li>the <a href="http://www.tcl.tk/about/">Tcl</a> programming language implementation</li>
<li>(on desktop versions) the <a href="http://www.tkdocs.com/">Tk</a> graphical user interface</li>
<li>support for serial interfaces, sockets, and threads</li>
<li>the <a href="http://equi4.com/metakit/">Metakit</a> embedded database (by yours truly)</li>
<li>co-routine based <a href="http://wiki.tcl.tk/23626">wibble</a> web server, by Andy Goth</li>
<li>upgrade mechanism using <a href="http://equi4.com/starkits/">Starkits</a> (by yours truly)</li>
<li>domain-specific code, collectively called <a href="http://jeelabs.org/jeerev">JeeRev</a></li>
</ul>

<p>That last item is the only part in this whole equation which is in flux. It creates a context aimed specifically at environmental monitoring and home automation. <em>This is the part where I keep saying: Wait, it&#8217;s not ready yet!</em></p>

<p>Tomorrow, I&#8217;ll describe what&#8217;s inside this &#8220;JeeRev&#8221; &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/11/23/whats-in-the-yellow-box/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JeeMon? JeeBus? JeeRev?</title>
		<link>http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/</link>
		<comments>http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/#comments</comments>
		<pubDate>Mon, 21 Nov 2011 23:01:44 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=15574</guid>
		<description><![CDATA[For several years now, I&#8217;ve been working on a software project on the side, called JeeMon. Then something called JeeBus was created, and then JeeRev came along. That&#8217;s a lotta names for a pile of unfinished code! I&#8217;d like to explain what it&#8217;s all about, and where I want to take this (looking back is [...]]]></description>
			<content:encoded><![CDATA[<p>For several years now, I&#8217;ve been working on a software project on the side, called <a href="http://jeelabs.org/jeemon">JeeMon</a>. Then something called <a href="http://jeelabs.net/projects/jeebus/wiki">JeeBus</a> was created, and then <a href="http://jeelabs.org/jeerev">JeeRev</a> came along.</p>

<p><em>That&#8217;s a lotta names for a pile of unfinished code!</em></p>

<p>I&#8217;d like to explain what it&#8217;s all about, and where I want to take this (looking back is not so interesting or useful).</p>

<h2>The Big Picture ™</h2>

<p>With monitoring and control in the home and &lt;cough> Home Automation &lt;/cough>, the goal is quite simple, really: <em>to figure out what&#8217;s going on in the house and to make things happen based on events and rules.</em></p>

<p>In a nutshell: I want energy consumption graphs, and curtains which close automatically when it gets dark.</p>

<p>There are no doubt roughly one million different ways to do this, and ten million implementations out there already. JeeMon adds one more to the mix. Because I&#8217;ve looked at them all, and none of the existing ones suit me. Call it &#8220;Not Invented At JeeLabs&#8221; if you like, but I think I can help design / build a better system (please remind me to define &#8220;better&#8221; in a future weblog post, some day).</p>

<p>I&#8217;ve pondered for some time on how to present the big picture.
Threw out all my initial attempts. This says it all:</p>

<blockquote>
  <p><img src="http://jeelabs.org/wp-content/uploads/2011/11/jeemon-context.png" alt="Jeemon context" title="jeemon-context.png" border="0" width="386" height="378" /></p>
</blockquote>

<p>Let&#8217;s call the yellow box&#8230; <strong>JeeMon</strong> ! Forget about JeeBus. Forget JeeRev (it&#8217;s still there, under the hood).</p>

<p>JeeMon is the <em>always-on</em> software &#8220;switchboard&#8221; which talks to all this hardware. It can run on a dedicated little server box or on the router. The devices can be connected via serial, USB, Ethernet, WiFi, FSK, OOK, whatever.</p>

<h2>Functionality &amp; Features</h2>

<p>The primary tasks of JeeMon are to &#8230;</p>

<ol>
<li>track the state of sensors around the house</li>
<li>display this real-time state via a built-in web server</li>
<li>interface to remotely operated devices around the house</li>
<li>present one or more web pages to control these devices</li>
<li>act as a framework which is easy to install, configure, use, and extend</li>
</ol>

<p>Everything is highly modular, JeeMon is based on drivers and other extensions &#8211; collectively called &#8220;features&#8221;.</p>

<p>Some other tasks which are a natural fit for JeeMon:</p>

<ul>
<li>configuration of each sensor, device, and interface involved</li>
<li>collecting and saving the full history of all sensor data and control actions</li>
<li>presenting a drill-down interface to all that historical data</li>
<li>managing simple rules to automatically make things happen</li>
<li>access control, e.g. to prevent &#8220;junior&#8221; from wreaking havoc</li>
</ul>

<p>That&#8217;s about it. It&#8217;s that simple, and it needs to be built. JeeMon has been &#8220;work in progress&#8221; for far too long.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2011/11/22/jeemon-jeebus-jeerev/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Reflow Timer software</title>
		<link>http://jeelabs.org/2010/11/04/reflow-timer-software/</link>
		<comments>http://jeelabs.org/2010/11/04/reflow-timer-software/#comments</comments>
		<pubDate>Wed, 03 Nov 2010 23:01:38 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>
		<category><![CDATA[Reflow]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=10466</guid>
		<description><![CDATA[Another episode in the reflow controller story&#8230; Here is yesterday&#8217;s graph again, but manually annotated this time: Actually, I went ahead and extended the code to add those axis labels in there. I was concerned that they would overlap and distract from the graph data itself, but after seeing this&#8230; it clearly improves readability. The [...]]]></description>
			<content:encoded><![CDATA[<p><em>Another episode in the <a href="http://cafe.jeelabs.net/pof/04_-_reflow_controller/">reflow controller</a> story&#8230;</em></p>

<p>Here is <a href="/2010/11/03/meet-the-reflow-timer/">yesterday&#8217;s graph</a> again, but manually annotated this time:</p>

<p><img src="http://files.jeelabs.org/2010/11/annotated_reflow.png" alt="Annotated Reflow" /></p>

<p>Actually, I went ahead and extended the code to add those axis labels in there. I was concerned that they would overlap and distract from the graph data itself, but after seeing this&#8230; it clearly improves readability.</p>

<p>The trick is to get the PID control factors right, and these will be different for each setup. Right now, I just picked a couple of values which seem to be working ok on <em>my</em> particular grill. I&#8217;ve extended the JeeNode sketch to allow adjusting these values via a serial USB connection:</p>

<pre><code>    &lt;N&gt; P       P factor (x1000)
    &lt;N&gt; I       I factor (x1000)
    &lt;N&gt; D       D factor (x1000)
    &lt;N&gt; L       I limit (x1000)
</code></pre>

<p>The PID calculation is:</p>

<pre><code>    (Pfactor*Pval + Ifactor*Ival - Dfactor*Dval) / 1000
</code></pre>

<p>In other words, these factors are specified as a multiple of 0.001.</p>

<p>The result is brought into a range of 0..100. This in turn is used to determine when, how often, and how long to turn on the heater in the grill/oven/skillet.</p>

<p>The reflow profile parameters are also adjustable from the serial link:</p>

<pre><code>    &lt;N&gt; o       ON temperature (°C), default 70
    &lt;N&gt; w       minimum time in WARMUP phase (sec), default 60
    &lt;N&gt; p       temperature at end of PREHEAT phase (°C), default 140
    &lt;N&gt; s       temperature at end of SOAK phase (°C), default 170
    &lt;N&gt; m       maximum REFLOW temperature (°C), default 250
    &lt;N&gt; r       minimum time in REFLOW phase (sec), default 15
    &lt;N&gt; c       temperature at end of COOL phase (°C), default 150
    &lt;N&gt; f       temperature at end of FINAL phase (°C), default 50
</code></pre>

<p>Once the FINAL phase ends, the JeeNode will power itself down.</p>

<p>A few more parameters:</p>

<pre><code>    &lt;N&gt; l       lower calibration temperature limit (°C), default 40
    &lt;N&gt; u       upper calibration temperature limit (°C), default 120
    &lt;N&gt; d       stable duration (sec), default 5
    &lt;N&gt; t       stable trigger gap (°C), default 25
    &lt;N&gt; a       number of temperature averages to take, default 250
</code></pre>

<p>Some parameters for reporting, which happens once per second:</p>

<pre><code>    &lt;N&gt; i       wireless node ID (sending disabled if 0), default 8
    &lt;N&gt; b       wireless frequency (4=433, 8=868, 9=915), default 8
    &lt;N&gt; g       wireless net group, default 5
    &lt;N&gt; e       enable (1) or disable (0) serial reports, default 0
</code></pre>

<p>And finally, the parameters which control the FS20 remote switch:</p>

<pre><code>    &lt;N&gt; H       house code to use for FS20, default 4660
    &lt;N&gt; h       device ID to use for FS20, default 1
</code></pre>

<p>All PID factors and other parameters are stored in EEPROM, so they will remain in effect until changed.</p>

<p>To get a summary of all the current settings, type a question mark: &#8220;?&#8221;.</p>

<p>To reset all parameters to their &#8220;factory&#8221; defaults, type an exclamation mark: &#8220;!&#8221;.</p>

<p>The code for the &#8220;reflowTimer.pde&#8221; sketch is <a href="http://code.jeelabs.org/jeemon/sketches/reflowTimer/reflowTimer.pde">here</a> The current code size is ≈ 14 Kb. I&#8217;ll probably be tweaking it a bit further in the coming days.</p>

<p>One thing I&#8217;d like to try adding to the current sketch is an easy way to self-calibrate and come up with a workable set of P/I/D factors, so that it can be used with a variety of electrical grills, toasters, skillets, ovens, barbecues, whatever &#8211; under the motto: <em>if it can melt solder, we should try it!</em></p>

<p>The JeeMon script is <a href="http://code.jeelabs.org/jeemon/sketches/reflowTimer/application.tcl">here</a> and is about 150 lines of code. If you save it as &#8220;application.tcl&#8221; next to JeeMon, it will automatically be picked up when JeeMon is launched. The code is still work-in-progress at this point: you will have to manually edit the &#8220;device&#8221; variable to refer to <em>your</em> attached JeeNode/JeeLink running RF12demo &#8211; you can also set it to a COM port (Windows) or tty device (Linux/Mac). Likewise, the &#8220;nodeID&#8221; variable should be set to match the current setting in the Reflow Timer sketch (&#8220;i&#8221; parameter):</p>

<pre><code>    variable device   usb-A900ad5m    ;# which JeeNode/JeeLink to attach to
    variable nodeID   8               ;# which node ID to listen to
</code></pre>

<p>The frequency band + netgroup of the JeeNode/JeeLink are assumed to have been previously set in RF12demo.</p>

<p>Note that the script is an <em>optional</em> GUI front-end &#8211; you can launch it anytime, or you can ignore this whole <a href="http://cafe.jeelabs.net/sw/jeemon/">JeeMon</a> thing, since the sketch does not depend on it. It&#8217;ll drive the reflow process with or without the GUI.</p>

<p>If you try this out, or have suggestions about how to improve things, please let me know.</p>

<p><strong>Update</strong> &#8211; I&#8217;ve adjusted the info above to match the latest code changes.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/11/04/reflow-timer-software/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Meet the Reflow Timer</title>
		<link>http://jeelabs.org/2010/11/03/meet-the-reflow-timer/</link>
		<comments>http://jeelabs.org/2010/11/03/meet-the-reflow-timer/#comments</comments>
		<pubDate>Tue, 02 Nov 2010 23:01:54 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>
		<category><![CDATA[POF]]></category>
		<category><![CDATA[Reflow]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=10434</guid>
		<description><![CDATA[Now we&#8217;re cookin&#8217; &#8211; here&#8217;s the complete reflow configuration I am setting up for use at Jee Labs: Yes, it&#8217;s a Project On Foam again! As before, I&#8217;m using a 700 Watt low-end toaster/grill. It can heat about the area of a 10&#215;16 cm pcb and it&#8217;s really small and practical for me. I removed [...]]]></description>
			<content:encoded><![CDATA[<p><em>Now we&#8217;re cookin&#8217;</em> &#8211; here&#8217;s the complete <a href="http://cafe.jeelabs.net/pof/04_-_reflow_controller/">reflow</a> configuration I am setting up for use at Jee Labs:</p>

<p><img src="http://files.jeelabs.org/2010/11/dsc_2201.jpg" alt="Dsc 2201" /></p>

<p><em>Yes, it&#8217;s a <a href="/2009/11/27/introducing-projects-on-foam/">Project On Foam</a> again!</em></p>

<p>As before, I&#8217;m using a 700 Watt low-end toaster/grill. It can heat about the area of a 10&#215;16 cm pcb and it&#8217;s really small and practical for me. I removed the teflon-coated hot plates, and placed a thin aluminum sheet in there, to respond more quickly to heat changes. A small oven or a skillet could probably also be used.</p>

<p>The power is controlled by an FS20 remote switch (available from <a href="http://www.conrad.nl/">Conrad</a> or <a href="http://www.elv.de/">ELV</a>, both in Europe). This is very convenient, since JeeNodes can control this thing through the RFM12B without any further hardware. The big advantage: no need to mess around with 220V AC mains &#8211; <em>it&#8217;s RF-isolated!</em></p>

<p>The LCD display makes this thing independent of a PC/Mac. And the battery pack makes it a fully stand-alone solution. The JeeNode (and LCD / radio) will shut off once the temperature drops below 50 °C. This whole setup draws about 30 mA, so with a run time of 10-minutes, four AA batteries will last hundreds of runs, i.e. <em>plenty!</em></p>

<p>The <a href="http://jeelabs.org/tp1">Thermo Plug</a> and <a href="http://jeelabs.org/bp1">Blink Plug</a> have both been extended in the shop as pre-assembled unit and kit, respectively, including a thermouple which can be used up to 350 °C. I&#8217;ve also added a 4-cell battery holder.</p>

<p>Here&#8217;s how to operate this thing:</p>

<ul>
<li>set up everything, place the board inside the grill, and close the lid</li>
<li>press the GREEN button, the green LED goes on</li>
<li>wait for the BEEP, then carefully open the lid</li>
<li>wait until the green LED turns off, i.e. the temperature drops under 150 °C</li>
<li>done!</li>
</ul>

<p>This is an example of what happens during a run:</p>

<p><img src="http://files.jeelabs.org/2010/11/screen_shot_2010_11_02_at_131019.png" alt="Screen Shot 2010 11 02 at 13.10.19" /></p>

<p><em>Tomorrow, I&#8217;ll comment on this graph and the JeeMon app that produced it.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/11/03/meet-the-reflow-timer/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JeeMon device discovery</title>
		<link>http://jeelabs.org/2010/10/12/jeemon-device-discovery/</link>
		<comments>http://jeelabs.org/2010/10/12/jeemon-device-discovery/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 22:01:28 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=10104</guid>
		<description><![CDATA[Ok, I must admit that JeeMon has been a bit too ambitious in its original inception. It works quite nicely here at Jee Labs, but there are just too many hoops you have to jump through to make it happen on your own. I&#8217;ll first explain why things are the way they are, and how [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I must admit that JeeMon has been a bit too ambitious in its original inception. It works quite nicely here at Jee Labs, but there are just <em>too many hoops</em> you have to jump through to make it happen on your own.</p>

<p>I&#8217;ll first explain why things are the way they are, and how that is supposed to work, and then I&#8217;ll present a different setup for the <a href="/2010/04/13/an-ook-scope/">OOK Scope</a> which jettisons all that machinery and lets you use the OOK Scope with nothing but a single source file and JeeMon.</p>

<p>The <em>idea</em> behind the &#8220;Serial&#8221; and &#8220;JeeSketch&#8221; rigs (code modules) in JeeMon, is that it should be possible to respond to changes in interfaces dynamically. So there&#8217;s a way to scan for USB interfaces periodically:</p>

<pre><code>Serial periodicScan &lt;cmd&gt;
</code></pre>

<p>This will compare the list of USB devices it sees with the list it saw last time (once every 5 seconds by default). And then call the specified &lt;cmd> whenever an interface is added or has gone away. Only FTDI interfaces are detected, by the way.</p>

<p>The next step is to decide what to do when a new USB device is attached. I&#8217;ve been using a convention for some time now, whereby every sketch starts by sending out its own name, with optional version and configuration details. For example, RF12demo will send out a string like this to the USB connection when it starts up:</p>

<pre><code>[RF12demo.6] A i1 g5 @ 868 MHz
</code></pre>

<p>The trick is to wait for such a string when JeeMon detects the device and opens it. This is handled by the &#8220;JeeSketch&#8221; rig. Once the sketch type is known, JeeMon then tries to locate a &#8220;host.tcl&#8221; driver for it. It does this by looking in a directory, as configured at start up. I&#8217;ve been placing all my drivers in a directory called &#8220;sketches&#8221;, so my startup includes the following line:</p>

<pre><code>JeeSketch register ./sketches
</code></pre>

<p>When RF12demo connects, JeeMon checks whether &#8220;./sketches/RF12demo/host.tcl&#8221; exists, and runs it.</p>

<p>Similarly, when plugging in a JeeNode running the OOK Scope sketch, it announces itself as:</p>

<pre><code>[ookScope]
</code></pre>

<p>The script &#8220;./sketches/ookScope/host.tcl&#8221; then gets started, it creates a GUI window, takes over the communication link to process all incoming (binary) data bytes, and does its pulse histogram thing.</p>

<p>So far so good. It&#8217;s a nicely modular mechanism. I can add a new sketch, i.e. a &#8220;blah.pde&#8221; file for use in a JeeNode, and add a matching &#8220;host.tcl&#8221; script alongside to deal with the communication in any way it likes. Then, all I need to do is plug the device in and everything starts up. With a bit of care, everything is also shut down and cleaned up again when the device is removed.</p>

<p>Unfortunately, that&#8217;s not the end of the story. One of the important devices I want to support is a JeeNode or JeeLink running RF12demo. But how can JeeMon deal with <em>remote</em> nodes? After all, all they do is send packets to the central device. Each of these nodes will be running a sketch, and not all of them are necessarily the same. So we either need some sort of auto-discovery or some central configuration file. For a first implementation, I decided to use a configuration file to try and keep things, eh, simple. Which is why my startup code also contains these two commands:</p>

<pre><code>set appDir [file dir [dict get [info frame 0] file]]
Config setup $appDir/config.txt
</code></pre>

<p>That&#8217;s a tricky way of making sure that the &#8220;config.txt&#8221; file will be picked up from the same directory as the source code, i.e. the &#8220;application.tcl&#8221; file.</p>

<p>I&#8217;ll refrain from describing the config.txt file in full detail. Let me just include an example which I&#8217;ve been using around here:</p>

<hr />

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_11_at_225215.png" alt="Screen Shot 2010 10 11 at 22.52.15" /></p>

<hr />

<p>As with any such type of &#8220;registry&#8221;, you can see lots of little config details, for use in different modules and parts of the code. Even some obsolete stuff, in fact.</p>

<p>Does it work? Oh, sure, it works great and it&#8217;s very easy to extend for new modules and usage scenarios. Even node discovery works nicely, both coming on-line and dropping off-line, as seen in the <a href="/2010/03/01/node-discovery/">voltmeter</a> demo.</p>

<p><em>But there&#8217;s a problem with what I&#8217;ve described so far&#8230;</em></p>

<p>&#8230; there&#8217;s too much rope &#8211; to hang yourself. It&#8217;s brittle, it needs lots of documentation to use this stuff (unless you&#8217;re willing to dive into the JeeMon Tcl code), and it&#8217;s just too much trouble if you want to do something <em>simple</em> with JeeMon, like run the OOK Scope and nothing else. The entry curve is way too steep.</p>

<p>I can&#8217;t say I&#8217;ve figured out an alternative. There <em>is</em> a lot of ground to cover, and it <em>is</em> fairly hard to implement a system which dynamically adapts to interfaces getting plugged in and nodes coming (wirelessly) online.</p>

<p>But at the end of the day, all that extra bagage is unnecessary for simple cases.</p>

<p>Fortunately, JeeMon is flexible enough to adapt in any way I want. I don&#8217;t <em>have</em> to use any of the above machinery. So here&#8217;s the OOK Scope logic as a single &#8220;application.tcl&#8221; file. No scanning, no config, nothing:</p>

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_11_at_230506.png" alt="Screen Shot 2010 10 11 at 23.05.06" /></p>

<p>The full code is available <a href="http://code.jeelabs.org/jeemon/sketches/ookScope/application.tcl">here</a>. To run this version of the OOK Scope, download that file, make sure it is called &#8220;application.tcl&#8221;, and place it <em>next</em> to your JeeMon executable. Then launch JeeMon. Just make sure to have the JeeNode running <a href="http://code.jeelabs.org/jeemon/sketches/ookScope/ookScope.pde">ookScope.pde</a> plugged in.</p>

<p>If more than one FTDI interface is found, you will be asked to pick one:</p>

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_11_at_232245.png" alt="Screen Shot 2010 10 11 at 23.22.45" /></p>

<p><em>That&#8217;s it: ookScope.pde, application.tcl, plus JeeMon &#8211; should work on Windows, Mac OS X, and Linux.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/10/12/jeemon-device-discovery/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>IR pulse pickup</title>
		<link>http://jeelabs.org/2010/10/11/ir-pulse-pickup/</link>
		<comments>http://jeelabs.org/2010/10/11/ir-pulse-pickup/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 22:01:56 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[JeeMon]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=10085</guid>
		<description><![CDATA[With the sending of IR pulses out of the way, the next step is picking them up. That&#8217;s a lot simpler since there are various sensors which do this. But unfortunately I only have a QSC113 IR photo transistor at hand right now. It doesn&#8217;t have any sort of 38 kHz filtering, it just senses [...]]]></description>
			<content:encoded><![CDATA[<p>With the <a href="/2010/10/10/generating-ir-pulses/">sending</a> of IR pulses out of the way, the next step is picking them up. That&#8217;s a lot simpler since there are various sensors which do this.</p>

<p>But unfortunately I only have a QSC113 IR photo transistor at hand right now. It doesn&#8217;t have any sort of 38 kHz filtering, it just senses IR light. Then again, it still seems to work &#8211; <em>I don&#8217;t understand why,</em> to be honest:</p>

<p><img src="http://files.jeelabs.org/2010/10/dsc_2123.jpg" alt="Dsc 2123" /></p>

<p>Anyway, this seemed like a good test case to throw at the <a href="/2010/04/13/an-ook-scope/">OOK Scope</a>. The name is a bit confusing actually &#8211; it was used to analyze OOK-encoded radio signals a couple of months ago, but it&#8217;s really more general than that. What the OOK Scope does, is create a histogram of incoming pulse widths (20 .. 4604 µs with the current code).</p>

<p>As a refresher, here&#8217;s some OOK Scope output with a 433 MHz radio attached, after pressing buttons on my KAKU remote control:</p>

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_10_at_220654.png" alt="Screen Shot 2010 10 10 at 22.06.54" /></p>

<p>The histogram runs sideways: at the top are the short pulses, at the bottom the long pulses. The longer the bar, the more pulses of that length have been picked up.</p>

<p>Now the fun part is that this same setup can also be used for IR pulses:</p>

<p><img src="http://files.jeelabs.org/2010/10/dsc_2122.jpg" alt="Dsc 2122" /></p>

<p>I simply replaced the OOK radio in port 2 by my IR photo transistor, with the short lead to GND and the long lead to AIO2. Here&#8217;s what comes out when using the Apple remote:</p>

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_10_at_224736.png" alt="Screen Shot 2010 10 10 at 22.47.36" /></p>

<p>The pulses are a lot sharper, which is not surprising since it&#8217;s picking up direct light pulses now, not radiomagnetic waves of a much lower frequency and intensity that has to be detected and converted into an electrical signal by the radio.</p>

<p>Reading these values is a bit more work, because the <a href="http://code.jeelabs.org/jeemon/sketches/ookScope/ookScope.pde">ookScope.pde</a> does some trickery to increase the range of pulse widths it can report in a single byte:</p>

<pre><code>if (width &gt;= 128) {
    width = (width &gt;&gt; 1) + 64;
    if (width &gt;= 192) {
        width = (width &gt;&gt; 1) + 96;
        if (width &gt;= 224) {
            width = (width &gt;&gt; 1) + 112;
            if (width &gt;= 240) {
                width = (width &gt;&gt; 1) + 120;
                if (width &gt;= 248) {
                    width = (width &gt;&gt; 1) + 124;
                    if (width &gt;= 252) {
                        width = (width &gt;&gt; 1) + 126;
                        if (width &gt; 255)
                            width = 255;
                    }
                }
            }
        }
    }
}
</code></pre>

<p>See the <a href="/2010/04/13/an-ook-scope/">OOK Scope</a> post for details on how this works.</p>

<p>Back to the readings. The values reported are two strong bands centered around ≈ 105 and 158, respectively, with another set of pulses at 224. The pulse widths corresponding to these are ≈ 420 µs, 652 µs, and 1536 µs if I got my calculations right. That last one might be the time between retransmissions.</p>

<p>I&#8217;ll have to revisit this with a real 38 kHz filtering IR sensor when I get them in &#8211; but that sort of looks right to me. Another remote sending out RC5 codes ended up with very similar pulse widths, but with more variation.</p>

<p><em>Tomorrow, I&#8217;ll describe the OOK Scope setup in more detail, since it doesn&#8217;t seem to be working for everyone&#8230;</em></p>

<p><strong>Update</strong> &#8211; I just figured out the pinout of a 5V sensor with IR filtering (TSOP1138) &#8211; here&#8217;s what comes out:</p>

<p><img src="http://files.jeelabs.org/2010/10/screen_shot_2010_10_10_at_233207.png" alt="Screen Shot 2010 10 10 at 23.32.07" /></p>

<p>Hm, more variation now. Then again, also a <em>lot</em> more sensitive, it seems. And it looks like it should still be possible to discriminate between the two pulse widths at position 135, i.e. around 568 µs.</p>

<p>The pulse trains are now more consistent on the scope:</p>

<p><img src="http://files.jeelabs.org/2010/10/dsc_2124.jpg" alt="Dsc 2124" /></p>

<p><em>Note that I&#8217;m driving the JeeNode I/O pin to nearly 5V, which isn&#8217;t really such a good idea&#8230;</em></p>

<p>PS. That&#8217; a <a href="http://www.seeedstudio.com/depot/micro-digital-storage-oscilloscopedso-nano-p-512.html">DSO Nano</a> scope, in case you&#8217;re wondering&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/10/11/ir-pulse-pickup/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Save data to a logfile with JeeMon</title>
		<link>http://jeelabs.org/2010/10/01/save-data-to-a-logfile-with-jeemon/</link>
		<comments>http://jeelabs.org/2010/10/01/save-data-to-a-logfile-with-jeemon/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 22:01:48 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>
		<category><![CDATA[Techniques]]></category>

		<guid isPermaLink="false">http://jeelabs.org/?p=9942</guid>
		<description><![CDATA[I&#8217;ve added a little demo application called &#8220;SaveToFile&#8221; to JeeMon which saves data from an attached JeeNode or JeeLink to file, complete with timestamps. When started, you&#8217;ll need to specify which device you want to log (unless there is only one): Click on one of the lines, and you&#8217;ll get this dialog on Mac OS [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve added a little demo application called &#8220;SaveToFile&#8221; to JeeMon which saves data from an attached JeeNode or JeeLink to file, complete with timestamps.</p>

<p>When started, you&#8217;ll need to specify which device you want to log (unless there is only one):</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_210118.png" alt="Screen Shot 2010 09 30 at 21.01.18" /></p>

<p>Click on one of the lines, and you&#8217;ll get this dialog on Mac OS X (Windows and Linux look a little different):</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_210131.png" alt="Screen Shot 2010 09 30 at 21.01.31" /></p>

<p>Once you click &#8220;Save&#8221;, the main window changes to show the last received line:</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_2102071.png" alt="Screen Shot 2010 09 30 at 21.02.07" /></p>

<p>Here&#8217;s the contents of the log file at this point:</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_2102551.png" alt="Screen Shot 2010 09 30 at 21.02.55" /></p>

<p>You can just leave it running to collect more data.</p>

<p>The following code implements all this and shows a bit of Tcl and Tk scripting in action:</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_212240.png" alt="Screen Shot 2010 09 30 at 21.22.40" /></p>

<p>This code is now included in the JeeMon on-line demos, so all you need to do is get JeeMon, launch it, and then click on &#8220;Run web-based demo&#8221;:</p>

<p><img src="http://files.jeelabs.org/2010/09/screen_shot_2010_09_30_at_210434.png" alt="Screen Shot 2010 09 30 at 21.04.34" /></p>

<p>(make sure you don&#8217;t have a file called &#8220;application.tcl&#8221; next to JeeMon)</p>

<p>A window will open, just select the &#8220;SaveToFile&#8221; link, and it&#8217;ll be downloaded to the &#8220;JeeMon-demos&#8221; folder and then launched.</p>

<p>To run this code from the downloaded copy, launch JeeMon as:</p>

<pre><code>    ./JeeMon JeeMon-demos/SaveToFile.zip
</code></pre>

<p>To view the code, unpack that ZIP file and you&#8217;ll get what is shown above. You can adapt it to your needs, of course. <em>It&#8217;s all open source software!</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/10/01/save-data-to-a-logfile-with-jeemon/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pulling data from an EtherNode</title>
		<link>http://jeelabs.org/2010/08/17/pulling-data-from-an-ethernode/</link>
		<comments>http://jeelabs.org/2010/08/17/pulling-data-from-an-ethernode/#comments</comments>
		<pubDate>Mon, 16 Aug 2010 22:01:31 +0000</pubDate>
		<dc:creator>jcw</dc:creator>
				<category><![CDATA[Software]]></category>
		<category><![CDATA[JeeMon]]></category>
		<category><![CDATA[Network]]></category>

		<guid isPermaLink="false">http://news.jeelabs.org/?p=9032</guid>
		<description><![CDATA[Last month&#8217;s EtherNode sketch was an example of a simple web server which allows viewing incoming packets received by the RFM12B. Here&#8217;s a sample web page again: If JeeMon could access and pick up that data without requiring an extra JeeLink or JeeNode, then you could place the EtherNode wherever reception is best while running [...]]]></description>
			<content:encoded><![CDATA[<p>Last month&#8217;s <a href="/2010/07/14/improved-ethernode/">EtherNode sketch</a> was an example of a simple web server which allows viewing incoming packets received by the RFM12B. Here&#8217;s a sample web page again:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_07_13_at_231929.png" alt="Screen Shot 2010 07 13 at 231929" /></p>

<p>If JeeMon could access and pick up that data without requiring an extra JeeLink or JeeNode, then you could place the EtherNode wherever reception is best while running JeeMon on your desktop machine, or anywhere else.</p>

<p>In response to a <a href="http://talk.jeelabs.net/topic/456">request</a> on the forum for just that, I started writing a little demo &#8220;application.tcl&#8221; for JeeMon to do this sort of web-scraping. Here&#8217;s what I came up with (<a href="http://jeelabs.org/pub/old-jeefiles/demo-ethernodepull.tcl">code</a>):</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_16_at_103549.png" alt="Screen Shot 2010 08 16 at 10.35.49" /></p>

<p>Sample console output:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_16_at_104248.png" alt="Screen Shot 2010 08 16 at 10.42.48" /></p>

<p>The point here, is that it needs to periodically poll the EtherNode, get a web page from it, and <em>skip</em> the readings it has already seen before. That&#8217;s what most of the code in &#8220;EtherNodePull&#8221; does. Each packet that remains will be sent to the &#8220;GotPacket&#8221; proc, which just logs it on the console.</p>

<p><em>But that&#8217;s just one half of the required solution&#8230;</em></p>

<p>The bigger challenge is to also make JeeMon decode these packets, as if they came in through a serial USB link. There is quite a bit of logic in sketches/central/host.tcl to do that for a JeeNode or JeeLink running the &#8220;central&#8221; sketch (which is almost identical to RF12demo).</p>

<p>The reason this is more complicated, is that I want to be able to decode each packet in different ways, depending on the sketch running on the <em>remote</em> (sending) node. My network has more than just room nodes, and will be extended with many more node types in the future.</p>

<p>One workaround would be to collect all nodes of the same type in their own group, i.e. net group 1 for room nodes, net group 2 for the ookRelay, etc. And yes, that would work &#8211; but it&#8217;s not very convenient, and I&#8217;d need separate etherNodes to pick up the packets from each net group. <em>Messy.</em></p>

<p>The approach I have used so far, is to maintain a config section for JeeMon, with information about the type of each node, organized by frequency band, net group, and node id:</p>

<p><img src="http://files.jeelabs.org/2010/08/screen_shot_2010_08_16_at_105223.png" alt="Screen Shot 2010 08 16 at 10.52.23" /></p>

<p>It&#8217;s not automatic, but this way I just need to adjust one list whenever a new wireless node is brought online.</p>

<p>The current code in sketches/central/host.tcl is all about picking up packets, and mapping them thtough this configuration section to know what is what. It does this by setting up a pseudo &#8220;connection&#8221; whenever packets come in for the first time and includes logic to tear down this connection again when no new packets are received within a certain amount of time.</p>

<p>To use this approach with an EtherNode as data collection node, I need to re-factor the exisiting code and make the core mechanism independent of the Serial implementation. I also need to bring more of the code from central/host.tcl into the JeeMon code, so it can be re-used for EtherNodes.</p>

<p><em>Re-factoring is my middle name &#8211; I&#8217;ll update this post when the code changes are complete.</em></p>
]]></content:encoded>
			<wfw:commentRss>http://jeelabs.org/2010/08/17/pulling-data-from-an-ethernode/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.661 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-23 10:35:33 -->

