<?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</title>
	<atom:link href="http://john.crouchley.com/blog/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>Tue, 24 Aug 2010 12:56:54 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<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 address of your DSL router. It [...]]]></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>Hacking the pink IM-Me Part 1</title>
		<link>http://john.crouchley.com/blog/archives/690</link>
		<comments>http://john.crouchley.com/blog/archives/690#comments</comments>
		<pubDate>Tue, 03 Aug 2010 11:15:32 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=690</guid>
		<description><![CDATA[<p>This is the first of several posts about the IM-Me pink wireless toy from Mattell. The aim of this post is to collect all of the relevant links I have found useful from the web.

You can currently get one (or more) of these toys for £8.99 at Amazon
The IM-Me is based upon the TI CC1110F32 [...]]]></description>
			<content:encoded><![CDATA[<p>This is the first of several posts about the IM-Me pink wireless toy from Mattell. The aim of this post is to collect all of the relevant links I have found useful from the web.<br />
<a href="http://www.flickr.com/photos/22788868@N02/4856721900/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4137/4856721900_a58bef9a61.jpg" alt="IMAG0078" width="299" height="500" /></a><a href="http://www.flickr.com/photos/22788868@N02/4856104471/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4095/4856104471_3324133e79.jpg" alt="IMAG0079" width="500" height="299" /></a><br />
You can currently get one (or more) of these toys for £8.99 at <a href="http://www.amazon.co.uk/exec/obidos/ASIN/B001CC1HNE/cmbea-21" target="_blank">Amazon</a><br />
The IM-Me is based upon the TI CC1110F32 chip, <a href="http://focus.ti.com/lit/ds/symlink/cc1110f32.pdf" target="_blank">datasheet </a><br />
Dave’s hacks – <a href="http://daveshacks.blogspot.com/2010/01/im-me-hacking.html" target="_blank">im-me hacking </a><br />
Dave’s hacks – <a href="http://daveshacks.blogspot.com/2010/01/im-me-lcd-interface-hacked.html" target="_blank">im-me LCD interface hacked </a><br />
Travis Goodspeed’s blog on the <a href="http://travisgoodspeed.blogspot.com/2010/03/im-me-goodfet-wiring-tutorial.html" target="_blank">IM-Me</a><br />
Michael Ossmans blog – <a href="http://ossmann.blogspot.com/2010/03/16-pocket-spectrum-analyzer.html" target="_blank">a $16 spectrum analyser </a><br />
<a href="http://www.modula.si/cc_flasher/en" target="_blank">CC-flasher</a> – open source programmer – most useful for the SDCC open source tool chain for the CC1110<br />
From TI:To develop software, program and debug the CC1110, the IAR Embedded Workbench for 8051 is recommended. An evaluation version of IAR EW8051 is included in the kit. This free evaluation version and a free code size limited version, can be downloaded from the web, see <a href="http://www.iar.com/ew8051" target="_blank">www.iar.com/ew8051</a> this is limited to 4K of code, this can be increased to 16K by following the instructions in section 9.1 of this <a href="http://focus.ti.com.cn/cn/lit/ug/swru236a/swru236a.pdf " target="_blank">document </a><br />
Details of the <a href="http://focus.ti.com/lit/ug/swra124/swra124.pdf" target="_blank">CC1110 debugging interface </a>and how to program it </p>
<p>The next post on this topic will look at modifying the IM-Me so that the debug interface is easily used, setting up an Arduino to program the IM-Me and the Arduino software required to interface to the IM-Me.<br />
<a href="http://www.flickr.com/photos/22788868@N02/4856105659/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4138/4856105659_af03f3a5ea.jpg" alt="IMAG0081" width="500" height="299" /></a><br />
Further posts will then look at programming the IM-Me using the IAR EW8051 IDE <a href="http://www.iar.com/ew8051" target="_blank">www.iar.com/ew8051</a> (I use the 4kb code limited Kickstart edition, increased to 16kb).</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/690/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MISO and Arduino Ethernet Shields</title>
		<link>http://john.crouchley.com/blog/archives/662</link>
		<comments>http://john.crouchley.com/blog/archives/662#comments</comments>
		<pubDate>Thu, 24 Jun 2010 12:03:23 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=662</guid>
		<description><![CDATA[<p>Both of the major Arduino ethernet shields (standard Arduino and NueElectronics) have issues with the MISO signal which prevent them being used with other SPI devices.</p>
<p>The standard Arduino shield uses the Wiznet5100 chip &#8211; this chip has a flaw in that the CS signal does not tri-state the MISO line. The Wiznet application note can [...]]]></description>
			<content:encoded><![CDATA[<p>Both of the major Arduino ethernet shields (<a href="http://arduino.cc/en/Main/ArduinoEthernetShield" target="_blank">standard Arduino</a> and <a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&amp;cPath=1&amp;products_id=4" target="_blank">NueElectronics</a>) have issues with the MISO signal which prevent them being used with other SPI devices.</p>
<p>The standard Arduino shield uses the Wiznet5100 chip &#8211; this chip has a flaw in that the CS signal does not tri-state the MISO line. The Wiznet application note can be found <a href="http://www.wiznet.co.kr/Sub_Modules/en/product/product_detail.asp?Refid=101&amp;page=1&amp;cate1=5&amp;cate2=7&amp;cate3=26&amp;pid=1011&amp;cType=2" target="_blank">here</a>. The relevant part is below.</p>
<p>Quote<br />
<em>Basically, multiple SPI slave usage is the same as single SPI slave usage. One difference between other SPI slave devices compared to the W5100 is that the MISO output is continuously driven in the W5100 whether the /SCS is asserted as high or as low. As well, when the 5100 /SCS is asserted as high when using multiple slaves, other SPI devices cannot be read or written by the SPI master on the SPI BUS simultaneously. These problems will continue unless the recommendations listed below are followed.</em></p>
<p><em>Recommendations:<br />
- When accessing another device on the SPI BUS rather than the W5100, assert the SEN pin in the W5100 as low first, then access the other devices.<br />
- When accessing the W5100, the SEN pin should be high.<br />
&#8230;<br />
The W5100?s SEN signal is input from the /SCS through the inverter. If you don?t want to use the inverter, you can control each signal through the I/O port of the MCU.</em><br />
end quote</p>
<p>So by inverting the SS line (Arduino digital 10) and driving SEN from that fixes the issue. Here is a photo of my rather crude fix &#8211; using a CMOS 4011 quad 2 input NAND gate chip. Note this is a DFRobot clone &#8211; the pads for the PROG jumper (one connected to SEN) are reversed from the normal shield. The wire running underneath connects to the chip select line (Ardunio 10) &#8211; I went underneath for this to allow my to cut the line later if I needed another pin for chip select. <em><strong>Small rant &#8211; all SPI shields seem to assume they can use CS on pin10 &#8211; why cannot this come out to a solder jumper or pads so that I can select any pin as chip select. Using multiple SPI devices is a real pain because of this.</strong></em><br />
By request the circuit diagram for this is also shown. Note that in the board pics I placed the 4011 upside down (I could then glue it to the board). Also all unused inputs of the 4011 (I only use one gate out of 4) are grounded (because this is good practice with CMOS devices), even here I made one of my many mistakes &#8211; the diagram is wrong in fact pins 5&#038;6 are grounded not 4&#038;5.<br />
Any inverter would have done, I just happened to have a 4011 in my &#8216;bits&#8217; box.</p>
<p><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4730191322/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1011/4730191322_ef301891d4.jpg" alt="IMAG0047" width="299" height="500" /></a> <a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4730191844/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1170/4730191844_aa4c02226c.jpg" alt="IMAG0048" width="299" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4735891601/" class="tt-flickr tt-flickr-Medium" target="_blank"><img class="alignnone" src="http://farm5.static.flickr.com/4097/4735891601_66f0a90d65.jpg" alt="IMAG0057.jpg" width="500" height="299" /></a> </p>
<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</p>
<p>The NueElectronics shield uses a 74HCT08 chip to boost the MISO and INT signals to 5V levels, this chip is not tri-state and so the MISO line is always driven.</p>
<p>Replacing the 74HCT08D with a 74AHC125D is an almost direct replacement &#8211; cut the 74HCT08D off and tidy up the pads,</p>
<p><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4730188286/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1110/4730188286_29b69b02ed.jpg" alt="IMAG0043" width="500" height="299" /></a><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4729542953/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1322/4729542953_8d2ac52266.jpg" alt="IMAG0044" width="299" height="500" /></a></p>
<p>the connection between pins 1&amp;2 and pins 4&amp;5 needs to be broken and then the 74AHC125D soldered in the same place. Then add two small jumper wires: pin1 connected to GND (for the INT line), p4 connected to SS (Arduino digital 10) for the MISO line (Arduino digital 12).</p>
<p><a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4730189686/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1086/4730189686_06fdd7f962.jpg" alt="IMAG0045" width="299" height="500" /></a> <a class="tt-flickr tt-flickr-Medium" href="http://www.flickr.com/photos/22788868@N02/4729544473/" target="_blank"><img class="alignnone" src="http://farm2.static.flickr.com/1062/4729544473_655f7a7a93.jpg" alt="IMAG0046" width="299" height="500" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/662/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>I2C LCD and keypad controller using ATTiny2313</title>
		<link>http://john.crouchley.com/blog/archives/612</link>
		<comments>http://john.crouchley.com/blog/archives/612#comments</comments>
		<pubDate>Sun, 18 Apr 2010 15:57:30 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Arduino]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=612</guid>
		<description><![CDATA[<p>A while back @andrewoke was bemoaning the availability of an open source HD4470 I2C LCD and keypad controller. So I wrote one &#8211; the code fits into an Attiny2313 (just). ATTiny2313 chips are available for under $2.
The AVRDude command line I use to program the ATTiny2313 with Adafruit&#8217;s USBTiny programmer is: (note the fuse change [...]]]></description>
			<content:encoded><![CDATA[<p>A while back @andrewoke was bemoaning the availability of an open source HD4470 I2C LCD and keypad controller. So I wrote one &#8211; the code fits into an Attiny2313 (just). ATTiny2313 chips are available for under $2.<br />
The AVRDude command line I use to program the ATTiny2313 with Adafruit&#8217;s USBTiny programmer is: (note the fuse change &#8211; this is to run the 2313 at 8MHz)<br />
<code>avrdude -p attiny2313 -c USBTiny -u -U lfuse:w:0xE4:m  -U flash:w:I2C_LCD.hex -U eeprom:w:I2C_LCD.eep</code></p>
<p>Downloads:</p>
<ul>
<li> <a href="http://john.crouchley.com/files/HD4470LCD.zip">Source and hex files</a></li>
<li> <a href="http://john.crouchley.com/files/ATTiny2313%20LCD%20and%20Keypad%20controller.pdf">Documentation</a></li>
<li> Arduino library &#8211; not ready yet.</li>
</ul>
<p>Wire up like this:</p>
<p><a rel="attachment wp-att-614" href="http://john.crouchley.com/blog/archives/612/attiny-i2c-lcd-v2_bb"><img class="aligncenter size-full wp-image-614" title="Schematic" src="http://john.crouchley.com/blog/wp-content/uploads/2010/02/ATTiny-I2C-LCD-v2_bb.jpg" alt="Connections for LCD controller" width="650" height="717" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/612/feed</wfw:commentRss>
		<slash:comments>0</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 joined the team [...]]]></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>3</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>3</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 a [...]]]></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>Calke Abbey</title>
		<link>http://john.crouchley.com/blog/archives/535</link>
		<comments>http://john.crouchley.com/blog/archives/535#comments</comments>
		<pubDate>Mon, 22 Feb 2010 10:30:19 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[Photo a day]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=535</guid>
		<description><![CDATA[<p>A week ago we went for a walk round Calke Abbey grounds. Calke Abbey is National Trust and about 10 miles south of Derby.
As is usual I took a few (well a lot) of photos.</p>
<p>





 </p>
<p>I can see a face in this gnarled old Oak trunk.





 </p>
]]></description>
			<content:encoded><![CDATA[<p>A week ago we went for a walk round <a href="http://www.nationaltrust.org.uk/main/w-calkeabbey">Calke Abbey</a> grounds. Calke Abbey is National Trust and about 10 miles south of Derby.<br />
As is usual I took a few (well a lot) of photos.</p>
<p><a href="http://www.flickr.com/photos/22788868@N02/4376846938/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4046/4376846938_fd0fe46d3a.jpg" alt="Calke Abbey" width="378" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376104687/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4063/4376104687_2143a0d95b.jpg" alt="Calke Abbey" width="378" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376106317/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4023/4376106317_881fe85da9.jpg" alt="Calke Abbey" width="500" height="378" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376112383/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4065/4376112383_aa40b40302.jpg" alt="Calke Abbey" width="378" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376862358/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm3.static.flickr.com/2738/4376862358_66d71f7461.jpg" alt="Calke Abbey" width="500" height="378" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376119035/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4007/4376119035_f97a1ff764.jpg" alt="Calke Abbey" width="500" height="378" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376136063/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4048/4376136063_3b8aa84c3c.jpg" alt="Calke Abbey" width="500" height="378" /></a> </p>
<p>I can see a face in this gnarled old Oak trunk.<br />
<a href="http://www.flickr.com/photos/22788868@N02/4376148681/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm3.static.flickr.com/2791/4376148681_7d6a756840.jpg" alt="Face in gnarled tree Calke Abbey" width="500" height="391" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376905136/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4047/4376905136_251f28ff06.jpg" alt="Calke Abbey" width="378" height="500" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376913570/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4056/4376913570_d11f857f7e.jpg" alt="Calke Abbey" width="500" height="378" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376919316/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm3.static.flickr.com/2687/4376919316_8df66a6828.jpg" alt="Calke Abbey reflections" width="500" height="378" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376177625/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm3.static.flickr.com/2747/4376177625_398d3dbf32.jpg" alt="Deer at Calke Abbey" width="500" height="436" /></a><br />
<a href="http://www.flickr.com/photos/22788868@N02/4376182455/" class="tt-flickr tt-flickr-Medium" target="_blank"><img src="http://farm5.static.flickr.com/4061/4376182455_d1ab1e682c.jpg" alt="Deer at Calke Abbey" width="371" height="500" /></a> </p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/535/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cannot post reliably &#8211; keep getting errors</title>
		<link>http://john.crouchley.com/blog/archives/518</link>
		<comments>http://john.crouchley.com/blog/archives/518#comments</comments>
		<pubDate>Sun, 21 Feb 2010 09:39:47 +0000</pubDate>
		<dc:creator>john</dc:creator>
				<category><![CDATA[comment]]></category>

		<guid isPermaLink="false">http://john.crouchley.com/blog/?p=518</guid>
		<description><![CDATA[<p>I am having great difficulty in posting anything that is not straight text &#8211; I suspect a WordPress bug (recently upgraded to 2.9) but I cannot narrow it down. It appears to be when I have links to external sites. Wonder if WordPress introduced a new security feature?
Got it &#8211; any post created with the [...]]]></description>
			<content:encoded><![CDATA[<p>I am having great difficulty in posting anything that is not straight text &#8211; I suspect a WordPress bug (recently upgraded to 2.9) but I cannot narrow it down. It appears to be when I have links to external sites. Wonder if WordPress introduced a new security feature?<br />
Got it &#8211; any post created with the twitter upload plugin active and WP 2.9 or greater gets garbled. Disable and delete the plugin, then create new posts &#8211; all is good.<br />
Set up with different plugins and theme.</p>
]]></content:encoded>
			<wfw:commentRss>http://john.crouchley.com/blog/archives/518/feed</wfw:commentRss>
		<slash:comments>0</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 look at the [...]]]></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>
	</channel>
</rss>
