<?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 Daily Duino &#187; Optical</title>
	<atom:link href="http://dailyduino.com/archives/category/sensors/optical/feed" rel="self" type="application/rss+xml" />
	<link>http://dailyduino.com</link>
	<description>mostly daily arduino projects and news</description>
	<lastBuildDate>Fri, 04 Dec 2009 19:46:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>Getting Started with Pachube &amp; Arduino</title>
		<link>http://dailyduino.com/archives/616</link>
		<comments>http://dailyduino.com/archives/616#comments</comments>
		<pubDate>Thu, 25 Jun 2009 13:18:50 +0000</pubDate>
		<dc:creator>Morgellon</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Optical]]></category>
		<category><![CDATA[Pachube]]></category>
		<category><![CDATA[Phone]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Based]]></category>

		<guid isPermaLink="false">http://dailyduino.com/?p=616</guid>
		<description><![CDATA[Another post on Pachube and how easy it is to get setup and going. This post will cover the basic steps on how to get some sensors online!  I will be using my project of two light sensors as an example.  The status of my light sensors are viewable at http://www.pachube.com/feeds/2145 Pachube + Arduino from [...]]]></description>
			<content:encoded><![CDATA[<p>Another post on Pachube and how easy it is to get setup and going. This post will cover the basic steps on how to get some sensors online!  I will be using my project of two light sensors as an example.  The status of my light sensors are viewable at <a title="http://www.pachube.com/feeds/2145" href="http://www.pachube.com/feeds/2145" target="_blank">http://www.pachube.com/feeds/2145</a></p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://vimeo.com/moogaloop.swf?clip_id=5320339&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed type="application/x-shockwave-flash" width="400" height="300" src="http://vimeo.com/moogaloop.swf?clip_id=5320339&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<p><a href="http://vimeo.com/5320339">Pachube + Arduino</a> from <a href="http://vimeo.com/morgellon">Morgellon</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p><strong>STEP ONE: </strong><em>GET A PACHUBE ACCOUNT!</em></p>
<p>Head over to the <a title="http://www.pachube.com/" href="http://www.pachube.com/" target="_blank">Pachube</a> website and see various sensors from all over the world and view their status.  Be sure to view the <a title="http://community.pachube.com/about" href="http://community.pachube.com/about" target="_blank">ABOUT</a> page, this describes INPUTs and OUTPUTs, along with ways to interface with Pachube and your sensors.  The <a title="http://community.pachube.com/quickstart" href="http://community.pachube.com/quickstart" target="_blank">QUICKSTART</a> page has the details to get started and how to use your API.  Pachube is still in beta, so you&#8217;ll need to get an invite code&#8230; but no worries, Pachube has an email address on the QUICKSTART page.  Just send them and email asking for an invite and what you would like to do.  If they let me in&#8230; they will let anyone in! <img src='http://dailyduino.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><strong>STEP TWO: </strong><em>PREPARE ARDUINO! </em></p>
<p>The Arduino can be interfaced with Pachube <strong>two</strong> ways: 1. With an Ethernet shield <strong>OR</strong> 2. Via USB connected to a PC running Processing&#8230; which is the way used in this tutorial&#8230; as I feel it is an easy and inexpensive way.  You can learn more about each way at the <a title="http://community.pachube.com/arduino" href="http://community.pachube.com/arduino" target="_blank">Pachube Arduino</a> page.</p>
<p>To prep the Arduino, you need to connect the sensors you will be using and <em><strong>verify</strong></em> <strong>that they are working correctly!</strong> Once the sensors are good, then upload the &#8220;Standard Firmata&#8221; to the Arduino.  Now the Arduino is prepped for Pachube!  Leave the Arduino connected to the PC.</p>
<p><strong>STEP THREE: </strong><em>PREPARE PROCESSING!</em></p>
<p>To have Processing communicate easily with Pachube, you will need to add a few libraries.  They are the Pachuino, Arduino and EEML libraries, they are available and there is more info at the <a title="http://community.pachube.com/node/13" href="http://community.pachube.com/node/13" target="_blank">PACHUINO</a> page.  Download, unzip and move them to the <strong>libraries</strong> folder, in your <strong>sketchbook</strong> folder.  Now Processing is ready!</p>
<p><strong>STEP FOUR: </strong><em>PREPARE INPUT FEED!</em></p>
<p>Once you have a Pachube account and your API key, go ahead and set up a new feed for your sensors.  Since I have light sensors, I started a new <a title="http://www.pachube.com/feeds/new" href="http://www.pachube.com/feeds/new" target="_blank">INPUT FEED</a>.  I chose to make my feed &#8220;manual&#8221; (as this is easier for me) which means Pachube gets updates only when I send them.  Instead of Pachube connecting directly to my PC to pull the info.</p>
<p><strong>STEP FIVE: </strong><em>PREPARE CODE FOR PROCESSING!</em></p>
<p>Once you have the libraries in the folder, you are ready to start Processing and start coding.  Below is the code I used for my light sensor.  This was taken from the sample code and stripped to make it more simple. I added a LED on pin 11 to light up (to let me know when my Arduino was running) and a delay(1500).</p>
<p>Be sure to add you API Key, and the URL of your INPUT FEED!</p>
<p><em>import processing.serial.*;<br />
import cc.arduino.*;<br />
import eeml.*;<br />
import pachuino.*;</em></p>
<p><em>Pachuino p;<br />
Arduino arduino;<br />
int ledPin = 11;</em></p>
<p><em>void setup(){<br />
p = new Pachuino(this, Arduino.list()[0], 115200);<br />
p.manualUpdate(&#8220;http://www.pachube.com/api/2145.xml&#8221;); // change URL &#8212; this is the feed you want to update<br />
p.setKey(&#8220;&#8212;YOUR API KEY HERE&#8212;&#8221;);</em></p>
<p><em>// local sensors<br />
p.addLocalSensor(&#8220;analog&#8221;, 0,&#8221;Light Sensor Inside&#8221;);<br />
p.addLocalSensor(&#8220;analog&#8221;, 1,&#8221;Light Sensor Outside&#8221;);<br />
}</em></p>
<p><em>void draw(){<br />
//p.debug();<br />
p.digitalWrite(ledPin, Arduino.HIGH);<br />
delay(1500);<br />
}</em></p>
<p><em>// you don&#8217;t need to change any of these</em></p>
<p><em>void onReceiveEEML(DataIn d){<br />
p.updateRemoteSensors(d);<br />
}</em></p>
<p><strong>STEP SIX: </strong><em>LAUNCH CODE AND COLLECT DATA!</em></p>
<p>Make sure that:</p>
<ul>
<li>Sensors are <em>*working*</em> and connected to Arduino</li>
<li>Arduino is running &#8220;Standard Firmata&#8221; and connected to computer</li>
<li>Processing is collecting sensor data from Arduino</li>
<li>Computer has Internet connection</li>
</ul>
<p>Now run your program and begin collecting data and sharing it on the web!!  Check your feed to make sure you data is being transmitted.  Have fun and happy tinkering!</p>
<p>&#8211;Morgellon OUT!</p>
]]></content:encoded>
			<wfw:commentRss>http://dailyduino.com/archives/616/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Arduino + Pachube = Web Connected Sensors!</title>
		<link>http://dailyduino.com/archives/592</link>
		<comments>http://dailyduino.com/archives/592#comments</comments>
		<pubDate>Wed, 24 Jun 2009 12:37:13 +0000</pubDate>
		<dc:creator>Morgellon</dc:creator>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Code]]></category>
		<category><![CDATA[Communication]]></category>
		<category><![CDATA[Displays]]></category>
		<category><![CDATA[Optical]]></category>
		<category><![CDATA[Pachube]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Sensors]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Web Based]]></category>

		<guid isPermaLink="false">http://dailyduino.com/?p=592</guid>
		<description><![CDATA[Quick update before I zonk out&#8230;  Yesterday I setup an account for Pachube and spent all night getting familiar with how it works. Pachube describes itself as a service that enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to [...]]]></description>
			<content:encoded><![CDATA[<p>Quick update before I zonk out&#8230;  Yesterday I setup an account for <a title="http://www.pachube.com/" href="http://www.pachube.com/" target="_blank">Pachube</a> and spent all night getting familiar with how it works. Pachube describes itself as a service that enables you to connect, tag and share real time sensor data from objects, devices, buildings and environments around the world. The key aim is to facilitate interaction between remote environments, both physical and virtual.</p>
<p>It also works with Arduino and Processing&#8230; hrmmmmm&#8230;..</p>
<div>As a &#8220;test&#8221; project, I set up two light sensors in my room.  One is mounted on the wall, the other is taped to the window facing outside.  The idea is to compare inside light levels to outside light levels and adjust for energy consumption.  If the light level outside is equal or greater than inside, then perhaps I should open the blinds to let in more light&#8230; or maybe even go outside&#8230; <em><strong>*gasp</strong></em>*</div>
<div>The two light sensors are connected to an Arduino running the Standard Firmata.  The Arduino is connected to a PC running a Processing sketch that sends the sensor data to Pachube.  Nice and easy!  I&#8217;ll post more details, code and a basic tutorial later&#8230; after I&#8217;ve slept&#8230; that way it <em><strong>*might*</strong></em> make sense.</div>
<div>Until then, here are some pictures and graphs. (yay graphs!) The two graphs are generated by Pachube and are fairly easy to customize.  The higher the number, the less light is present.  So, hopefully the Inside Light Sensor will stay a nice high number as I sleep&#8230; while the Outside Light Sensor should lower over the course of the day.</div>
<div>
<a href='http://dailyduino.com/archives/592/2009-06-24-065401' title='2009-06-24-065401'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-065401-150x150.jpg" class="attachment-thumbnail" alt="Arduino Light Sensor Wiring" title="2009-06-24-065401" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-065230' title='2009-06-24-065230'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-065230-150x150.jpg" class="attachment-thumbnail" alt="Light Sensors in Room" title="2009-06-24-065230" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-065118' title='2009-06-24-065118'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-065118-150x150.jpg" class="attachment-thumbnail" alt="Inside Light Sensor" title="2009-06-24-065118" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-065254' title='2009-06-24-065254'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-065254-150x150.jpg" class="attachment-thumbnail" alt="Outside Light Sensor" title="2009-06-24-065254" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-070307' title='2009-06-24-070307'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-070307-150x150.jpg" class="attachment-thumbnail" alt="Outside Light Sensor" title="2009-06-24-070307" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-070403' title='2009-06-24-070403'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-070403-150x150.jpg" class="attachment-thumbnail" alt="Sunrise" title="2009-06-24-070403" /></a>
<a href='http://dailyduino.com/archives/592/2009-06-24-070102' title='2009-06-24-070102'><img width="150" height="150" src="http://dailyduino.com/wp-content/uploads/2009/06/2009-06-24-070102-150x150.jpg" class="attachment-thumbnail" alt="&quot;Screen Shot&quot;" title="2009-06-24-070102" /></a>
</div>
<p><img class="alignnone" title="INSIDE Light Sensor" src=" http://www.pachube.com/feeds/2145/datastreams/0/history.png?w=500&amp;h=200&amp;c=33cc66&amp;b=true&amp;g=true&amp;t=Inside%20Light%20Sensor&amp;l=Higher%20Numbers%20Equal%20Dark%20---%20Lower%20Numbers%20Equal%20Light&amp;s=2" alt="" width="500" height="200" /></p>
<p><img class="alignnone" title="Outside Light Sensor" src=" http://www.pachube.com/feeds/2145/datastreams/1/history.png?w=500&amp;h=200&amp;c=33cc66&amp;b=true&amp;g=true&amp;t=Outside%20Light%20Sensor&amp;l=Higher%20Numbers%20Equal%20Dark%20---%20Lower%20Numbers%20Equal%20Light&amp;s=2" alt="" width="500" height="200" /></p>
<p>The graphs will continue to update as they receive more data from the sensors.  It will be interesting to watch and compare the differences in the two graphs.  More to come soon!</p>
<p>&#8211;Morgellon OUT!!</p>
<p><code><br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://dailyduino.com/archives/592/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Slotted Optical Sensors</title>
		<link>http://dailyduino.com/archives/91</link>
		<comments>http://dailyduino.com/archives/91#comments</comments>
		<pubDate>Thu, 04 Sep 2008 04:39:50 +0000</pubDate>
		<dc:creator>droops</dc:creator>
				<category><![CDATA[Freeduino]]></category>
		<category><![CDATA[Optical]]></category>
		<category><![CDATA[breadboard]]></category>
		<category><![CDATA[infrared]]></category>
		<category><![CDATA[nkc]]></category>
		<category><![CDATA[proto]]></category>

		<guid isPermaLink="false">http://dailyduino.com/?p=91</guid>
		<description><![CDATA[After watching Citizen Engineer, I wanted to play with a slotted optical sensor, well that and a payphone, a sim card reader, a little vice and other cool electronics things. So I ordered a few from All Electronics. As usual, I had no idea how these things work, so I started plugging in wires and [...]]]></description>
			<content:encoded><![CDATA[<p>After watching <a href="http://www.citizenengineer.com/">Citizen Engineer</a>, I wanted to play with a slotted optical sensor, well that and a payphone, a sim card reader, a little vice and other cool electronics things.  So I ordered a few from <a href="http://www.allelectronics.com/make-a-store/item/OSU-57/SLOTTED-OPTO-SENSOR/1.html">All Electronics</a>.</p>
<p>As usual, I had no idea how these things work, so I started plugging in wires and using a standard analog input sketch.  That did not work at all, after I heard something pop I knew I was not on the right track. Then I started looking for some help. I still have not found a datasheet, but I found a graphic that made things work for me.  My exact model is the OPB3902.</p>
<p style="text-align: center;"><img class="aligncenter" src="http://csel.cs.colorado.edu/~bauerk/legorobots/images/assembly/img46.gif" alt="Optical Sensor Schematic" /></p>
<p>There are four pins on the bottom of these things, two to work the emitter (E) (pins 1 and 3) and two for the detector (D) (pins 2 and 4).  Two resistors are needed, a 330 Ohm (orange orange red) and 2.2 K (red red orange).</p>
<p>I mounted the Optical Sensor on a proto board, having carefully cut off the plastic bump on the bottom of the sensor.  I also used a led with a 1K (brown black red) for signaling when something was activating the switch.  According to the drawing 5 volts would work, so that&#8217;s what I used, along with analog pin 2 for input and digital pin 12 for the signaling led.</p>
<p>After running my sketch and dumping the sensor reading to serial I found that it idled at ~929 and when the sensor was activated it was ~1020.  This is great, no problem to see a change of state, so I wrote a bit more code to activate the led.  I did not include a delay as I wanted the led to react quickly.</p>
<p style="text-align: center;"><a href="http://dailyduino.com/wp-content/uploads/2008/09/opt2.png"><img class="alignnone size-thumbnail wp-image-97" title="opt2" src="http://dailyduino.com/wp-content/uploads/2008/09/opt2-150x150.png" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/opt1.png"><img class="alignnone size-thumbnail wp-image-96" title="opt1" src="http://dailyduino.com/wp-content/uploads/2008/09/opt1-150x150.png" alt="" width="150" height="150" /></a></p>
<p style="text-align: left;">Here is my code, feel free to do with it as you will!</p>
<pre style="text-align: left;">
/*
Demo for a slotted optical sensor.

I am sure that someone elses code is in here somewhere
*/

int inputPin = 2;    // select the input pin for the potentiometer
int ledPin = 12;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(inputPin, OUTPUT);  // declare the ledPin as an OUTPUT
  pinMode(ledPin, OUTPUT);
  Serial.begin(9600);
}

void loop() {

  val = analogRead(inputPin);    // read the value from the sensor
  Serial.println(val);

  if(val &gt; 950){
    digitalWrite(ledPin, HIGH);  // turn the ledPin on
  } else {
    digitalWrite(ledPin, LOW);   // turn the ledPin off
  }
}
</pre>
<p>I am very excited to know how to set up this sensor.  Next time I am going to find some with the hook up wires already soldered and heatshrinked on.  For those that are curious, that is a <a href="http://www.nkcelectronics.com/freeduino-arduino-diecimila-compatible-board-complete-kit.html">Freeduino from NKC</a> under there.</p>
<p style="text-align: center;"><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0344.jpg"><img class="alignnone size-thumbnail wp-image-101" title="dsc_0344" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0344-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0345.jpg"><img class="alignnone size-thumbnail wp-image-102" title="dsc_0345" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0345-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0346.jpg"><img class="alignnone size-thumbnail wp-image-103" title="dsc_0346" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0346-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0347.jpg"><img class="alignnone size-thumbnail wp-image-104" title="dsc_0347" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0347-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0348.jpg"><img class="alignnone size-thumbnail wp-image-105" title="dsc_0348" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0348-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0349.jpg"><img class="alignnone size-thumbnail wp-image-106" title="dsc_0349" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0349-150x150.jpg" alt="" width="150" height="150" /> </a><a href="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0350.jpg"><img class="alignnone size-thumbnail wp-image-107" title="dsc_0350" src="http://dailyduino.com/wp-content/uploads/2008/09/dsc_0350-150x150.jpg" alt="" width="150" height="150" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://dailyduino.com/archives/91/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

