<?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>Oliver Smith &#187; arduino</title>
	<atom:link href="http://chemicaloliver.net/category/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>http://chemicaloliver.net</link>
	<description>experimentation and geekiness</description>
	<lastBuildDate>Fri, 11 May 2012 20:44:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Arduino manufacturing problems</title>
		<link>http://chemicaloliver.net/arduino/arduino-manufacturing-problems/</link>
		<comments>http://chemicaloliver.net/arduino/arduino-manufacturing-problems/#comments</comments>
		<pubDate>Fri, 01 Oct 2010 17:17:41 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[bad quality]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[soldering]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=768</guid>
		<description><![CDATA[After reading a post on hackaday Next generation Arduino manufacturing problems it has prompted me to photograph my new Arduino mega 2560 which frankly looks a bit sloppy. The first thing that struck me was the burnt flux on the main chip: Then I noticed staining on around the caps too, nothing that affects the functionality of [...]]]></description>
			<content:encoded><![CDATA[<p>After reading a post on hackaday <a href="http://hackaday.com/2010/10/01/next-generation-arduino-manufacturing-problems/">Next generation Arduino manufacturing problems</a> it has prompted me to photograph my new Arduino mega 2560 which frankly looks a bit sloppy.</p>
<p>The first thing that struck me was the burnt flux on the main chip:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/10/DSC04543.jpg"><img class="size-thumbnail wp-image-769 aligncenter" title="Arduino Mega Flux" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/10/DSC04543-300x248.jpg" alt="Arduino Mega Flux" width="300" height="248" /></a></p>
<p>Then I noticed staining on around the caps too, nothing that affects the functionality of the unit but it left me feeling disappointed. This arduino cost me £57 + shipping + a new ethernet shield to use with it (which is incidentally, absolutely perfectly manufactured and really shows up the mega). My board also had sharp bits on but I filed them off. I paid a premium price to get what I thought was a premium quality product, clearly I was wrong and will think twice before buying any official arduino hardware again.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/10/DSC04544.jpg"><img class="aligncenter size-thumbnail wp-image-770" title="Arduino staining" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/10/DSC04544-225x300.jpg" alt="Arduino staining" width="225" height="300" /></a></p>
<p>And don&#8217;t even get me started on releasing the boards before<a href="http://chemicaloliver.net/arduino/using-the-new-arduino-mega-2560-with-arduino-19-on-ubuntu/"> there was linux support</a>. At first I thought I had faulty hardware after seeing it and then it not working.</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/arduino-manufacturing-problems/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Using the new Arduino Mega 2560 with Arduino 0019 on Ubuntu</title>
		<link>http://chemicaloliver.net/arduino/using-the-new-arduino-mega-2560-with-arduino-19-on-ubuntu/</link>
		<comments>http://chemicaloliver.net/arduino/using-the-new-arduino-mega-2560-with-arduino-19-on-ubuntu/#comments</comments>
		<pubDate>Thu, 30 Sep 2010 21:42:48 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[interactive]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=761</guid>
		<description><![CDATA[I should state that this post is only applicable to the arduino 0019 IDE version and later versions should solve issues here, however at the time of writing such versions have not been released. Today I was happy to take delivery of one of the first new arduino megas which utilise the atmega2560 and replace [...]]]></description>
			<content:encoded><![CDATA[<p><em>I should state that this post is only applicable to the arduino 0019 IDE version and later versions should solve issues here, however at the time of writing such versions have not been released.<br />
</em><br />
Today I was happy to take delivery of one of the first new arduino megas which utilise the atmega2560 and replace the ftdi chip with a more versatile ATMEGA 8U2. The websocket server I&#8217;ve been writing is getting a bit heavy for the arduino duemilanove I used up to now at around 20kb so I decided it was time to upgrade. However I had failed to notice that a version of the arduino IDE  (0020) had not been released for Linux at the same time as the hardware. This was a bit of an oversight on my part but I think it was a bit silly of the arduino team to release the hardware without mentioning it.</p>
<p>In this post I intend to briefly outline things I&#8217;ve tried that can make it work at least a bit&#8230;</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/09/IMG_3137.jpg"><img class="aligncenter size-thumbnail wp-image-762" title="Arduino Mega 2560" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/09/IMG_3137-300x199.jpg" alt="Arduino Mega 2560" width="300" height="199" /></a></p>
<p><span id="more-761"></span></p>
<h2>Hardware</h2>
<p>The main improvement, for me, of this new arduino over the old mega is the double memory capacity which allows me to grow a bit further after the duemilanove. Most noticeable on arrival is the new packaging which is a nice touch and makes the product feel like a commercial product rather than some underground toy.</p>
<p>However it&#8217;s not all good, the quality of production of this board seems to have dropped slightly, it having a significant amount of flux on the chip, not a major issue, I just like things to be perfect!</p>
<h2>Software</h2>
<p>This is where all hell breaks loose. The arduino mega 2560 and arduino uno require the new version 0020 of the IDE to work correctly, this is <a href="http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285659745">not yet available on linux due to rxtx problems</a>, when I ordered I stupidly assumed that there would be the same software support that had always been there but sadly not, so I tried a few things to try and make it work, with varying amounts of success:</p>
<h3>Run the IDE under Windows XP in a virtual machine</h3>
<p>While I could put up with this for a week or two it&#8217;s not ideal..and proved far from reliable.</p>
<p>I duly downloaded and installed the windows version of arduino 0020, I already have a virtual machine set up with XP and usb set up, so I piped through the usb port for the arduino, it was detected by windows and appeared to install correctly however when attempting to upload the blink sketch (which compiles fine) I get errors from avrdude:</p>
<p><code>avrdude: stk500v2_recv(): checksum error<br />
avrdude: stk500v2_recv(): checksum error<br />
avrdude: verification error, first mismatch at byte 0x0268<br />
0x68 != 0xb1<br />
avrdude: verification error; content mismatch</code></p>
<p>After retrying sometimes I was able to upload a sketch, but not reliably, sometimes it just hanging on upload. At this point I didn&#8217;t really know what to do,  so I tried it on a real windows computer and it worked fine&#8230;but that is not a workable solution for me so I tried a more radical approach:</p>
<h3>Modify the Arduino 0019 IDE to work</h3>
<p>I did not have high hopes here as there is obviously a reason if the arduino team are having issues with 0020 on linux. However I had limited success.</p>
<p>I took the hardware/arduino/boards.txt file from the new windows arduino 0020 ide and pasted it into the corresponding place in the 0019 IDE on linux, the arduino mega 2560 (and uno) now appear in the boards menu. All good so far but in removing the ftdi chip the arduino moved its default location moving from /dev/ttyUSB0 to /dev/ttyACM0, to compenste for this I made a symlink between the locations <code>sudo ln -s /dev/ttyACM0 /dev/ttyUSB0</code> after inserting the arduino usb lead into the computer.</p>
<p>Now when starting the ide there is a delay of several seconds longer than usual with no errors shown, sketches can be opened and compiled for the mega 2560 but everytime the tools menu is accessed there is the same hanging of the program for several seconds while the serial ports are searched. Despite these problems sketches can be uploaded most of the time, others the arduino just hangs&#8230;</p>
<p><em>Edit: Since writing this post I&#8217;ve noticed that there were 5 instances of avrdude running left over from my messing about collectively maxing out my quad core processor so there are definitely  still issues to be resolved!</em></p>
<p>That&#8217;s as far as I got&#8230;hoping for a better solution soon&#8230;</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/using-the-new-arduino-mega-2560-with-arduino-19-on-ubuntu/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>WebSocket-Arduino Forked &#8211; Updated arduino websocket library now in development</title>
		<link>http://chemicaloliver.net/arduino/websocket-arduino-forked-updated-arduino-websocket-library-now-in-development/</link>
		<comments>http://chemicaloliver.net/arduino/websocket-arduino-forked-updated-arduino-websocket-library-now-in-development/#comments</comments>
		<pubDate>Sat, 11 Sep 2010 13:20:43 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[web sockets]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=742</guid>
		<description><![CDATA[After consultation with the original developer of the only existing Arduino (@razorbeans) websockets library I have forked the project to allow me to take over maintenance. Over the coming weeks and months I intend to: Migrate the library to use the new bundled string library rather than the WString library (mostly done) Tidy up the code Add functions for [...]]]></description>
			<content:encoded><![CDATA[<p>After consultation with the original developer of the only existing Arduino (<a href="http://twitter.com/razerbeans">@razorbeans</a>) websockets library I have forked the project to allow me to take over maintenance. Over the coming weeks and months I intend to:</p>
<ul>
<li>Migrate the library to use the new bundled string library rather than the WString library (mostly done)</li>
<li>Tidy up the code</li>
<li>Add functions for onconnect, onmessage and allow sending of strings at a time determined by the Arduino, not just in response to a message from the client.</li>
<li>Update the library to allow recent browsers to connect. Currently the library supports the version 75 handshake protocol but most browsers have now moved to the more recent 76 protocol..</li>
</ul>
<p>The project is available to <a href="http://github.com/chemicaloliver/WebSocket-Arduino">download on Github</a> currently this will only work with versions of Google chrome before 6.0.414.0 but this will hopefully change soon as the handshake is updated.</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/websocket-arduino-forked-updated-arduino-websocket-library-now-in-development/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Maker Faire UK 2010 Newcastle</title>
		<link>http://chemicaloliver.net/arduino/maker-faire-uk-2010-newcastle/</link>
		<comments>http://chemicaloliver.net/arduino/maker-faire-uk-2010-newcastle/#comments</comments>
		<pubDate>Sun, 14 Mar 2010 13:02:10 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=429</guid>
		<description><![CDATA[Yesterday I spent a very tiring but entertaining day back in my home from home, Newcastle. The reason being to attend the 2nd UK Maker Faire organised by Make Magazine. My legs have just about recovered from all the standing up and walking I did so I thought I&#8217;d do a post about some of [...]]]></description>
			<content:encoded><![CDATA[<p>Yesterday I spent a very tiring but entertaining day back in my home from home, Newcastle. The reason being to attend the 2nd UK Maker Faire organised by <a href="http://makezine.com/">Make Magazine</a>. My legs have just about recovered from all the standing up and walking I did so I thought I&#8217;d do a post about some of the more interesting things I saw.</p>
<h4>Guerilla Knitting</h4>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_28151.png"><img class="aligncenter size-medium wp-image-431" title="Knitted Maker Faire Sign " src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_28151-225x300.png" alt="" width="225" height="300" /></a></p>
<p style="text-align: left;">Around Newcastle for the past few days knitting has been appearing attached to railings and signs, this was <a href="http://www.newcastlesciencefest.co.uk/News/Details.aspx?Id=18">organised</a> as part of the Newcastle Science week and really does look pretty cool, I especially liked this example above outside the Discovery Museum and the one below in the Centre for Life. This seems to be part of a larger movement, known as Guerilla Knitting which aims to bring a smile to peoples faces by placing art in somewhere unusual (<a href="http://www.guardian.co.uk/lifeandstyle/2009/feb/23/guerrilla-knitting-yarn-bombing-magda-sayeg">from here</a> &#8211; the most sensible explanation I can find).</p>
<p><span id="more-429"></span></p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2811.jpg"><img class="size-medium wp-image-433 aligncenter" title="Guerilla Knitting in Newcastle" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2811-292x300.jpg" alt="Guerilla Knitting in Newcastle" width="234" height="240" /></a></p>
<h4>Sugru</h4>
<p style="text-align: left;"><a href="http://sugru.com/">Sugru</a> has rapidly become a bit of a cult material recently and having been publicised by mentions in Make and Wired is now very difficult to get hold of. It seemed to be just as popular in the flesh as online and the stall always seemed busy throughout the day. Sugru is an unusual material, much like a grown up version of play dough which hardens into a grippy silicone rubber when left to set. It&#8217;s also self adhesive so it can be used to fix and modify items as far as your imagination allows. I had the chance to meet two of the people behind it &#8211; Jane (it&#8217;s creator) and James(? if that&#8217;s wrong I&#8217;m sorry I really should remember after specifically asking!) :</p>
<p style="text-align: left;">
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2742.jpg"><img class="size-medium wp-image-434 aligncenter" title="Makers of Sugru" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2742-300x199.jpg" alt="Makers of Sugru" width="300" height="199" /></a><br />
<a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_27401.jpg"><img class="size-medium wp-image-437 aligncenter" title="Examples of Sugru Hacks" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_27401-300x199.jpg" alt="Examples of Sugru Hacks" width="300" height="199" /></a><br />
<a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2741.jpg"><img class="size-medium wp-image-436 aligncenter" title="People from Sugru" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2741-300x199.jpg" alt="People from Sugru" width="300" height="199" /></a></p>
<h4>Rubot II</h4>
<p style="text-align: left;">The <a href="http://www.mechatrons.com/rubot.html">Rubot II</a> is a robot which can solve rubick&#8217;s cubes in a maximum of 50s. It was probably the most impressive example of robotics on show and I found it particularly interesting having worked on computer vision systems for my MSc. thesis. Having said all that I felt it a little lacking compared to many other stalls as it&#8217;s a bit of a one trick pony and I think I like things with more of a reason for being.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2738.jpg"><img class="size-medium wp-image-438 aligncenter" title="Rubot II " src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2738-300x199.jpg" alt="Rubot II" width="300" height="199" /></a></p>
<h4>.: oomlout :.</h4>
<p><a href="http://oomlout.com/">Oomlout</a> is a name I&#8217;ve mentioned several times on this blog and is my preferred retailer of arduino type things, they had all the usual things on show but what particularly caught my attention were some juicy looking robot kits not yet for sale:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2810.jpg"><img class="size-medium wp-image-439 aligncenter" title="Oomlout robot kits" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2810-300x199.jpg" alt="Oomlout robot kits" width="300" height="199" /></a></p>
<p style="text-align: left;">Another thing they had was the<a href="http://oomlout.co.uk/?p=79"> twypewriter</a> which uses and arduino to receive and then printout tweets, however along with many other network connected devices on show, it was having troubles with the wifi network! This the whole stall captured in this rather unflattering shot:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2719.jpg"><img class="size-medium wp-image-440 aligncenter" title="Oomlout stall at the maker faire uk 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2719-300x200.jpg" alt="oomlout stall at the maker faire uk 2010" width="300" height="200" /></a></p>
<p>My delight for free stuff was also indulged and I got a free keyring, something I&#8217;ve wanted since I saw photos of them at the 2009 Maker Faire.</p>
<h4>Mitch Altman</h4>
<p>Well known hardware hacker and creator of the TV-B-Gone <a href="http://en.wikipedia.org/wiki/Mitch_Altman">Mitch Altman</a> gave a couple of talks (which I managed to miss because I was distracted talking to other people) and could be seen hanging around the hardware hacking workshop area where people were also trying out these cool looking self hypnosis glasses:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2802.jpg"><img class="size-medium wp-image-441 aligncenter" title="Self Hypnosis Glasses at the Maker Faire UK 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2802-213x300.jpg" alt="Self Hypnosis Glasses at the Maker Faire UK 2010" width="213" height="300" /></a></p>
<h4>BBC</h4>
<p>I wasn&#8217;t aware that the bbc did cool stuff like this but they were exhibiting a number of &#8216;inventions&#8217; from thier labs. Including a camera system which takes high resolution images with a very deep depth of field and then allows adjustment of the depth of field afterwards. A physical remote control with echoes of retro tv remotes where the controller was wired to the tv and allowed users to more easily take control of the tv (I&#8217;m really not sure of the point&#8230;). More interesting was a system designed to allow families to choose what to watch democratically, based on the game Guess Who, however here players would flip down all the tv shows they didn&#8217;t wish to watch and the system would generate a playlist of shows which were liked by all:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2807.jpg"><img class="size-medium wp-image-442 aligncenter" title="Guess Who BBC version at Maker Faire UK 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2807-300x199.jpg" alt="Guess Who BBC version at Maker Faire UK 2010" width="300" height="199" /></a></p>
<h4>Bubblino</h4>
<p>Yet another twitter and arduino powered device which simply blows bubbles when tweeted to/about:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2747.jpg"><img class="size-medium wp-image-443 aligncenter" title="Bubblino at Maker Faire UK 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2747-300x199.jpg" alt="Bubblino at Maker Faire UK 2010" width="300" height="199" /></a></p>
<p>Also on the same stall a system for monitoring the running of the Mersey Ferries using AIS positioning (which seems to take inspiration from Andy Stamford Clark&#8217;s <a href="http://stanford-clark.com/ferries.html">twittering ferries</a>):</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2745.jpg"><img class="size-medium wp-image-444 aligncenter" title="Mersey Ferries Clock at Maker Faire UK 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2745-300x199.jpg" alt="" width="300" height="199" /></a></p>
<h4>Musical Tesla Coils</h4>
<p>A common feature of maker and science faires across the world are singing tesla coils in this case designed by Karim Ladha. They were quite impressive, allowing music to be played from a keyboard or guitar which modulates the output of the coils and makes a very loud (and rapidly annoying noise):</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2781.jpg"><img class="size-medium wp-image-445 aligncenter" title="Singing Tesla Coils Maker Faire UK 2010" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2781-300x199.jpg" alt="Singing Tesla Coils Maker Faire UK 2010" width="300" height="199" /></a></p>
<h4>Curiosity Collective</h4>
<p>A <a href="http://curiositycollective.org/">group of guys</a> from Ipswich, probably best known for walking to the Faire via Amsterdam (athough those who were doing that currently hadn&#8217;t arrived when I spoke to them!). They had some cool map visualisations and also an experiment into how accurately people can draw a map of the UK from memory.</p>
<h4>mbed</h4>
<p>The <a href="http://mbed.org/">mbed</a> microcontroller board with an ARM chip looks very attractive to me. I had a nice explanation of it&#8217;s finer points from one of the guys there but I&#8217;m still slightly unhappy about relying on an online compiler for some hardware to function, in a similar way to me not having bought a PS3 due to its need to be online. We&#8217;ll wait and see, if I have some spare cash to splash I might get one soon.</p>
<h4>Other People</h4>
<p>I also met people from <a href="http://openenergymonitor.org/emon/">openenergymeter</a>, <a href="http://www.sonodrome.co.uk/">sonodrome</a> and<a href="http://hackable-devices.com/"> hackable devices</a>, all of which had some cool things on display. Hackable devices had some cool open source devices on show like the Neo Freerunner, makerbot and other bits and pieces sadly we couldn&#8217;t play with them. They also suffered after their stall collapsed half way through the morning.</p>
<p>All in all a very enjoyable day talking to some very nice people and learning lots. I also had chance to revisit some favourite Newcastle haunts including the <a href="http://www.balticmill.com/">Baltic</a> and the <a href="http://www.amber-online.com/sections/side-gallery">Side gallery</a> both of which had good exhibitions. I got an amazing bargain from the Oxfam bookshop: A new hardback copy of &#8220;The C++ Programming Language&#8221; for £3.99 rather than the usual £40-50. My legs now ache terribly from carrying it around all day in addition to my camera, lenses and laptop!</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/maker-faire-uk-2010-newcastle/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MQTT, Arduino, Old Ammeters and Bandwidth Monitoring</title>
		<link>http://chemicaloliver.net/arduino/mqtt-and-ammeters/</link>
		<comments>http://chemicaloliver.net/arduino/mqtt-and-ammeters/#comments</comments>
		<pubDate>Thu, 11 Mar 2010 22:52:22 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=421</guid>
		<description><![CDATA[Thanks to some help from @knolleary the arduino pubsub library now works with mosquitto. I have now completed my bandwidth monitor project which I want to document in this post. I have mentioned in previous posts that I use various scripts and sensors to feed data into the open source MQTT broker mosquitto. Currently all [...]]]></description>
			<content:encoded><![CDATA[<p>Thanks to some help from <a href="http://twitter.com/knolleary">@knolleary</a> the <a href="http://knolleary.net/arduino-client-for-mqtt/">arduino pubsub library</a> now works with <a href="http://mosquitto.atchoo.org/">mosquitto</a>. I have now completed my bandwidth monitor project which I want to document in this post.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2702.png"><img class="size-medium wp-image-422 aligncenter" title="Arduino/MQTT powered bandwidth meter" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/03/IMG_2702-300x200.png" alt="" width="300" height="200" /></a></p>
<p>I have mentioned in previous posts that I use various scripts and sensors to feed data into the open source MQTT broker <a href="http://mosquitto.atchoo.org/">mosquitto</a>. Currently all data is posted to <a href="http://www.pachube.com/users/chemicaloliver/feeds">pachube</a>, rather than everything being online I decided I wanted some physical feedback. Having made an impulse buy of two vintage Ferranti ammeters using these to display some of my data seemed like obvious answer! The code on the arduino basically just displays a number passed by MQTT on the meter and therefore could be applied to any measurement one cared to choose.</p>
<p>The basic idea of this system is to monitor the current internet speed usage and display it on the ammeter. The system is based around an <a href="http://arduino.cc">arduino</a> with ethernet shield which acts as an MQTT client, this subscribes to the downstream bandwidth topic on my MQTT broker, receives the messages and changes the level of a PWM output pin on the arduino which causes the meter to show the appropriate level. The meter displays the current through a resistor which is varied by the PWM signal from the arduino. The reading on the meter corresponds to the current internet speed usage as a percentage of the overall theoretical available bandwidth.</p>
<p><span id="more-421"></span></p>
<h4>The Arduino Code</h4>
<p>As this is quite well commented I won&#8217;t go through it, but it serves as a good example of how to receive MQTT messages using an arduino:</p>
<pre class="brush: cpp; title: ; notranslate">
#include &lt;Ethernet.h&gt;
#include &lt;PubSubClient.h&gt;

//Setup network connection
byte mac[] = {  0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { &lt;arduino ip&gt; };
byte subnet[] = {&lt;subnet&gt;};
byte gateway[] = {&lt;router ip&gt;};

//MQTT Broker
byte server[] = {&lt;mqtt broker (mosquitto/RSMB)&gt;};
int port = 1883;
//Meter output spin
int meterPin = 9;

//Set initial bandwidth
float out = 0;

//MQTT client setup
PubSubClient client(server, port, callback);

//Add callback for when a message is recieved
//
// Takes bandwidth as 4 digit number e.g 44 = 0044
void callback(char* topic, byte* payload,int length) {
  //reset value
  out=0;

  //convert receieved byte array into number
  for(int i=0;i&lt;4;i++)
  {
    //get the byte
    byte ardValue = payload[i];
    //multiply it by 1/10/100 or 1000
    double tens = pow(10,(3-i));
    //convert the byte to either 1/10/100/1000
    float ardOut = tens * (ardValue-48);
    //add to total output
    out +=ardOut;
  }

  //scale number between 0-4000 to 0-255 for output
  out = map(out, 0, 4000, 0, 255);

  //print result to serial port for debugging
  Serial.println(out);

  //write output to meter
  analogWrite(meterPin, out);
}

//setup method
void setup()
{
  //start ethernet connection
  Ethernet.begin(mac, ip, gateway, subnet);

  //start serial connection for debugging
  Serial.begin(9600);

  //connect to MQTT Broker
  client.connect(&quot;arduino&quot;);

  //Subscribe to topic bandDown
  client.subscribe(&quot;bandDown&quot;);
}

//main loop
void loop()
{
  //Tell the MQTT broker we're still here
  client.loop();
}
</pre>
<p>The PHP script that provides the bandwidth data resides on my sheevaplug and queries my router for an XML file with the appropriate details, <a href="http://chemicaloliver.net/programming/internet-speed-monitoring-with-bt-2wire-homehub-1800hg/">I talked about this in a previous post.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/mqtt-and-ammeters/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Where to buy electronic components, arduinos and sheevaplugs in the UK?</title>
		<link>http://chemicaloliver.net/arduino/where-to-buy-electronic-components-in-the-uk/</link>
		<comments>http://chemicaloliver.net/arduino/where-to-buy-electronic-components-in-the-uk/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 23:17:26 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[build]]></category>
		<category><![CDATA[components]]></category>
		<category><![CDATA[Internet]]></category>
		<category><![CDATA[retailers]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=403</guid>
		<description><![CDATA[Often when I buy an electronics book, or more recently a physical computing book, there is a section detailing where to purchase components, however they&#8217;re almost exclusively in the US and details of UK electronics retailers are difficult to come by for beginners and even more experienced people. In this post I intend to detail some of the electronics component retails who I like [...]]]></description>
			<content:encoded><![CDATA[<p>Often when I buy an electronics book, or more recently a physical computing book, there is a section detailing where to purchase components, however they&#8217;re almost exclusively in the US and details of UK electronics retailers are difficult to come by for beginners and even more experienced people. In this post I intend to detail some of the electronics component retails who I like which sell a range of components from basic resistors and wire to expensive test equipment and embedded computers.</p>
<h2>General Component Retailers</h2>
<p>These are the retailers I most commonly order parts from and like, there are many others who may also be good but these are my favourites, as they stock the basics they&#8217;re used more than any other category here.</p>
<h3><a href="http://www.bitsbox.co.uk">Bitsbox</a></h3>
<p>Bitsbox is a small retailer with a large following, it sells mainly simple components: capacitors, resistors, basic connectors, basic tools all for very reasonable prices when ordering in small quantities, something which is not common among many bigger suppliers. Also standard postage is only 1.50 on any order. I&#8217;ve bought here many times and always had a great experience, quick dispatch and good communication.</p>
<h3><a href="http://uk.farnell.com/">Farnell</a></h3>
<p>Farnell is about the most furthest away from Bitsbox it&#8217;s possible to get in size and product selection,  it stocks hundreds of thousands, maybe millions of products from the mundane basics to the high end exotica and offers free next day delivery on any order. If you need something, almost anything in electronics quickly this is where to go. They are also the only retailer I&#8217;ve found in the UK which stock Texas Instruments components. Service is another area in which farnell is great. Prices can be high on some items but not unreasonable, my recent Agilent multimeter was 20% cheaper than any other UK retailer. Beware of items marked in stock in US which attract a 15 pound postage fee.</p>
<p>A point worthy of note is that if you want you can pick up orders from the trade counter at their international distribution centre in Leeds, West Yorkshire, something I&#8217;ve done a few times. You have to phone to order this way but the order can be collected after 2hrs and is within walking distance of Leeds Station and also is easy to drive to/park at. This makes them my 2nd favourite retailer on this list after NewIT (below).</p>
<p><span id="more-403"></span></p>
<h3><a href="http://www.rapidonline.com/">Rapid Electronics</a></h3>
<p>Rapid are a retailer smaller than Farnell but still quite large, they stock some products which Farnell do not but the catch is that orders under 35 pounds are changed 5 pounds postage. Redeeming factors are the postage is quick and service is generally good.</p>
<h3><a href="http://ebay.co.uk">eBay</a></h3>
<p>If you wish to buy low quality components in bulk then eBay is the place, often from China but usually reliable but usually cheap enough to risk it, especially with the protection provided by Paypal.</p>
<h3><a href="http://www.maplin.co.uk/">Maplin</a></h3>
<p>Maplin only deserve a mention as they are the last high street retailer which sells any kind of electronic components, otherwise they provide inconsistent service, have sometimes stupid staff and charge lots for bad quality products. But if you need some wire quick then it&#8217;s the only option really! A sad summary to give considering it was maplin and tandy (radioshack) which have been with me since my childhood electronics fad which never quite went away.</p>
<h3><a href="http://gb.mouser.com/Home.aspx"><em>Mouser</em></a></h3>
<p><em>Mouser not based in the UK but from my experience have proved the best retailer in the IS to order from if you have to, I ordered 2 panavice bits which are hard to find in the UK and they arrived within 2 days. Amazing, and delivery on orders over 50 pounds and they sort out the VAT in advance so you don&#8217;t get caught out later. These guys are amazing. They also stock some cool bits like beagle boards.</em></p>
<h2>Arduino Etc&#8230;</h2>
<p>A big factor in reigniting my interest in electronics, which had faded since I discovered computers, was micro controllers such as the arduino, these are quite easy to come by in the UK but I have two preferred retailers:</p>
<h3><a href="http://www.oomlout.co.uk/">.:oomlout:.</a></h3>
<p>Oomlout are another small company based in Leeds, they stock the Arduino and associated accessories at reasonable prices, including quite a few nice bits of their own making: the <a href="http://www.oomlout.co.uk/arduino-prototyping-bundle-br-ardp-wo-arduino-p-202.html">arduino prototyping board</a> is a simple piece of laser cut acrylic with holes to bolt the arduino and a small breadboard to fix next to it. They also stock a small range of products designed by <a href="http://www.adafruit.com/">Adafruit</a> (which would be on this list if I was in the US!) which is nice as it saves shipping from the US. Service is, as with most small specialist retailers, exemplary. I&#8217;ve made a few queries both for information and to resolve a problem and both were dealt with quickly. My definite first choice for Arduino related stuff. Oh and shipping is cheap and quick too.</p>
<h3><a href="http://www.coolcomponents.co.uk/catalog/">Cool Components</a></h3>
<p>I have mixed feelings about Cool Components, they sell a much larger range of products than oomlout, offering more advanced microcontrollers and accessories, they&#8217;re almost the Sparkfun of the UK (and they do stock some Sparkfun products). However I feel they seem expensive and VAT is not included in the displayed prices which I feel can be slightly misleading (even though it is stated). I have however bought from them when they had what I wanted and the service they provided was good.</p>
<h3><a href="http://www.seeedstudio.com/depot/"><em>Seeed Studio</em></a></h3>
<p><em>Seeed Studio are not based in the UK but in Hong Kong, however they ship to the UK for cheap prices and offer a lot of components at very cheap prices, like sparkfun style RF transceiver for $4 and the arduino clone Seeeduino. More recently they have started to retail open source test equipment which is attracting quite a lot of interest.</em></p>
<h2>Sheevaplugs</h2>
<p>If you&#8217;ve read my blog before you may know I&#8217;m a fan of the <a href="http://en.wikipedia.org/wiki/SheevaPlug">sheevaplug</a>. I&#8217;ve had mine several months now but when I first found the product I knew of no retailer in the UK, at around the same time New IT was started acting as a European distributor, saving me the hassle of high prices and long waits of ordering from GlobalScale in the US.</p>
<h3><a href="http://www.newit.co.uk/">NewIT</a></h3>
<p>New IT only currently sell Sheevaplugs, Guruplugs and the OpenRD and associated accessories and offer free shipping on all items. Despite the small product range shopping at New IT was possibly the best online shopping experience I&#8217;ve ever had, the online shop is just a typical shop but after ordering I received personal emails on order status and a check to see if it had arrived and if I needed any further help. In this day and age, nothing short of amazing.</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/where-to-buy-electronic-components-in-the-uk/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Controlling lights with TI ez430 chronos, home easy, arduino and processing</title>
		<link>http://chemicaloliver.net/arduino/controlling-lights-with-ti-ez430-chronos-home-easy-arduino-and-processing/</link>
		<comments>http://chemicaloliver.net/arduino/controlling-lights-with-ti-ez430-chronos-home-easy-arduino-and-processing/#comments</comments>
		<pubDate>Sun, 07 Feb 2010 19:17:28 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=348</guid>
		<description><![CDATA[Now that the protocol for basic communication with the TI chronos ez430 has been worked out (see previous posts) I needed to work on something useful. So I set out to try and control my wireless light switch with the watch. Sadly the RF receiver supplied with the chronos does not use a protocol which is likely to ever [...]]]></description>
			<content:encoded><![CDATA[<p>Now that the protocol for basic communication with the TI chronos ez430 has been worked out (see previous posts) I needed to work on something useful. So I set out to try and control my wireless light switch with the watch. Sadly the RF receiver supplied with the chronos does not use a protocol which is likely to ever be compatible with the arduino so this example requires a computer.</p>
<h4>The Hardware</h4>
<p>Recently I&#8217;ve acquired a Home Easy HE217 remote light switch which consists of a unit placed between the light bulb and ceiling rose and a wireless switch to switch the light on and off from anywhere within about 10m. I purchased this with some form of hackery in mind but this is the first real attempt to do anything useful outside of the functionality of the supplied package. The system uses RF at 433MHz and a simple authentication protocol, which is conveniently documented at the <a href="http://homeeasyhacking.wikia.com/wiki/Home_Easy_Hacking_Wiki">Home Easy Hacking Wiki</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-349 aligncenter" title="Home Easy HE217" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/02/311773168_tp.jpg" alt="Home Easy HE217" width="400" height="266" /><br />
<span id="more-348"></span><br />
433MHz is a common frequency used by radio controlled devices such as remote switches, garage doors and car remote controls and transmitters and receivers are readily <a href="http://www.seeedstudio.com/depot/433mhz-rf-link-kit-p-127.html?cPath=2">available for very little money (around $5)</a>. These can be used for many uses especially in combination with an <a href="http://arduino.cc">arduino</a>, following on from the work documented on the <a href="http://homeeasyhacking.wikia.com/wiki/Home_Easy_Hacking_Wiki">Home Easy Hacking Wiki</a> an arduino library has been produced (<a href="http://www.arduino.cc/playground/Code/HomeEasy">available here</a>). This allows the arduino to control the light switch in the same way as the provided Home Easy light switch.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/02/rf.jpg"><img class="size-full wp-image-353 aligncenter" title="Seeeduino 433MHz RF Transmitter" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/02/rf.jpg" alt="Seeeduino 433MHz RF Transmitter" width="380" height="340" /></a></p>
<p>The RF transmitter was then simply connected to the arduino to allow the light switch to be controlled using the arduino.</p>
<h4>The software</h4>
<p>The software aspect of this project consists of my <a href="http://chemicaloliver.net/programming/receiving-ti-ez430-chronos-button-presses-in-processing-and-python/">previous processing sketch</a> which receives button presses from the chronos watch, to this I added functionality so that every time a button press is received a serial character is sent to the arduino in this case H for on and L for off.</p>
<p>On the arduino a sketch is used that reads the serial input and when H or L is received it send an on or off message using the <a href="http://www.arduino.cc/playground/Code/HomeEasy">home easy arduino library</a> thus switching the light. The observant among you will have noticed that this is based on the <a href="http://www.arduino.cc/en/Tutorial/PhysicalPixel">arduino physical pixel example</a>!</p>
<p>The system works even if the watch is taken out of transmit mode and then restarted.</p>
<p>The code can be viewed below.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/rfard.jpg"><img class="size-full wp-image-355 aligncenter" title="Arduino RF transmitter circuit" src="http://chemicaloliver.net/wordpress/wp-content/uploads/2010/02/rfardt.jpg" alt="Arduino RF transmitter circuit" width="380" height="388" /></a></p>
<h4>In action</h4>
<p style="text-align: center;"><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" 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://www.youtube.com/v/j2_NBuWCztk&amp;hl=en_GB&amp;fs=1&amp;rel=0" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/j2_NBuWCztk&amp;hl=en_GB&amp;fs=1&amp;rel=0" allowscriptaccess="always" allowfullscreen="true"></embed></object></p>
<h4>The code</h4>
<p>The processing sketch <a href="http://chemicaloliver.net/code/chronoslight.pde">chronoslight.pde</a></p>
<p>The arduino sketch: <a href="http://chemicaloliver.net/code/chronosHE.pde">chronosHE.pde</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/controlling-lights-with-ti-ez430-chronos-home-easy-arduino-and-processing/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
		<item>
		<title>Graphing ti ez430 Chronos watch data in Linux</title>
		<link>http://chemicaloliver.net/arduino/graphing-ti-ez430-chronos-watch-data-in-linux/</link>
		<comments>http://chemicaloliver.net/arduino/graphing-ti-ez430-chronos-watch-data-in-linux/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 17:17:14 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Processing]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[processing controlp5]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[scripting]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[TI chronos]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=295</guid>
		<description><![CDATA[Recently my Texas Instruments ez430 Chronos watch arrived, I preordered it the day I read about it on engadget back in November 2009, so it was nice to receive it after all this time. As a dedicated Linux user I found it disappointing that there was little in the way of Linux support provided by [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: center;"><a href="http://chemicaloliver.net/images/chronosw.jpg"><img class="aligncenter" title="TI Cronos ez-430" src="http://chemicaloliver.net/images/chronoswt.jpg" alt="" width="380" height="337" /></a></p>
<p style="text-align: left;">Recently my <a href="http://www.ti-estore.com/Merchant2/merchant.mvc?Screen=PROD&amp;Product_Code=eZ430-Chronos-868">Texas Instruments ez430 Chronos </a>watch arrived, I preordered it the day I read about it on engadget back in November 2009, so it was nice to receive it after all this time. As a dedicated Linux user I found it disappointing that there was little in the way of Linux support provided by TI, however this was not unexpected and a linux application is currently being developed, although progress seems to be somewhat slow. However in the last week breakthroughs have been made, <a href="http://e2e.ti.com/support/microcontrollers/msp43016-bit_ultra-low_power_mcus/f/166/t/32714.aspx">uguryildiz in a post on the TI forum</a> revealed the protocol used to request data from the acceleration sensors and also for setting of the time allowing custom applications to be built using this data on Linux or any other operating system able to use usb serial.</p>
<p><span id="more-295"></span></p>
<p>Example code in python was also posted <a href="http://pastebin.com/fde255fd">here</a>, basically the protocol for getting the accelerometer data is very simple:</p>
<ul>
<li>After connecting the RF USB dongle supplied with the watch and putthe watch into ACC transmit mode and connect to the serial port /dev/ACM0 (on linux) with baud of 115200</li>
<li>Send the hex string: 0xFF 0&#215;07 0&#215;03 to open a connection with the watch, it should reply 0xFF 0&#215;06 0&#215;03 to confirm a connection has been made</li>
<li>Accelerometer data can then be requested by sending 0xFF, 0&#215;08, 0&#215;07, 0&#215;00, 0&#215;00, 0&#215;00, 0&#215;00</li>
<li>The watch will then return seven bytes back in the form ff 06 07 tt xx yy zz where the last three bytes are the accelerometer values.</li>
</ul>
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/chronos.jpg"><img class="aligncenter" title="Chronos Sensor Graph" src="http://chemicaloliver.net/images/chronost.jpg" alt="" width="380" height="337" /></a></p>
<p>As a simple experiment I used the afore mentioned python code to get data from the watch and then combined this with a graphing gui example kindly posted by <a href="http://eli.thegreenplace.net/2008/08/01/matplotlib-with-wxpython-guis/">Eli Bendersky</a> to make an application which uses matplotlib produce a live graph of the data (currently only one axis at a time).</p>
<p>My code can be downloaded here: <a href="http://chemicaloliver.net/code/chronos_graph.py">chronos_graph.py</a></p>
<p>It should be noted that this code is very much hacked together, I am not a python coder and have never written anything in python before in my life, but it should work.</p>
<p>I am currently working on trying to get this working with processing and arduino, however serial communication from processing with the watch is proving troublesome so I reverted to python for this example.</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/graphing-ti-ez430-chronos-watch-data-in-linux/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Using a webcam with OpenCV to display video on an LED Matrix controlled by arduino</title>
		<link>http://chemicaloliver.net/arduino/usinga-webcam-with-opencv-to-display-video-on-an-led-matrix-controlled-by-arduino/</link>
		<comments>http://chemicaloliver.net/arduino/usinga-webcam-with-opencv-to-display-video-on-an-led-matrix-controlled-by-arduino/#comments</comments>
		<pubDate>Sun, 06 Dec 2009 22:08:19 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[c++]]></category>
		<category><![CDATA[libserial]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[RS232]]></category>
		<category><![CDATA[serial]]></category>
		<category><![CDATA[webcam]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=232</guid>
		<description><![CDATA[Recently I&#8217;ve been looking for new things to do with my LED Matrix shield I made for arduino and as I have some experience with writing video caputure systems I thought I&#8217;d have a go at trying to capture webcam video frames and processing them and  then displaying them in real time on an 8&#215;8 [...]]]></description>
			<content:encoded><![CDATA[<p>Recently I&#8217;ve been looking for new things to do with my <a href="http://chemicaloliver.net/electronics/arduino-led-matrix-shield/">LED Matrix shield</a> I made for arduino and as I have some experience with writing video caputure systems I thought I&#8217;d have a go at trying to capture webcam video frames and processing them and  then displaying them in real time on an 8&#215;8 LED Matrix. Previously as part of my <a href="http://chemicaloliver.net/projects/face-tracking-for-pseudo-virtual-reality-applications/">masters thesis</a> I had worked with OpenCV which, amongst many other image processing and computer vision features, provides simple, cross platform video capture capability so this formed the starting point of my experiments.</p>
<p>In this post I will describe a method for the capture of video frames from a webcam using OpenCV, the subsequent processing required to convert to an 8&#215;8 monochrome image and the process of sending the data via serial to arduino using libserial which is linux specific. Example source code is included at the end.</p>
<p style="text-align: left;">Having previously used a Logitech Quickcam Fusion with windows and OpenCV I started out on this project assuming it would work in linux, however the camera isn&#8217;t fully supported by Linux due to the specific chipset used so I replaced my webcam and found the Microsoft Lifecam Cinema Webcam to be fully linux compatible and the highest quality webcam currently available at a sensible price (currently ~£45 on Amazon) and has proved to work very well in all respects producing very high quality images (for a webcam).</p>
<p style="text-align: center;"><img class="aligncenter" title="Microsoft Lifecam Cinema Webcam" src="http://chemicaloliver.net/images/webcam.JPG" alt="" width="228" height="203" /><br />
<span id="more-232"></span></p>
<h3>Video Capture and Processing</h3>
<p>The rest of this post assumes that OpenCV has been correctly installed and is known to the compiler and will concentrate on the main functions required to perform the capture and image processing.</p>
<p>OpenCV represents video streams as CvCapture objects, andOpenCV images such as video frames as IPL images, a standard type defined by Intel but basically an encapsulated BGR matrix of the pixels. So initially I define the variables which will hold the capture stream and the images required:</p>
<p><code>CvCapture * pCapture;    //new OpenCV capture stream<br />
IplImage * pVideoFrame;           //new OpenCV image<br />
IplImage * pVideoFrameBW;      //new OpenCV image for colour conversion</code></p>
<p>A video stream from a camera, assuming that the camera is correctly installed in the guess operating system, can be initialised in one line:</p>
<p><code>pCapture = cvCaptureFromCAM(0);    //choose camera for capture</code></p>
<p>where the parameter is the capture device, if you only have one webcam it&#8217;s likely to be 0 otherwise you&#8217;ll need to experiment to find the correct one.</p>
<p>To display the image being transmitted a window can be created using the HighGUI library integrated with OpenCV:</p>
<p><code>cvNamedWindow( "video", CV_WINDOW_AUTOSIZE );</code></p>
<p>Now the main data structures have been defined we need to enter into a loop to perform the frame capture and processing. OpenCV includes a GUI library and this will be used to display the images on screen and also control behaviour of the program, in the example code extra GUI features control some parameters. To control the loop we will use the <code>cvWaitKey(int time)</code> function which returns -1 if no key press has been detected and the ASCII code of the character if a key is pressed within the time specified in milliseconds. Therefore the main loop will be of the form:</p>
<p><code>int key = -1;<br />
while(key==-1)<br />
{<br />
<em>capture and process</em><br />
}<br />
<em>clean up and exit</em></code></p>
<p>Inside every cycle of the loop a new frame needs to be captured from the stream, this is achieved using the the <code>cvQueryFrame(CvCapture pCapture)</code> method:</p>
<p><code>pVideoFrame = cvQueryFrame(pCapture);<br />
</code><br />
Next to reduce the number of colours in the image a threshold is needed of the image, again OpenCV includes a function to do this:</p>
<p><code>cvThreshold(pVideoFrame, pVideoFrame, thresh, 255, CV_THRESH_BINARY);</code></p>
<p>where<code> thresh</code> is the level to which thresholding is required, more information can be found <a href="http://www710.univ-lyon1.fr/~bouakaz/OpenCV-0.9.5/docs/ref/OpenCVRef_ImageProcessing.htm#decl_cvThreshold">here</a>.</p>
<p>As the data required for display on a basic LED matrix is not in colour it needs to be converted to black and white, in OpenCV this works by creating an empty image of the correct colour depth and then using the <code>cvCvtColor()</code> function:</p>
<p><code>pVideoFrameBW=cvCreateImage(cvGetSize(pVideoFrame),8,1);<br />
cvCvtColor(pVideoFrame, pVideoFrameBW, CV_BGR2GRAY);</code></p>
<p>As currently the LED matrix I&#8217;m working with is an 8&#215;8 type the image needs to be scaled down considerably to fit, in my case by about 60 time, this is done in a similar way to the conversion of the colour:</p>
<p><code>/*create small image*/<br />
IplImage* out = cvCreateImage( cvSize(pVideoFrameBW-&gt;width/60,<br />
pVideoFrameBW-&gt;height/60), pVideoFrameBW-&gt;depth,<br />
pVideoFrameBW-&gt;nChannels );<br />
cvResize(pVideoFrameBW,out,CV_INTER_NN); </code></p>
<p>In order to display the image on screen at a sensible size the small image needs to be scaled back up again and then displayed:<br />
<code>cvResize(out,pVideoFrameBW,CV_INTER_NN);<br />
cvShowImage( "video", pVideoFrameBW);</code></p>
<p>This produces a window which will look something like this:</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/window.jpg"><img class="aligncenter" title="Screenshot of OpenCV window" src="http://chemicaloliver.net/images/windowt.jpg" alt="" width="400" height="342" /></a></p>
<p>Now that a small monochrome image has been formed the value of each pixel needs to be transmitted to the arduino if it is black or white. The value of a pixel can be extracted from the image using the cvGet2D() method and returns a CvScalar object containing three matrices ( for BGR respectively)  for ease I have taken just the blue values here, the two loops consider each column of pixels and store their value in p:</p>
<p><code>for(int y=0; y&lt;8; y++)<br />
{<br />
for(int x=0;x&lt;8;x++)<br />
{<br />
CvScalar s;<br />
s=cvGet2D(out,y,x);<br />
/*save pixel value (blue)*/<br />
int p = s.val[0];<br />
/*print value to terminal for debugging*/<br />
printf("%i",p);<br />
if(p==255) //if the pixel is black<br />
{<br />
p=1; //turn on led<br />
}<br />
}</code></p>
<p>Now that all processing and capture has taken place for this frame we can wait for a keypress to close the program and clean up any memory used during this iteration:</p>
<p><code>key = cvWaitKey(20);<br />
/*release memory*/<br />
cvReleaseImage(&amp;pVideoFrameBW);<br />
cvReleaseImage(&amp;out);</code></p>
<p>Now the main while loop can be closed and final cleaning up carried out</p>
<p><code>cvReleaseImage( &amp;pVideoFrame );<br />
cvReleaseCapture ( &amp;pCapture );<br />
cvDestroyWindow( "video" );</code></p>
<p>That concludes the summary of what is required to capture images from a video stream and process it to a smaller monochrome image, next we will consider sending the data.</p>
<h3>Serial Communication</h3>
<p>I shall be fairly brief discussing serial communication as it&#8217;s a topic well covered in <a href="http://devlog.bigmonachus.org/2008/08/interfacing-arduino-with-c-and.html">other postings</a> such as <a href="http://devlog.bigmonachus.org/2008/08/interfacing-arduino-with-c-and.html">here</a>.</p>
<p>It can be achieved in linux quite simply using libSerial which allows a steam object to be created and anything which is added to the stream is forwarded to the serial port. In this system this means each pixel would be represented by a 1 or 0 depending on if the led is required to be on or off which is sent to the arduino and interpreted. In my example I used 115200 baud but had to add a delay in the loop using usleep to allow the arduino to have time to process the incoming data.</p>
<p>This method of sending the data is however quite inefficient as each led only requires an on or off to be sent which could consist of one bit being either 0 or 1 however this system sends data using ASCII. ASCII uses several bits per led making the communication and processing much slower than it could be, shifting the process to a stream of bits should greatly improve the framerate and will be discussed in a later post when I finish writing the code!</p>
<h3>Arduino Code</h3>
<p>The the arduino takes data from the serial stream and displays it on the leds and takes no other part in the processing. It uses similar code to my <a href="http://chemicaloliver.net/projects/twitterpop/">twitterpop</a> project however I will get around to posting the code here soon.</p>
<h3>Example</h3>
<p>An example class can be found <a href="http://chemicaloliver.net/code/Controller.cpp">here</a>, it shows the includes which might not normally be there but it makes things slightly clearer, you&#8217;ll need to do you&#8217;re own header file.</p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/usinga-webcam-with-opencv-to-display-video-on-an-led-matrix-controlled-by-arduino/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Getting NMEA data from an Inforad GPS speed camera detector</title>
		<link>http://chemicaloliver.net/arduino/getting-nmea-data-from-an-inforad-gps-speed-camera-detector/</link>
		<comments>http://chemicaloliver.net/arduino/getting-nmea-data-from-an-inforad-gps-speed-camera-detector/#comments</comments>
		<pubDate>Thu, 19 Nov 2009 14:00:29 +0000</pubDate>
		<dc:creator>Oliver</dc:creator>
				<category><![CDATA[arduino]]></category>
		<category><![CDATA[Electronics]]></category>

		<guid isPermaLink="false">http://chemicaloliver.net/?p=189</guid>
		<description><![CDATA[Some time ago I came across a post in the EeeUser forum alerting me to a cheap (£7.50) unit which was aimed at alerting drivers to speed cameras, however it also happens to provide a stream of standard NMEA data on a serial line. If you wish to obtain these units now they are readily [...]]]></description>
			<content:encoded><![CDATA[<p>Some time ago I came across a post in the EeeUser forum alerting me to a cheap (£7.50) unit which was aimed at alerting drivers to speed cameras, however it also happens to provide a stream of standard NMEA data on a serial line. If you wish to obtain these units now they are readily available from ebay for under £10 .</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/Screenshot.png"><img class="aligncenter" title="Inforad Box" src="http://chemicaloliver.net/images/Screenshot.png" alt="" width="426" height="320" /></a></p>
<p>Having followed the instructions that came with the unit (including no mention of direct GPS functionality) and installed the provided software in windows xp I got nowhere, so I tried it on linux. The device is actually a serial device and the cable which is included is in fact not a conventional USB, cable despite having a USB-A and USB-B plug at either end, it is an FTDI usb-serial adaptor which has linux kernel support. I then found it was possible to connect to it at 4800 baud using <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/">putty</a> or <a href="http://cutecom.sourceforge.net/">cutecom</a> or whatever your favorite terminal happens to be and standard NMEA data is displayed.</p>
<p>On closer examination of the cable the USB-A end can be split apart to reveal a simple Serial to TTL converter based in the PL2302 chip, this allowed me to find drivers (available <a href="http://www.prolific.com.tw/eng/downloads.asp?ID=24">here http://www.prolific.com.tw/eng/downloads.asp?ID=24</a>)  for all versions of windows and receive GPS data over serial in the same method as with Linux.</p>
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/IMG_2403.JPG"><img class=" aligncenter" title="PL2302 FTDI Adaptor" src="http://chemicaloliver.net/images/IMG_2403t.JPG" alt="PL2302 FTDI Adaptor" width="400" height="316" /></a></p>
<p style="text-align: left;">This means that the cable could easily be used for any 5V TTL applications required and also that the GPS unit would be ideal for interfacing with an arduino or similar system as the points for connection can be easily seen on the circuit board:</p>
<p style="text-align: left;">
<p style="text-align: center;"><a href="http://chemicaloliver.net/images/IMG_2398.JPG"><img class="aligncenter" title="Underside of Inforad Main Board" src="http://chemicaloliver.net/images/IMG_2398t.JPG" alt="" width="400" height="316" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://chemicaloliver.net/arduino/getting-nmea-data-from-an-inforad-gps-speed-camera-detector/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

