<?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>John&#039;s Ramblings &#187; Home monitoring</title>
	<atom:link href="http://john.crouchley.com/blog/archives/category/home-monitoring/feed" rel="self" type="application/rss+xml" />
	<link>http://john.crouchley.com/blog</link>
	<description>Personal record for family and friends - contact me: john at crouchley.me.uk</description>
	<lastBuildDate>Fri, 03 Feb 2012 13:30:18 +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>Wireless Arduino programming</title>
		<link>http://john.crouchley.com/blog/archives/750</link>
		<comments>http://john.crouchley.com/blog/archives/750#comments</comments>
		<pubDate>Mon, 15 Aug 2011 12:16:10 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=750</guid>
		<description><![CDATA[<p>I have recently been experimenting with some XRFs from Ciseco Plc. The firmware (v0.36) on these XRFs is beta but I understand it is about to be released. I have tested this on a Nanode and also on a Ciseco Xino for Atmel, it should work with a standard Arduino but I have not tested [...]]]></description>
			<content:encoded><![CDATA[<p>I have recently been experimenting with some <a href="http://www.ebay.co.uk/itm/XRF-wireless-UART-serial-data-module-XBee-shape-arduino-/320735107482?pt=LH_DefaultDomain_3&amp;hash=item4aad4d599a#ht_3959wt_1071" target="_blank">XRFs from Ciseco Plc</a>. The firmware (v0.36) on these XRFs is beta but I understand it is about to be released.<br />
I have tested this on a <a href="http://www.nanode.eu/" target="_blank">Nanode</a> and also on a <a href="http://www.ebay.co.uk/itm/XINO-Basic-Atmel-ATMEGA-AVR-Arduino-compatible-kit-/320737064586?pt=LH_DefaultDomain_3&amp;hash=item4aad6b368a#ht_3636wt_1071" target="_blank">Ciseco Xino for Atmel</a>, it should work with a standard Arduino but I have not tested it.</p>
<p>The new features of the firmware are:<br />
1) reduced delays when continuously sending or receiving data<br />
2) Support for remote reset</p>
<p>These when taken together allow Arduinos to be remote programmed.</p>
<p>So to set this up we need an XRF connected to the Arduino (I&#8217;ll call this the remote XRF) and an XRF connected to your PC (the host XRF).</p>
<p>Wiring, the remote XRF needs GND, PWR, Rx, Tx and pin 17 hooked up &#8211; see the fritzing diagram below,<br />
the host XRF needs to be connected serially to the host PC &#8211; e.g. by using a FTDI cable; GND, PWR Rx, Tx and pin 16 need connecting.</p>
<p>Remote XRF setup:<br />
You need to give the remote XRF an ID (command ATMY) e.g. to give the ID &#8220;NN&#8221; to the node enter the AT command &#8220;ATMY NN&#8221;.<br />
You also need to set up the baud rate to match that expected by the bootloader. This is 115200 for a UNO bootloader and 57600 for a standard ATMega386 bootloader.<br />
For the Uno<br />
ATBD 1C200<br />
and for the standard Arduino<br />
ATBD E100</p>
<p>Host XRF setup:<br />
You need to tell the host XRF the ID of the remote XRF to program.<br />
To set a remote ID of NN<br />
ATRI NN<br />
you also need to enable the remote reset (1 to enable and 0 to disable)<br />
ATRP 1<br />
Finally you need to set the baud rate as for the remote XRF.<br />
ATBD 1C200 or ATBD E100</p>
<p>Now you are all set up &#8211; run the Arduino IDE, select the board type and the port for the host XRF and program.</p>
<p>Note: This method of programming is intolerant of any radio noise or other XRF radio traffic on the same frequency/panID. I understand future firmware updates may improve this, but at the moment you may need to try and upload more than once &#8211; the Arduino IDE will tell you if it succeeded.</p>
<p>&nbsp;</p>
<p>Images:</p>
<p>Host XRF to PC.<a href="http://john.crouchley.com/blog/archives/750/hostxrf-to-pc_bb-2" rel="attachment wp-att-765"><img class="aligncenter size-full wp-image-765" title="hostXRF to PC_bb" src="http://john.crouchley.com/blog/wp-content/uploads/2011/08/hostXRF-to-PC_bb1.jpg" alt="" width="574" height="252" /></a></p>
<p>&nbsp;</p>
<p>Remote XRF to Arduino. Note Pin 17 of the XRF should be connected to the DTR line if the Arduino has a FTDI connector, also if used the capacitor value is 100nF.</p>
<p><a href="http://john.crouchley.com/blog/archives/750/remote-xrf-to-arduino-connections-2" rel="attachment wp-att-766"><img class="aligncenter size-full wp-image-766" title="remote XRF to Arduino connections" src="http://john.crouchley.com/blog/wp-content/uploads/2011/08/remote-XRF-to-Arduino-connections1.jpg" alt="" width="676" height="337" /></a></p>
<p>I built this onto a small XRF module board that Ciseco produce. Miles assures me that these will be available soon. The boards contain a 3v3 regulator as well as sufficient prototyping space for the connections needed.</p>
<p>Photo of the remote setup, Nanode, XRF and XRF module board</p>
<p><a class="tt-flickr tt-flickr-Large" href="http://www.flickr.com/photos/22788868@N02/6052656017/" target="_blank"><img class="alignnone" src="http://farm7.static.flickr.com/6068/6052656017_b047ce3570_b.jpg" alt="P8176762" width="812" height="533" /></a></p>
<p>&nbsp;</p>
<p>Photo of the host setup &#8211; SparkFun FTDI board, AdaFruit XBee board and XRF</p>
<p><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/6053215260/" target="_blank"><img class="alignnone" src="http://farm7.static.flickr.com/6063/6053215260_cc43b43f2a.jpg" alt="P8176763" width="500" height="414" /></a></p>
<p>Videos:<br />
<object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/QqD78i_qL-g&#038;hl=en_US&#038;feature=player_embedded&#038;version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/QqD78i_qL-g&#038;hl=en_US&#038;feature=player_embedded&#038;version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></embed></object></p>
<p><object width="640" height="390"><param name="movie" value="http://www.youtube.com/v/B5SRaesmpGo&#038;hl=en_US&#038;feature=player_embedded&#038;version=3"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.youtube.com/v/B5SRaesmpGo&#038;hl=en_US&#038;feature=player_embedded&#038;version=3" type="application/x-shockwave-flash" allowfullscreen="true" allowScriptAccess="always" width="640" height="390"></embed></object><br />
<strong>Disclosure:</strong> Miles (Ciseco) lives near to me, we met at the Nottingham Hackspace. In return for beta testing Miles supplies me with some of his kit.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/750/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Arduino reading a CSV pachube feed with the ENC28J60</title>
		<link>http://john.crouchley.com/blog/archives/706</link>
		<comments>http://john.crouchley.com/blog/archives/706#comments</comments>
		<pubDate>Tue, 24 Aug 2010 12:12:14 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=706</guid>
		<description><![CDATA[<p>The question of how to do GET requests with the ENC28J60 arose recently so here is an example. This is using the etherShield from Nuelectronics and @andrewdlindsay&#8216;s etherShield library.</p> <p>The code assumes some familiarity with the ethershield examples.</p> #include &#60;etherShield.h&#62; static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x28}; static uint8_t myip[4] = {192,168,1,25}; // Default gateway. The ip [...]]]></description>
			<content:encoded><![CDATA[<p>The question of how to do GET requests with the ENC28J60 arose recently so here is an example.<br />
This is using the etherShield from <a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&amp;cPath=1&amp;products_id=4" target="_blank">Nuelectronics</a> and <a href="http://twitter.com/andrewdlindsay" target="_blank">@andrewdlindsay</a>&#8216;s <a href="http://blog.thiseldo.co.uk/?p=422" target="_blank">etherShield library</a>.</p>
<p>The code assumes some familiarity with the ethershield examples.</p>
<pre>#include &lt;etherShield.h&gt;

static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x28};
static uint8_t myip[4] = {192,168,1,25};
// Default gateway. The ip address of your DSL router. It can be set to the same as
// websrvip the case where there is no default GW to access the
// web server (=web server is on the same lan as this host)
static uint8_t gwip[4] = {192,168,1,1};

//============================================================================================================
// Pachube declarations
//============================================================================================================
#define PORT 80                   // HTTP

// the etherShield library does not really support sending additional info in a get request
// here we fudge it in the host field to add the API key
// Http header is
// Host: &lt;HOSTNAME&gt;
// X-PachubeApiKey: xxxxxxxx
// User-Agent: Arduino/1.0
// Accept: text/html
#define HOSTNAME "www.pachube.com\r\nX-PachubeApiKey: xxxxxxxxxxxxxxxxxxxxxxxxxxx"          // my API key
static uint8_t websrvip[4] = {173,203,98,29};  // www.pachube.com
#define HTTPPATH "/api/9999.csv"      // The feed

EtherShield es=EtherShield();

#define BUFFER_SIZE 500
static uint8_t buf[BUFFER_SIZE+1];

void browserresult_callback(uint8_t statuscode,uint16_t datapos){
 Serial.print("Received data, status:"); Serial.println(statuscode,DEC);
 if (datapos != 0)
 {
  Serial.println((char*)&amp;buf[datapos]);
  // now search for the csv data - it follows the first blank line
  // I'm sure that there is an easier way to search for a blank line - but I threw this together quickly
  // and it works for me.
  uint16_t pos = datapos;
  while (buf[pos])    // loop until end of buffer (or we break out having found what we wanted)
  {
   while (buf[pos]) if (buf[pos++] == '\n') break;   // find the first line feed
   if (buf[pos] == 0) break; // run out of buffer
   if (buf[pos++] == '\r') break; // if it is followed by a carriage return then it is a blank line (\r\n\r\n)
  }
  if (buf[pos])  // we didn't run out of buffer
  {
   pos++;  //skip over the '\n' remaining
   Serial.print("CSV line is:");
   Serial.println((char*)&amp;buf[pos]);
  }
 }
}

void setup(){
 Serial.begin(9600);
 Serial.println("Ethershield Get example");

 /*initialize enc28j60*/
 es.ES_enc28j60Init(mymac);

 //init the ethernet/ip layer:
 es.ES_init_ip_arp_udp_tcp(mymac, myip, PORT);

 // init the web client:
 es.ES_client_set_gwip(gwip);  // e.g internal IP of dsl router

 es.ES_client_set_wwwip(websrvip);  // target web server

}

void loop()
{
 static uint32_t timetosend;
 uint16_t dat_p;
 while(1){
  // handle ping and wait for a tcp packet - calling this routine powers the sending and receiving of data
  dat_p=es.ES_packetloop_icmp_tcp(buf,es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf));
  if (dat_p == 0)
  {
   if (millis() - timetosend &gt; 10000)  // every 10 seconds
   {
    timetosend = millis();
    Serial.println("Sending request");
    // note the use of PSTR - this puts the string into code space and is compulsory in this call
    // second parameter is a variable string to append to HTTPPATH, this string is NOT a PSTR
    es.ES_client_browse_url(PSTR(HTTPPATH), NULL, PSTR(HOSTNAME), &amp;browserresult_callback);
   }
  }
 }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/706/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New Home Monitoring – part 2</title>
		<link>http://john.crouchley.com/blog/archives/638</link>
		<comments>http://john.crouchley.com/blog/archives/638#comments</comments>
		<pubDate>Sun, 18 Apr 2010 15:47:31 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=638</guid>
		<description><![CDATA[<p>********* Notice &#8211; the protocol to be used has pretty much completely changed. I am adopting the aProtocol described on the OpenKontrol web site</p> <p>aProtocol is essentially a hub polling devices, it does allow for devices to announce events but in the main it is polling. The aProtocol is still work in development, I have [...]]]></description>
			<content:encoded><![CDATA[<p>*********<br />
Notice &#8211; the protocol to be used has pretty much completely changed. I am adopting the aProtocol described on the <a href="http://www.openkontrol.org/wiki/tiki-index.php?page=main+contents">OpenKontrol web site</a></p>
<p>aProtocol is essentially a hub polling devices, it does allow for devices to announce events but in the main it is polling.<br />
The aProtocol is still work in development, I have joined the team to help make it into a robust home monitoring and automation protocol.<br />
*********</p>
<p>Now that I have decided on the hardware (JeeNode V4 for nodes and Arduino for data logger) I have started to look at the data format and protocols between the nodes/sensors and the data logger. It is clear that there are three basic types of data to be dealt with</p>
<p>a)      Current reading (sensor to data logger ). This includes events (e.g. PIR trigger or Battery Low).</p>
<p>b)      Totals &amp; counts (sensor to data logger). Note: totals/counts are never cleared down (unless the node is reset), the receiver of the data needs to keep track of the last total and subtract it. This makes it easy to get total for last 15 minutes, total for day etc.</p>
<p>c)       Requests and instructions (data logger to sensor)</p>
<p>Low level protocol will ensure message integrity (CRC check or similar). If the sending message requests it then the receiver will ack the message (most messages will not use this – see message descriptions).</p>
<p>Some means to assess transmission quality (number of missing packets) is needed. The low level transmission protocol will send an incrementing sequence number (byte) with every message. Each node will also track the last sequence number received from the data logger. The data logger will keep a table; for every node the last sequence number sent and received will be stored.</p>
<p>The basic mode of operation is that nodes will send out data at predetermined time intervals (say every x seconds – but may differ for some sensor types), if a message goes astray or is corrupted then this is not important and we will get the value next time. Whilst this is not completely accurate (for example for energy readings) in that some values may be lost it is good enough for monitoring purposes. We require to know if some messages have arrived successfully so these will request an ack, (and re-transmission if no ack is received) in these cases the receiver should be able to accept the same message more than once without issues as the ack may be lost.</p>
<p>All sensor to data logger messages will be broadcast (destination node 0) – this facilitates having more than one listener – although only the data logger will ack (if ack is requested).</p>
<p>All messages will be in the following format : 12 bytes, human readable ascii to facilitate debugging (32 bit values will be sent as hex). Numeric information will be zero padded to the left (e.g. 123 will be sent as 00000123).<br />
Message Format</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="54" valign="top">Byte #</td>
<td width="123" valign="top">Name</td>
<td width="439" valign="top">Meaning</td>
</tr>
<tr>
<td width="54" valign="top">0</td>
<td width="123" valign="top">msg_Type</td>
<td width="439" valign="top">Message type – list below</td>
</tr>
<tr>
<td width="54" valign="top">1</td>
<td width="123" valign="top">msg_NodeID</td>
<td width="439" valign="top">Sending node ID (A-Z)</td>
</tr>
<tr>
<td width="54" valign="top">2</td>
<td width="123" valign="top">msg_SnsID</td>
<td width="439" valign="top">Sensor ID within node (A-Z) + special types</td>
</tr>
<tr>
<td width="54" valign="top">3</td>
<td width="123" valign="top">msg_SnsType</td>
<td width="439" valign="top">Sensor type – list below</td>
</tr>
<tr>
<td width="54" valign="top">4</td>
<td width="123" valign="top">msg_Data1</td>
<td width="439" valign="top">Data to be sent</td>
</tr>
<tr>
<td width="54" valign="top">5</td>
<td width="123" valign="top">msg_Data2</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">6</td>
<td width="123" valign="top">msg_Data3</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">7</td>
<td width="123" valign="top">msg_Data4</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">8</td>
<td width="123" valign="top">msg_Data5</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">9</td>
<td width="123" valign="top">msg_Data6</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">10</td>
<td width="123" valign="top">msg_Data7</td>
<td width="439" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">11</td>
<td width="123" valign="top">msg_Data8</td>
<td width="439" valign="top"></td>
</tr>
</tbody>
</table>
<p>Message Types</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="54" valign="top">Type</td>
<td width="406" valign="top">Meaning</td>
</tr>
<tr>
<td width="54" valign="top">A</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">B</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">C</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">D</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">E</td>
<td width="406" valign="top">Echo &#8211; Request a I&#8217;m here message</td>
</tr>
<tr>
<td width="54" valign="top">F</td>
<td width="406" valign="top">I&#8217;m here</td>
</tr>
<tr>
<td width="54" valign="top">G</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">H</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">I</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">J</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">K</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">L</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">M</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">N</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">O</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">P</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">Q</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">R</td>
<td width="406" valign="top">Sensor reading</td>
</tr>
<tr>
<td width="54" valign="top">S</td>
<td width="406" valign="top">Request reading</td>
</tr>
<tr>
<td width="54" valign="top">T</td>
<td width="406" valign="top">Request total</td>
</tr>
<tr>
<td width="54" valign="top">U</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">V</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">X</td>
<td width="406" valign="top">Node (re)started</td>
</tr>
<tr>
<td width="54" valign="top">Y</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">Z</td>
<td width="406" valign="top"></td>
</tr>
</tbody>
</table>
<p>Some sensor IDs are reserved for special use. These  are: (lowercase letters)</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="54" valign="top">ID</td>
<td width="406" valign="top">Meaning</td>
</tr>
<tr>
<td width="54" valign="top">a</td>
<td width="406" valign="top">Total of missing received sequence numbers (16 bit)</td>
</tr>
<tr>
<td width="54" valign="top">b</td>
<td width="406" valign="top">Last sequence number received</td>
</tr>
<tr>
<td width="54" valign="top">c</td>
<td width="406" valign="top">Last sequence number transmitted</td>
</tr>
<tr>
<td width="54" valign="top">d</td>
<td width="406" valign="top">Battery low indicator</td>
</tr>
<tr>
<td width="54" valign="top"></td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top"></td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top"></td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">z</td>
<td width="406" valign="top">All sensors (e.g. to request totals).</td>
</tr>
</tbody>
</table>
<p>Sensor Types</p>
<table border="1" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td width="54" valign="top">Type</td>
<td width="406" valign="top">Meaning</td>
</tr>
<tr>
<td width="54" valign="top">A</td>
<td width="406" valign="top">Generic analogue reading (0-124)</td>
</tr>
<tr>
<td width="54" valign="top">B</td>
<td width="406" valign="top">Generic digital reading (0/1)</td>
</tr>
<tr>
<td width="54" valign="top">C</td>
<td width="406" valign="top">Counter state change (e.g.  door,   window)</td>
</tr>
<tr>
<td width="54" valign="top">D</td>
<td width="406" valign="top">Counter total (16 bit)</td>
</tr>
<tr>
<td width="54" valign="top">E</td>
<td width="406" valign="top">Energy use (Watts) – Gas or Electricity</td>
</tr>
<tr>
<td width="54" valign="top">F</td>
<td width="406" valign="top">Energy use total Watts (32 bit)</td>
</tr>
<tr>
<td width="54" valign="top">G</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">H</td>
<td width="406" valign="top">Humidity</td>
</tr>
<tr>
<td width="54" valign="top">I</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">J</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">K</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">L</td>
<td width="406" valign="top">Light Level</td>
</tr>
<tr>
<td width="54" valign="top">M</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">N</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">O</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">P</td>
<td width="406" valign="top">PIR sensor triggered</td>
</tr>
<tr>
<td width="54" valign="top">Q</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">R</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">S</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">T</td>
<td width="406" valign="top">Temperature (tenths of a degree C)</td>
</tr>
<tr>
<td width="54" valign="top">U</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">V</td>
<td width="406" valign="top"></td>
</tr>
<tr>
<td width="54" valign="top">X</td>
<td width="406" valign="top">Display (output) cursor position (row,col)</td>
</tr>
<tr>
<td width="54" valign="top">Y</td>
<td width="406" valign="top">Display (output) command (blink, colour etc)</td>
</tr>
<tr>
<td width="54" valign="top">Z</td>
<td width="406" valign="top">Display (output) data (8 bytes)</td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/638/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino XBee shield issue</title>
		<link>http://john.crouchley.com/blog/archives/487</link>
		<comments>http://john.crouchley.com/blog/archives/487#comments</comments>
		<pubDate>Sat, 13 Mar 2010 11:02:58 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[XBee]]></category>
		<category><![CDATA[Arduino Xbee]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=487</guid>
		<description><![CDATA[<p>The Arduino XBee shield uses a resistor divider to connect the TTL 5V Arduino Tx to the XBee Din line. This has the side effect of pulling the Din line to GND if the Arduino is not asserting the Tx line. Problem is that the Arduino does not have control of the TX line during [...]]]></description>
			<content:encoded><![CDATA[<p>The Arduino XBee shield uses a resistor divider to connect the TTL 5V Arduino Tx to the XBee Din line. This has the side effect of pulling the Din line to GND if the Arduino is not asserting the Tx line. Problem is that the Arduino does not have control of the TX line during the brief power up sequence.<br />
Series one (802.15.4) Xbees use a low on DIn during power up to force entry into command mode at 9600 baud &#8211; an escape for when all else fails.<br />
This means that you cannot use the XBee for about 10 seconds after power up. To avoid this you need to pull up the Arduino Tx line by attaching a 10K resistor between Tx and 5V. Here are a couple of shields I modified<br />
<a href="http://www.flickr.com/photos/22788868@N02/4428432277/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4070/4428432277_e9bf326db0.jpg" alt="P3134780" width="498" height="500" /></a> <a href="http://www.flickr.com/photos/22788868@N02/4429200228/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4016/4429200228_a1014fcfb1.jpg" alt="P3134786" width="413" height="500" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/487/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>New home monitoring setup &#8211; part 1</title>
		<link>http://john.crouchley.com/blog/archives/543</link>
		<comments>http://john.crouchley.com/blog/archives/543#comments</comments>
		<pubDate>Tue, 23 Feb 2010 21:54:12 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[Wireless]]></category>
		<category><![CDATA[XBee]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=543</guid>
		<description><![CDATA[<p>Updated 26/2/2010 I have been looking at revisiting my home monitoring setup for some time. Whilst I have considered plug computers and other slugs as the hub for this I keep coming back to the Arduino. An Arduino has enough CPU power, is cheap, very low power and I can maintain it should it develop [...]]]></description>
			<content:encoded><![CDATA[<p>Updated 26/2/2010<br />
I have been looking at revisiting my home monitoring setup for some time. Whilst I have considered plug computers and other slugs as the hub for this I keep coming back to the Arduino. An Arduino has enough CPU power, is cheap, very low power and I can maintain it should it develop a fault.</p>
<p>For the sensor communications I have decided to standardize on the <a href="http://news.jeelabs.org/docs/jn4.html" target="_blank">JeeLabs JN4</a>. Most sensors will connect directly to the sensor controllers, but for the CC128 then I will use a bare board Arduino as a data concentrator.</p>
<p><a rel="attachment wp-att-544" href="http://john.crouchley.com/blog/archives/543/architecture" target="_blank"><img class="aligncenter size-full wp-image-544" title="architecture" src="http://john.crouchley.com/blog/wp-content/uploads/2010/02/architecture.jpg" alt="new architecture for home monitoring" width="600" height="401" /></a></p>
<p>For the first part of this project I will build the data storage unit. This will have:</p>
<p>1) <a href="http://www.seeedstudio.com/depot/seeeduino-v328-fully-assembledatmega-328-p-439.html?cPath=27" target="_blank">Seeeduino 328</a> &#8211; chosen due to the additional 3.3v power available.<br />
Update 24/2/10: I am revising this decision as the Seeeduino has placed the 500mA fuse on the 5v line (not on the USB 5v line), I need more than this (it is the LCD back light that draws most of this) and the fuse keeps cutting power. I will probably end up with a standard Duemilanove and put a 3.3v regulator in for the 3.3v devices.<br />
Update 25/2/10: Measured current required &#8211; 305mA (180mA without the LCD) &#8211; so it must be the regulator cutting out because the heat sink is not adequate. Moved to Duemilanove, with 100mA 3.3v LDO regulator and although the 5v regulator does get hot I do not have any cutout problems.</p>
<p>2) <a href="http://arduino.cc/en/Main/ArduinoEthernetShield" target="_blank">Arduino ethernet shield</a></p>
<p>3) <a href="http://www.digi.com/products/wireless/point-multipoint/xbee-pro-series1-module.jsp" target="_blank">XBee-pro 802.15.4</a> for serial wireless communications connecting to the Arduino via a <a href="http://www.seeedstudio.com/depot/xbee%C3%82%C2%AE-shield-v11-by-seeedstudio-p-419.html?cPath=2" target="_blank">XBee shield</a>.<br />
Update: Using the <a href="http://news.jeelabs.org/docs/jn4.html" target="_blank">JeeLabs JN4</a> with <a href="http://www.hoperf.com/rf_fsk/rfm12b.htm" target="_blank">RFM12B</a> operating at 868MHz for the wireless communications</p>
<p>4) 128Kbyte I2C <a href="http://www.ramtron.com/products/nonvolatile-memory/" target="_blank">FRAM (RAMTRON)</a> this will be used to hold message queues &#8211; this is 3.3v</p>
<p>5) 2GB SD card &#8211; initially with <a href="http://www.ghielectronics.com/product/102" target="_blank">uALFAT controller</a> (I2C 3.3v), but I intend to use a SD card directly for the final version.</p>
<p>6) I2C serial LCD &#8211; based upon my own <a href="http://john.crouchley.com/files/ATTiny2313%20LCD%20and%20Keypad%20controller.pdf" target="_blank">ATTiny2313 I2C Serial LCD adapter</a></p>
<p>7) I2C battery backed <a href="http://www.sparkfun.com/commerce/product_info.php?products_id=99" target="_blank">RTC</a> to use as a time stamp for all readings.</p>
<p>I am using my own level converter (based upon <a href="http://ics.nxp.com/support/documents/interface/pdf/an97055.pdf" target="_blank">this</a>) to drive the 3.3v I2C bus from 5v.</p>
<p>I have gathered the necessary hardware and will start detailed design at the weekend.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/543/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>FIO (Arduino and XBEE) door, doorbell and others monitor</title>
		<link>http://john.crouchley.com/blog/archives/424</link>
		<comments>http://john.crouchley.com/blog/archives/424#comments</comments>
		<pubDate>Wed, 03 Feb 2010 11:01:28 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[FIO]]></category>
		<category><![CDATA[HomeMonitoring]]></category>
		<category><![CDATA[XBee]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=424</guid>
		<description><![CDATA[<p>I have been extending my range of inputs to the CurrentCost, Ardunio, Xport pachube logger. In order to do this I wanted a wireless sensor module. After looking round I chose the FIO, has an XBEE socket and ATMega168, very little else. Can be powered from a rechargeable LiPo battery. The next step was to [...]]]></description>
			<content:encoded><![CDATA[<p>I have been extending my range of inputs to the CurrentCost, Ardunio, Xport pachube logger.<br />
In order to do this I wanted a wireless sensor module.<br />
After looking round I chose the FIO, has an XBEE socket and ATMega168, very little else. Can be powered from a rechargeable LiPo battery.<br />
The next step was to look at the power requirements. I am using a 1000mAH battery and with the normal FIO consumption of 65mA this would last about 16 hours &#8211; not very long. After some experimentation I found that if I ran the XBEE in pin controlled sleep mode 2 (less power used than mode 1 at 3.3V) and the ATMega in full sleep I could get the consumption down to 270uA. Switching off the ADC and the analog comparator got this down further to 170uA. Assuming that we have 30 minutes active per day (I&#8217;m hoping for much less) this will run for just under 1 month. In practice (this has been in place for the last 6 months) it runs for about 4 months before it needs recharging.<br />
I am using a low value on digital inputs 2 or 3 to wake up the ATMega and then the ATMega wakes up the XBEE.<br />
<a href="http://www.flickr.com/photos/22788868@N02/4304008591/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4002/4304008591_051b01da5d.jpg" alt="" width="500" height="290" /></a><br />
To be continued &#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/424/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A TinyXML library for the Arduino</title>
		<link>http://john.crouchley.com/blog/archives/454</link>
		<comments>http://john.crouchley.com/blog/archives/454#comments</comments>
		<pubDate>Mon, 11 Jan 2010 19:14:37 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[currentcost]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=454</guid>
		<description><![CDATA[<p>A lot of devices use XML these days &#8211; and parsing the XML by hand is quite complex. I use a CurrentCost CC128 power monitor and also Twitter. Both of these have an XML interface.</p> <p>Over the last couple of months I have been developing a simple XML parser as an Arduino library &#8211; it [...]]]></description>
			<content:encoded><![CDATA[<p>A lot of devices use XML these days &#8211; and parsing the XML by hand is quite complex. I use a CurrentCost CC128 power monitor and also Twitter. Both of these have an XML interface.</p>
<p>Over the last couple of months I have been developing a simple XML parser as an Arduino library &#8211; it is table driven and so compact and easily modified. This is now ready for release &#8211; you can download it <a href="http://john.crouchley.com/files/TinyXML.zip">here</a>. The CC-128 example compiles at less than 9kB.</p>
<p>I have included a Twitter API example and also a CurrentCost CC-128 example.</p>
<p>The CC-128 example is being used to provide a data concentrator for CC-128. I am using an Arduino (Mini Pro 328) to take the cpu burden off the main Arduino,  processing serial data at 57600 baud takes up most of the power of an Arduino.</p>
<p>Connect the Mini Pro to the CC-128 using GND and CC-128 Tx to Mini Pro pin digital 1. The Mini Pro acts as an I2C slave for the main Arduino (simple connection &#8211; just link up GND, A4 and A5 &#8211; also 5V if you don&#8217;t have a separate power supply).</p>
<p>I have three current cost devices feeding the CC-128 &#8211; Electricity, Gas and a light sensor. It should be quite easy to modify the example for your configuration.</p>
<p>Master code to read from the CC128 I2C slave is roughly as follows<br />
<code><br />
  CC128Data cc128data;   // structure definition is held in the .h file</p>
<p>  Wire.beginTransmission(I2CADDR);<br />
  Wire.send(COMMAND);<br />
  Wire.send(SNAPSHOT | READALL);<br />
  Wire.endTransmission();<br />
  delay(5);      // give the I2C transmission and the slave time to deal with request<br />
                 // 2mS does not work - 3 does - give it 5 to be safe<br />
  Wire.requestFrom(I2CADDR, sizeof(CC128Data));    // request data structure bytes from slave device<br />
  byte* b = (byte*)&#038;cc128data;<br />
  for (int i = 0; i&lt;sizeof (CC128Data); i++)<br />
  {<br />
    *b++ = Wire.receive(); // receive a byte as character<br />
  }<br />
</code><br />
I will be writing up another post about the CC-128 data concentrator and the main Arduino, describing how to set up multiple I2C slaves all linked to a central Arduino CPU.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/454/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Block diagram of current home monitoring system</title>
		<link>http://john.crouchley.com/blog/archives/445</link>
		<comments>http://john.crouchley.com/blog/archives/445#comments</comments>
		<pubDate>Sun, 25 Oct 2009 23:15:42 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[HomeMonitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=445</guid>
		<description><![CDATA[<p>This is the current state fo my home monitoring system. I am working on integrating a camera (pictures visible on a web site), sms and email.</p> ]]></description>
			<content:encoded><![CDATA[<p>This is the current state fo my home monitoring system.<br />
<a href="http://www.flickr.com/photos/22788868@N02/3842370868/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm3.static.flickr.com/2477/3842370868_2400f5118b.jpg" alt="Home monitoring" width="500" height="377" /></a><br />
I am working on integrating a camera (pictures visible on a web site), sms and email.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/445/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arduino code for Currentcost/XPORT/Pachube</title>
		<link>http://john.crouchley.com/blog/archives/404</link>
		<comments>http://john.crouchley.com/blog/archives/404#comments</comments>
		<pubDate>Tue, 21 Jul 2009 17:28:44 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[currentcost]]></category>
		<category><![CDATA[ethernet]]></category>
		<category><![CDATA[HomeMonitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=404</guid>
		<description><![CDATA[<p>The code I have been developing for my Current Cost meter updating to Pachube via Arduino with XPORT is ready for sharing. You can download the code from this link. Current cost sensors are 0) Main electricity sensor &#8211; clamp on incoming live cable 1) Gas pulse sensor &#8211; see entry below 2) light sensor [...]]]></description>
			<content:encoded><![CDATA[<p>The code I have been developing for my <a href="http://www.currentcost.co.uk/" target="_blank">Current Cost</a> meter updating to <a href="http://www.pachube.com" target="_blank">Pachube</a> via <a href="http://www.arduino.cc" target="_blank">Arduino</a> with <a href="http://www.lantronix.com/device-networking/embedded-device-servers/xport.html">XPORT</a> is ready for sharing.<br />
You can download the code from <a href="http://john.crouchley.com/files/CC_XPort_Pachube_v1_4.zip">this link</a>.<br />
Current cost sensors are<br />
0) Main electricity sensor &#8211; clamp on incoming live cable<br />
1) Gas pulse sensor &#8211; see <a href="http://john.crouchley.com/blog/archives/345" target="_blank">entry below</a><br />
2) light sensor &#8211; photo resistor (about 2M ohms dark to 100 ohms bright light) as sensor across the channel inputs on the <a href="http://www.ceesquared.com/?p=11" target="_blank">Current Cost dev board</a>.<br />
Current Cost sensors are read by <a href="http://arduino.cc/en/Main/ArduinoBoardDuemilanove" target="_blank">Arduino</a>, displayed on 4&#215;20 lcd module and uploaded to <a href="http://www.pachube.com/feeds/2189" target="_blank">Pachube</a> via <a href="http://www.adafruit.com/index.php?main_page=product_info&#038;cPath=17_21&#038;products_id=83" target="_blank">Adafruit XPort</a> shield every 15 minutes.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/404/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Gas meter to CurrentCost to Arduino to Pachube up and running</title>
		<link>http://john.crouchley.com/blog/archives/345</link>
		<comments>http://john.crouchley.com/blog/archives/345#comments</comments>
		<pubDate>Sun, 12 Jul 2009 18:35:13 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Home monitoring]]></category>
		<category><![CDATA[currentcost]]></category>
		<category><![CDATA[Gas]]></category>
		<category><![CDATA[HomeMonitoring]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=345</guid>
		<description><![CDATA[<p>Built to circuit and connected it all up. Bluetacked reed switch to meter and board + cc dev board + 2 AA batteries into small container. CurrentCost meter connect to Pachube via Arduino. In order to try and get some idea of energy usage and comparison with the electricity usage I am logging KW. The [...]]]></description>
			<content:encoded><![CDATA[<p>Built to circuit and connected it all up. Bluetacked reed switch to meter and board + cc dev board + 2 AA batteries into small container.<br />
<a href="http://www.flickr.com/photos/22788868@N02/3713069233/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm4.static.flickr.com/3526/3713069233_7ec60d1dd0.jpg" alt="CurrentCost dev board with gas meter circuit" width="500" height="226" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/3713128495/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm3.static.flickr.com/2669/3713128495_956b000969.jpg" alt="P7122949" width="321" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/3713129005/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm3.static.flickr.com/2461/3713129005_1743fc5a8f.jpg" alt="P7122950" width="500" height="444" /></a><br />
CurrentCost meter connect to <a href="http://www.pachube.com/feeds/2189" target="_blank">Pachube</a> via <a href="http://www.ardunio.cc" target="_blank">Arduino</a>. In order to try and get some idea of energy usage and comparison with the electricity usage I am logging KW. The calculations are:<br />
<a href="http://www.ukenergy.co.uk/pages/gas-kwh.html" target="_blank">Gas KWhours</a> = cubicmeters * correctionfactor * calorificvalue / 3.6<br />
1 pulse is 0.01 cubic meters<br />
correctionfactor is 1.022646 (from gas bill)<br />
calorificvalue is 39.4 (from gas bill)<br />
So 1 pulse is 0.1119223 KWh.<br />
Average KW = totalKWh * 3600 / measurementperiod(seconds)<br />
I have set the measurement period to 5 minutes &#8211; this gives a reasonable resolution. At peak use I seem to get about 1 pulse every 18 seconds. Latest &#8211; I now update every 15 minutes &#8211; that way Pachube displays every update.</p>
<p><img src="http://www.pachube.com/feeds/2189/datastreams/3/history.png?w=600&#038;h=300&#038;c=33cc66&#038;b=true&#038;g=true&#038;t=Home&#038;l=Gas KW&#038;s=6" alt="Last 24 hours Gas KWatts" /></p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/345/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

