<?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>..the cat came back.. &#187; arduino</title>
	<atom:link href="http://blog.automated.it/category/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.automated.it</link>
	<description>i does tech i does.</description>
	<lastBuildDate>Wed, 25 Nov 2009 08:30:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Gratifying Graphic Gizmos</title>
		<link>http://blog.automated.it/2009/03/01/gratifying-graphic-gizmos/</link>
		<comments>http://blog.automated.it/2009/03/01/gratifying-graphic-gizmos/#comments</comments>
		<pubDate>Sun, 01 Mar 2009 08:47:37 +0000</pubDate>
		<dc:creator>ScaredyCat / Andy Powell</dc:creator>
				<category><![CDATA[1-Wire]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[software]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[environment]]></category>
		<category><![CDATA[monitoring]]></category>
		<category><![CDATA[Pachube]]></category>

		<guid isPermaLink="false">http://blog.automated.it/?p=207</guid>
		<description><![CDATA[Yesterday the Current Cost unit actually got installed for real, something I was dreading. Dreading not because it was a difficult thing to do but simply because I expected the figure it would show would be terrible. Guess what, it wasn&#8217;t. In fact it seemed to be fairly close to that of other people who [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday the <a href=http://www.currentcost.com/ target=_new>Current Cost</a> unit actually got installed for real, something I was dreading. Dreading not because it was a difficult thing to do but simply because I expected the figure it would show would be terrible. Guess what, it wasn&#8217;t. In fact it seemed to be fairly close to that of other people who are monitoring theirs. The initial figure of 371 Watts didn&#8217;t last too long once the dishwasher and oven came on and an interesting spike appeared when the hob went on for the kettle. </p>
<p><img class="left" title="Current Cost Graph" src="/images/gallery/environment/small_69.png" alt="" width="387" height="166" /><br />
<br/><br />
Continuing with my sudden graphing fetish, as well as using a Current Cost unit I have dotted a number of little devices I&#8217;ve built with <a href='http://www.digi.com/products/wireless/zigbee-mesh/' target=_new>Xbee</a> and <a href='http://arduino.cc' target=_new>Arduinos</a> to measure temperatures (and other things)  around the house. More information on those will come out later, but it&#8217;s an interesting project too. </p>
<p>Since I have the data for those it&#8217;d be rude not to graph them too, there&#8217;s a sample in the thumbnails below.</p>
<p>Not content with graphing them locally I picked up a <a href=http://www.pachube.com target=_new>Pachube</a> invite and started graphing data there too. The process is simple really and as you can see on the right hand side of this page under &#8216;Graphy Stuff&#8217;, graph images can be embedded in your own or other sites. The really interesting thing about Pachube is that you can <a href=http://www.pachube.com/feeds/1498 target=_new>share</a> your data with people who may be interested. The data they get to see is delayed by approximately 15 minutes. If you output your data in the <a href=http://community.pachube.com/?q=node/127>eeml</a> format then you can specify your own tags too.</p>
<p><a title="Electricity Usage Graph" rel="thumbnail" href="http://blog.automated.it/images/gallery/environment/graph_69_1.png"><img src="http://blog.automated.it/images/gallery/environment/thumb_graph_69_1.png" alt="Electricity Usage Graph" width="176" height="64" /></a><a title="Temperature in the garage" rel="thumbnail" href="http://blog.automated.it/images/gallery/environment/graph_70_1.png"><img src="http://blog.automated.it/images/gallery/environment/thumb_graph_70_1.png" alt="Temperature in the garage" width="176" height="64" /></a><br />
<br/></p>

<br><a href=http://blog.automated.it/2009/03/01/gratifying-graphic-gizmos/><p><img style='float:right;margin-left:15px;margin-bottom:10px;' src='http://blog.automated.it/images/tccb.png' border='0'></a></p><br>

<br><span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F&amp;title=Gratifying+Graphic+Gizmos" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
<a href="http://twitter.com/home?status=Currently reading http%3A%2F%2Fblog.automated.it%2F2009%2F03%2F01%2Fgratifying-graphic-gizmos%2F" title="Click to send this page to Twitter!" target="_blank"><img src="http://www.twitter.com/favicon.ico" width="16" height="16" alt="[Twitter]" /></a>
</span><br><br>]]></content:encoded>
			<wfw:commentRss>http://blog.automated.it/2009/03/01/gratifying-graphic-gizmos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>One Wireduino made easy</title>
		<link>http://blog.automated.it/2009/02/04/one-wireduino-made-easy/</link>
		<comments>http://blog.automated.it/2009/02/04/one-wireduino-made-easy/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 21:46:25 +0000</pubDate>
		<dc:creator>ScaredyCat / Andy Powell</dc:creator>
				<category><![CDATA[1-Wire]]></category>
		<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://blog.automated.it/?p=204</guid>
		<description><![CDATA[For a very long time now I&#8217;ve been playing with the Arduino boards but it wasn&#8217;t until I recently discovered some DS1820 1-wire chips in my parts box that I started even thinking about 1-wire stuff. Connecting 1-wire devices to the Arduino is, well, amazingly simple. Using the sample circuit from the datasheet we can [...]]]></description>
			<content:encoded><![CDATA[<p>For a very long time now I&#8217;ve been <a href="http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/" target="_new">playing</a> with the <a title="Arduino" href="http://www.arduino.cc/" target="_blank">Arduino</a> boards but it wasn&#8217;t until I recently discovered some <a title="DS1820 (replacements)" href="http://www.maxim-ic.com/quick_view2.cfm/qv_pk/3021" target="_blank">DS1820</a> 1-wire chips in my parts box that I started even thinking about 1-wire stuff. Connecting 1-wire devices to the Arduino is, well, amazingly simple. Using the sample circuit from the datasheet we can see the connections are few and far between.</p>
<p style="text-align: center;"><img class="aligncenter" title="DS1820 Circuit" src="/images/gallery/1wire/ds1820-circuit.png" alt="" width="415" height="135" /></p>
<p>Please note that this is the corrected circuit, previously the VDD was not tied to ground. While the circuit would work it would only give reliable results on very short runs. This circuit allows longer runs to the sensor.</p>
<p>Coding this up is also made extremely easy with the OneWire library. I&#8217;ve put together a little application below that will read all of the 1-wire devices on a bus. If you press L in the Arduino IDE serial monitor it will list all the 1-Wire device id&#8217;s and if you press T you&#8217;ll get the id and temperature reading.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
</pre></td><td class="code"><pre class="c" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">/*
Simple 1-wire device reading
&nbsp;
Pass T over serial to get temperatures
Pass L to list 1-wire devices
&nbsp;
*/</span>
<span style="color: #339933;">#include &lt;OneWire.h&gt;</span>
<span style="color: #339933;">#include &lt;stdio.h&gt;</span>
&nbsp;
<span style="color: #339933;">#define CONVERT     0x44</span>
<span style="color: #339933;">#define READSCRATCH 0xBE</span>
<span style="color: #339933;">#define SKIP_ROM    0xCC</span>
<span style="color: #339933;">#define MATCH_ROM   0x55</span>
&nbsp;
OneWire  ds<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// The DS18S20 is connected on pin 10</span>
<span style="color: #993333;">int</span> ledPin <span style="color: #339933;">=</span> <span style="color: #0000dd;">13</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// flash an led on 13 - we all like flashing lights</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #666666; font-style: italic;">// initialize inputs/outputs</span>
  <span style="color: #666666; font-style: italic;">// start serial port</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>ledPin<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">//we'll use the led to output a heartbeat</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> incomingByte <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// read the incoming byte:</span>
		incomingByte <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// say what you got:</span>
		<span style="color: #666666; font-style: italic;">//Serial.print(&quot;I received: &quot;);</span>
		<span style="color: #666666; font-style: italic;">//Serial.println(incomingByte, DEC);</span>
                <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>incomingByte <span style="color: #339933;">==</span> <span style="color: #0000dd;">84</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  getStuff<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>^&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>incomingByte <span style="color: #339933;">==</span> <span style="color: #0000dd;">76</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                   listDevices<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> listDevices<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
  byte addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
  ds.<span style="color: #202020;">reset_search</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>ds.<span style="color: #202020;">search</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
     digitalWrite<span style="color: #009900;">&#40;</span>ledPin<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// sets the LED on</span>
&nbsp;
     <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> OneWire<span style="color: #339933;">::</span><span style="color: #202020;">crc8</span><span style="color: #009900;">&#40;</span> addr<span style="color: #339933;">,</span> <span style="color: #0000dd;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>   <span style="color: #009900;">&#123;</span>
         <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #208080;">0x10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">// Make sure it is a DS18S20 device</span>
            <span style="color: #993333;">char</span> buffer<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">512</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
            sprintf<span style="color: #009900;">&#40;</span>buffer<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;Id:%02x%02x%02x%02x%02x%02x%02x%02x<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
                       addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                       addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
              Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>buffer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
          <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>
&nbsp;
    Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">'^'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> getStuff<span style="color: #009900;">&#40;</span><span style="color: #993333;">void</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  byte i<span style="color: #339933;">;</span>
  byte present <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
  byte data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">12</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  byte addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">char</span> buff<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">15</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
  <span style="color: #993333;">float</span> real_temp<span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #993333;">float</span> temp_count<span style="color: #339933;">;</span>
  <span style="color: #993333;">float</span> read_temp<span style="color: #339933;">;</span> 
&nbsp;
  ds.<span style="color: #202020;">reset_search</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span>ds.<span style="color: #202020;">search</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span>
&nbsp;
     digitalWrite<span style="color: #009900;">&#40;</span>ledPin<span style="color: #339933;">,</span> HIGH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// sets the LED on</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> OneWire<span style="color: #339933;">::</span><span style="color: #202020;">crc8</span><span style="color: #009900;">&#40;</span> addr<span style="color: #339933;">,</span> <span style="color: #0000dd;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">!=</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>  <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// Check CRC is valid</span>
        Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CRC is not valid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #208080;">0x10</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>   <span style="color: #666666; font-style: italic;">// Make sure it is a DS18x20 device</span>
      Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Device is not a DS18x20 family device.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    ds.<span style="color: #202020;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Reset device</span>
    ds.<span style="color: #202020;">select</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// Select device</span>
    ds.<span style="color: #202020;">write</span><span style="color: #009900;">&#40;</span>CONVERT<span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Issue Convert command </span>
&nbsp;
    delay<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>     <span style="color: #666666; font-style: italic;">// maybe 750ms is enough, maybe not</span>
    digitalWrite<span style="color: #009900;">&#40;</span>ledPin<span style="color: #339933;">,</span> LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// sets the LED off</span>
&nbsp;
    present <span style="color: #339933;">=</span> ds.<span style="color: #202020;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Reset device</span>
    ds.<span style="color: #202020;">select</span><span style="color: #009900;">&#40;</span>addr<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Select device</span>
    ds.<span style="color: #202020;">write</span><span style="color: #009900;">&#40;</span>READSCRATCH<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Read Scratchpad</span>
&nbsp;
    <span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span> i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> <span style="color: #0000dd;">9</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">// we need 9 bytes</span>
          data<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> ds.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>OneWire<span style="color: #339933;">::</span><span style="color: #202020;">crc8</span><span style="color: #009900;">&#40;</span> data<span style="color: #339933;">,</span> <span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">8</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>  <span style="color: #666666; font-style: italic;">// Check CRC is valid</span>
&nbsp;
      <span style="color: #666666; font-style: italic;">// CRC is ok</span>
      <span style="color: #666666; font-style: italic;">// Divide the temperature by 2 - note the » and</span>
      <span style="color: #666666; font-style: italic;">// « need to be replaced with double &lt; and &gt;</span>
      <span style="color: #666666; font-style: italic;">// wordpress kills the server when you try to </span>
      <span style="color: #666666; font-style: italic;">// save otherwise.</span>
      read_temp<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span>«<span style="color: #0000dd;">8</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">|</span> data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> » <span style="color: #0000dd;">1</span> <span style="color: #339933;">;</span>
     <span style="color: #666666; font-style: italic;">// Convert to real temperature</span>
      temp_count<span style="color: #339933;">=</span><span style="color: #993333;">float</span><span style="color: #009900;">&#40;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">-</span> data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">float</span><span style="color: #009900;">&#41;</span>data<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      real_temp <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">float</span><span style="color: #009900;">&#41;</span>read_temp<span style="color: #339933;">-</span><span style="color:#800080;">0.25</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>temp_count<span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Convert float to ascii</span>
      tempToAscii<span style="color: #009900;">&#40;</span>real_temp<span style="color: #339933;">,</span>buff<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #993333;">char</span> buffer<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">512</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
      sprintf<span style="color: #009900;">&#40;</span>buffer<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;%02x%02x%02x%02x%02x%02x%02x%02x %s<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span>
                  addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">4</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
                  addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">5</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> addr<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">7</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> buff<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
      Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>buffer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span>    <span style="color: #009900;">&#123;</span>
       Serial.<span style="color: #202020;">println</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;CRC Failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
  <span style="color: #009900;">&#125;</span>    
&nbsp;
<span style="color: #993333;">void</span> tempToAscii<span style="color: #009900;">&#40;</span><span style="color: #993333;">double</span> temp<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">*</span>buff<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> frac<span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">//get three numbers to the right of the decimal point</span>
  frac<span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">unsigned</span> <span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#40;</span>temp<span style="color: #339933;">*</span><span style="color: #0000dd;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">1000</span><span style="color: #339933;">;</span>
  itoa<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span>temp<span style="color: #339933;">,</span>buff<span style="color: #339933;">,</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
  strcat<span style="color: #009900;">&#40;</span>buff<span style="color: #339933;">,</span><span style="color: #ff0000;">&quot;.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #666666; font-style: italic;">//put the frac after the decimal</span>
  itoa<span style="color: #009900;">&#40;</span>frac<span style="color: #339933;">,&amp;</span>amp<span style="color: #339933;">;</span>buff<span style="color: #009900;">&#91;</span>strlen<span style="color: #009900;">&#40;</span>buff<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span><span style="color: #0000dd;">10</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>There&#8217;s also a copy of the .pde file that you can <a title="download file" href="http://blog.automated.it/files/ds18s20.pde" target="_blank">download</a> if you feel more inclined. It&#8217;s not an exact copy, I removed the commented out xml for the above version. It&#8217;s worth pointing out that this circuit is using what is called parasitic power, which means your cable run should be shortish. If you want to use an external power supply then pin 3 (VDD) on the DS18S20 should go to your external supply. This would allow for much longer runs of cable. Below is an example graph generated by <a title="Cacti" href="http://www.cacti.net/" target="_blank">cacti</a> with 2 DS1820&#8217;s connected the the arduino. As you can see the temperatures aren&#8217;t exactly the same but this is to be expected since the accuracy of the DS1820 is +/- 0.5 ° C</p>
<p style="text-align: center;"><img class="aligncenter" style="margin-left: 30px; margin-right: 30px;" title="Example Graph" src="/images/gallery/1wire/example_graph.png" alt="" width="367" height="304" /></p>
<p>The breaks in the graph were caused my me removing the USB plug from the PC it was connected to so that I could make some minor alterations to the circuit.</p>
<p><a href=http://blog.automated.it/2009/02/04/one-wireduino-made-easy/#comments>Josh</a> asked how I was getting the input for Cacti, here&#8217;s the perl script I use</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="perl" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/perl</span>
&nbsp;
<span style="color: #0000ff;">$output</span> <span style="color: #339933;">=</span> <span style="color: #ff0000;">`echo -en &quot;T&quot; &gt;&gt;/dev/ttyUSB0 &amp;&amp; cat /dev/ttyUSB0`</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #0000ff;">@lines</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\r\n/</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$output</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #0000ff;">$t</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span> <span style="color: #0000ff;">$line</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">@lines</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
       <span style="color: #0000ff;">@spl</span> <span style="color: #339933;">=</span> <span style="color: #000066;">split</span><span style="color: #009900;">&#40;</span><span style="color: #009966; font-style: italic;">/\s+/</span><span style="color: #339933;">,</span><span style="color: #0000ff;">$line</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #0000ff;">$lc</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">@spl</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">$lc</span> gt <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>	
                <span style="color: #0000ff;">$node</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$spl</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #0000ff;">$val</span><span style="color: #339933;">=</span><span style="color: #0000ff;">$spl</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066;">print</span> <span style="color: #ff0000;">&quot;Temperature_$node:$val &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #0000ff;">$t</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>This outputs <em>Temperature_x:n</em> where x is the 1-Wire id and n is the temperature. It could probably do with tidying up and if you wanted to you could pass the 1-Wire id to the script to and only output the temperature for that particular 1-Wire device. A copy of the exported Cacti template can be <a href="/files/cacti_arduino.xml" target=_new>downloaded</a>, I&#8217;m hoping that you just need to import that into your Cacti after placing the script in the scripts directory. Just remember, under linux, if you unplug and replug in your Arduino you may need to set the tty port speed to 9600 (or whatever you put in your Serial.begin(); ). You can use the following command for that;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="bash" style="font-family:monospace;">&nbsp;
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">stty</span> <span style="color: #660033;">-F</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>ttyUSB0 cs8 <span style="color: #000000;">9600</span> ignbrk <span style="color: #660033;">-brkint</span> <span style="color: #660033;">-icrnl</span> <span style="color: #660033;">-imaxbel</span> <span style="color: #660033;">-opost</span> <span style="color: #660033;">-onlcr</span> <span style="color: #660033;">-isig</span> <span style="color: #660033;">-icanon</span> <span style="color: #660033;">-iexten</span> <span style="color: #660033;">-echo</span> <span style="color: #660033;">-echoe</span> <span style="color: #660033;">-echok</span> <span style="color: #660033;">-echoctl</span> <span style="color: #660033;">-echoke</span> noflsh <span style="color: #660033;">-ixon</span> <span style="color: #660033;">-crtscts</span></pre></td></tr></table></div>

<p>Make sure that ttyUSB0 is what your Arduino is connected to first. If not you will need to change it in the perl script and on the line above. </p>

<br><a href=http://blog.automated.it/2009/02/04/one-wireduino-made-easy/><p><img style='float:right;margin-left:15px;margin-bottom:10px;' src='http://blog.automated.it/images/tccb.png' border='0'></a></p><br>

<br><span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F&amp;title=One+Wireduino+made+easy" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
<a href="http://twitter.com/home?status=Currently reading http%3A%2F%2Fblog.automated.it%2F2009%2F02%2F04%2Fone-wireduino-made-easy%2F" title="Click to send this page to Twitter!" target="_blank"><img src="http://www.twitter.com/favicon.ico" width="16" height="16" alt="[Twitter]" /></a>
</span><br><br>]]></content:encoded>
			<wfw:commentRss>http://blog.automated.it/2009/02/04/one-wireduino-made-easy/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>USB Controlled RGB Blob</title>
		<link>http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/</link>
		<comments>http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/#comments</comments>
		<pubDate>Mon, 18 Feb 2008 15:46:42 +0000</pubDate>
		<dc:creator>ScaredyCat / Andy Powell</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[hardware]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[opensource]]></category>
		<category><![CDATA[software]]></category>

		<guid isPermaLink="false">http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/</guid>
		<description><![CDATA[I recently came across a little project which would turn on an LED box when there was mail your gmail account. I thought it was quite interesting and, since I&#8217;d had an Arduino Diecimila in my laptop bag for about 6 months and not touched it, I decided to replicate it. The idea was simply [...]]]></description>
			<content:encoded><![CDATA[<p>I recently came across a <a title="gmail notifier" href="http://www.j4mie.org/2008/02/15/how-to-make-a-physical-gmail-notifier/" target="_blank">little project</a> which would turn on an LED box when there was mail your gmail account. I thought it was quite interesting and, since I&#8217;d had an <a title="arduino" href="http://www.arduino.cc/" target="_blank">Arduino </a><a title="diecimila" href="http://www.arduino.cc/en/Main/ArduinoBoardDiecimila" target="_blank">Diecimila</a> in my laptop bag for about 6 months and not touched it, I decided to replicate it. The idea was simply to get used to how the Arduino board worked, the project in itself isn&#8217;t exactly going to push anyone to their limit. I was right, the code was basically in the examples there was nothing to do. Since we&#8217;re selling our house lots of my electronics development stuff has ended up in the loft. I went for a rummage and found some little RGB light globes that a local garden centre had been trying to sell off cheaply at a couple of Euros each. Undoing the screws on the base of the globe revealed a very simple <img class="right" src="http://blog.automated.it/images/arduino-board.jpg" alt="Arduino board" width="217" height="151" align="middle" /></p>
<p>design, I&#8217;d just need to tap into the LEDs and disconnect the chip they used. Before any of this was going to happen I needed to build some sort of prototype to at least be sure that the concept was going to work. Since I didn&#8217;t have any RGB LEDs or even one of each red, green and blue I had to settle for a small LED board that had come from an old piece of equipment that I&#8217;d bought, literally, just for the parts. There was a slight problem. The led board was red, green and errm&#8230; orange. It didn&#8217;t really matter at this stage, I was only proving the code and making sure that I could get the whole idea to work before destroying the perfectly useless light globes.</p>
<p>The software side was also fairly straight forward too. In the end I used the <a title="serial messages" href="http://www.arduino.cc/playground/Code/SimpleMessageSystem" target="_blank">SimpleMessageSystem</a> library to handle the serial data since I kept running into issues with the standard serial I/O routines. The SimpleMessageSystem routines basically use white space as variable separators and a &lt;CR&gt; to signify the end of input.</p>
<p align="center">
<div id="video1" class="flashvideo">
<a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</div>
<script type="text/javascript">
var s1 = new SWFObject("http://blog.automated.it/wp-content/plugins/flash-video-player/mediaplayer.swf","n1","320","260","7");
s1.addParam("allowfullscreen","true");
s1.addParam("allowscriptaccess","always");
s1.addVariable("javascriptid","n1");
s1.addVariable("height","260");
s1.addVariable("width","320");
s1.addVariable("image","http://blog.automated.it//images/gallery/arduino/orbandarduino.jpg");
s1.addVariable("searchbar","false");
s1.addVariable("screencolor","0x000000");
s1.addVariable("overstretch","true");
s1.addVariable("showeq","false");
s1.addVariable("showicons","true");
s1.addVariable("shownavigation","true");
s1.addVariable("showstop","false");
s1.addVariable("showndigits","true");
s1.addVariable("showdownload","false");
s1.addVariable("usefullscreen","true");
s1.addVariable("autoscroll","false");
s1.addVariable("displayheight","240");
s1.addVariable("thumbsinplaylist","true");
s1.addVariable("autostart","false");
s1.addVariable("bufferlength","3");
s1.addVariable("repeat","false");
s1.addVariable("rotatetime","5");
s1.addVariable("shuffle","false");
s1.addVariable("smoothing","true");
s1.addVariable("volume","80");
s1.addVariable("enablejs","true");
s1.addVariable("linkfromdisplay","false");
s1.addVariable("linktarget","_self");
s1.addVariable("searchlink","http://search.longtail.tv/?q=");
s1.addVariable("file","http://blog.automated.it//video/arduino-globe.flv");
s1.write("video1");
</script>
</p>
<p>Each of the colour channels can have a value between 0 (zero) and 255 which gives a lot of variation. There&#8217;s also the option to pulse the mixed colours.</p>
<p>Initially I was just going to have the 3 LEDs change to their relative brightness but then I hit on the idea of having them fade up and down to the correct value. I have to say it looks much better with the gradual change, although I might just add the option of selecting either gradual or instant to the parameter list.</p>
<p>Now, with a simple command, I can set the RGB value of my light globe.</p>
<p>./rgb-globe -l -b 9600 -p/dev/ttyUSB0 -s &#8220;1 255 50 0&#8243;</p>
<p>The original code for the command line application came from <a title="todbot" href="http://todbot.com/blog/" target="_blank">Tod Kurt</a> and was written to be able to send serial data to the Arduino. I did make some modifications, including a couple of virtual slappings of Tod for using strcpy &#8211; I still don&#8217;t understand why people don&#8217;t pretend that function just does not exist.</p>
<p>I&#8217;m considering writing a small GTK application  that just has a colour picker to select colours, but that would be in addition to the command line application since this is designed to be used from things like scripts or mail and IM notifications or, as I suspect mine will, build status information for my <a href="http://wiki.openmoko.org/wiki/Main_Page" target='blank'>Openmoko</a> buildhost. The only real issue at the moment is that it&#8217;s really not bright enough, I think I need to rethink the orb &#8211; maybe it&#8217;ll be better at night&#8230;</p>
<p><a title="The globe/orb (anyone seen Mork?)" rel="thumbnail" href="http://blog.automated.it/images/gallery/arduino/orb.jpg"><img src="http://blog.automated.it/images/gallery/arduino/thumb_orb.jpg" alt="The globe/orb" width="64" height="48" /></a><a title="The globe/orb and Arduino board" rel="thumbnail" href="http://blog.automated.it/images/gallery/arduino/orbandarduino.jpg"><img src="http://blog.automated.it/images/gallery/arduino/thumb_orbandarduino.jpg" alt="The globe/orb connected to the Arduino board" width="64" height="48" /></a></p>

<br><a href=http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/><p><img style='float:right;margin-left:15px;margin-bottom:10px;' src='http://blog.automated.it/images/tccb.png' border='0'></a></p><br>

<br><span class="slashdigglicious">
<a href="http://slashdot.org/bookmark.pl?url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Slashdot It!"><img src="http://slashdot.org/favicon.ico" height="16" width="16" alt="[Slashdot]" /></a>
<a href="http://digg.com/submit?phase=2&amp;url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Digg This Story"><img src="http://digg.com/favicon.ico" width="16" height="16" alt="[Digg]" /></a>
<a href="http://reddit.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Reddit"><img src="http://reddit.com/favicon.ico" width="16" height="16" alt="[Reddit]" /></a>
<a href="http://del.icio.us/post?url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Save to del.icio.us" onclick="window.open('http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob', 'delicious', 'toolbar=no,width=700,height=400'); return false;"><img src="http://del.icio.us/favicon.ico" width="16" height="16" alt="[del.icio.us]" /></a>
<a href="http://www.facebook.com/share.php?u=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F" title="Share on Facebook"><img src="http://www.facebook.com/favicon.ico" width="16" height="16" alt="[Facebook]" /></a>
<a href="http://technorati.com/faves?add=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F" title="Add to my Technorati Favorites"><img src="http://technorati.com/favicon.ico" width="16" height="16" alt="[Technorati]" /></a>
<a href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Save to Google Bookmarks"><img src="http://www.google.com/favicon.ico" width="16" height="16" alt="[Google]" /></a>
<a href="http://www.stumbleupon.com/submit?url=http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F&amp;title=USB+Controlled+RGB+Blob" title="Stumble it!"><img src="http://www.stumbleupon.com/favicon.ico" width="16" height="16" alt="[StumbleUpon]" /></a>
<a href="http://twitter.com/home?status=Currently reading http%3A%2F%2Fblog.automated.it%2F2008%2F02%2F18%2Fusb-controlled-rgb-blob%2F" title="Click to send this page to Twitter!" target="_blank"><img src="http://www.twitter.com/favicon.ico" width="16" height="16" alt="[Twitter]" /></a>
</span><br><br>]]></content:encoded>
			<wfw:commentRss>http://blog.automated.it/2008/02/18/usb-controlled-rgb-blob/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
