<?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>Arduino &#8211; semifluid.com</title>
	<atom:link href="/category/electronics/arduino/feed/" rel="self" type="application/rss+xml" />
	<link>/</link>
	<description>Intermediate in flow properties between solids and liquids; highly viscous.</description>
	<lastBuildDate>Wed, 04 May 2016 22:34:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.7.1</generator>
	<item>
		<title>WiFi-Enabled Arduino Fio using the WiFly RN-XV (RN171XV)</title>
		<link>/2013/10/20/wifi-enabled-arduino-fio-using-the-wifly-rn-xv-rn171xv/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Sun, 20 Oct 2013 17:31:12 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[GLCD]]></category>
		<guid isPermaLink="false">/?p=3759</guid>

					<description><![CDATA[The Arduino Fio is a nice little Arduino board designed specifically to interface with XBee devices. I think it&#8217;s a great little board and have used it quite a bit in the past. BUT, I haven&#8217;t talked too much about the XBee interface, so for this post, I wanted to demonstrate an example utilizing the [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The <a href="http://arduino.cc/en/Main/ArduinoBoardFio">Arduino Fio</a> is a nice little Arduino board designed specifically to interface with XBee devices. I think it&#8217;s a great little board and have used it quite a bit in the past. BUT, I haven&#8217;t talked too much about the XBee interface, so for this post, I wanted to demonstrate an example utilizing the XBee socket to get an Arduino Fio onto the web. This is a simple example, just demonstrating communication with the Microchip RN171XV (previously Roving Networks RN-XV) wifi module.</p>
<p><a href="/2013/10/20/wifi-enabled-arduino-fio-using-the-wifly-rn-xv-rn171xv/"><img decoding="async" src="/wp-content/uploads/2013/10/IMG_8040-1024x623.jpg" alt="WiFlyTimeWithConsole Example" /></a></p>
<p>Click through the break for information on the setup and source code to get the Arduino Fio onto the web.<br />
<span id="more-3759"></span></p>
<p>The project uses an Arduino Fio as the microcontroller, a <a href="https://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en560635">Microchip RN171XV</a> wifi module to connect to the internet (hereafter described using the old part name, RN-XV), and a Mini12864 graphical LCD to show debug information.  Here&#8217;s a part list for this project (assuming you already have a USB -&gt; Micro USB cable):</p>
<ul>
<li>Arduino Fio (available on <a href="https://www.amazon.com/dp/B005K0O1PA/?tag=semifluidcom-20">Amazon</a> &amp; <a href="https://www.sparkfun.com/products/10116">Sparkfun</a>)</li>
<li>Mini12864 graphical LCD (available on <a href="http://www.amazon.com/dp/B005K0O1PA/?tag=semifluidcom-20">Amazon</a> &amp; <a href="http://dx.com/p/153821?utm_rid=62305252&amp;utm_source=affiliate">DX</a>)</li>
<li>Microchip RN171XV/Roving Networks RN-XV (available on <a href="http://www.amazon.com/gp/product/B007R9U4VM/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B007R9U4VM&amp;linkCode=as2&amp;tag=semifluidcom-20">Amazon</a> &amp; <a href="https://www.sparkfun.com/products/10822">Sparkfun</a>)</li>
<li>XBee USB adapter &#8211; for programming RN-XV (available on <a href="http://www.amazon.com/gp/product/B004G4XUXU/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B004G4XUXU&amp;linkCode=as2&amp;tag=semifluidcom-20">Amazon</a>, <a href="http://dx.com/p/140960?Utm_rid=62305252&amp;Utm_source=affiliate">DX</a>, &amp; <a href="https://www.sparkfun.com/products/8687">SparkFun</a>)</li>
<li>FTDI 3.3V USB cable &#8211; for programming Fio (available on <a href="http://www.amazon.com/gp/product/B004LBXO2A/ref=as_li_ss_tl?ie=UTF8&amp;camp=1789&amp;creative=390957&amp;creativeASIN=B004LBXO2A&amp;linkCode=as2&amp;tag=semifluidcom-20">Amazon</a>, <a href="http://dx.com/p/397477?Utm_rid=62305252&amp;Utm_source=affiliate">DX</a>, &amp; <a href="https://www.sparkfun.com/products/9717">SparkFun</a>)</li>
</ul>
<p>Want to make it completely wireless? I also used a Lithium Ion Polymer battery (available at <a href="https://www.sparkfun.com/products/341">Sparkfun</a>).</p>
<p>When you first get the RN-XV, it needs to be updated to the latest firmware. First, it needs to be plugged into the XBee USB adapter and connected to your computer. These days, I&#8217;m working on a Mac, so I use <a href="http://freeware.the-meiers.org/">CoolTerm</a> to communicate with the RN-XV. Here are the settings (basically 9600 baud serial communication):</p>
<p><a href="/wp-content/uploads/2013/10/Screen-Shot-2013-10-20-at-14.50.08.png"><img decoding="async" src="/wp-content/uploads/2013/10/Screen-Shot-2013-10-20-at-14.50.08-1024x858.png" alt="CoolTerm Setup Screenshot" /></a></p>
<p>Then the RN-XV needs to be connected to your wireless access point and updated. Type in <code>$$$</code> to enter the command mode and you should see the RN-XV respond <code>CMD</code>. You can then enter the commands one by one (carriage returns after each line) to connect the RN-XV to your WiFi access point. Here is my basic setup (see the <a href="http://ww1.microchip.com/downloads/en/DeviceDoc/rn-wiflycr-ug-v1.2r.pdf">RN-XV datasheet</a> for additional information):</p>
<p>[code lang=&#8221;text&#8221;]<br />
factory RESET<br />
reboot<br />
set wlan auth 4<br />
set wlan ssid XXXX<br />
set wlan phrase XXXX<br />
set wlan join 1<br />
save<br />
reboot<br />
[/code]</p>
<p>The RN-XV should associate (connect) with your wifi network and then you can test the connectivity by pinging the Microchip FTP server:</p>
<p>[code lang=&#8221;text&#8221;]<br />
ping 198.175.253.161 10<br />
[/code]</p>
<p>Then, update the RN-XV to the latest firmware (4.00.1 as of this article&#8217;s publish date):</p>
<p>[code lang=&#8221;text&#8221;]<br />
set ftp address 198.175.253.161<br />
set ftp user roving<br />
set ftp pass Pass123<br />
save<br />
ftp update<br />
[/code]</p>
<p>Once the update downloads, you can reset the factory defaults and reboot:</p>
<p>[code lang=&#8221;text&#8221;]<br />
factory RESET<br />
reboot<br />
[/code]</p>
<p>After the RN-XV resets, you should again enter the basic setup information to get the RN-XV connected to your WiFi access point (see above).  If all works out, then you can disconnect the serial port and pull the RN-XV out of the XBee adapter for the time being (don&#8217;t put it into the Arduino Fio, because the Fio needs to be programmed and the TX/RX lines are shared on the board).</p>
<p>I found a wonderful Arduino library for the RN-XV called <a href="https://github.com/harlequin-tech/WiFlyHQ">WiFlyHQ</a> by harlequin-tech.  The author includes a number of great examples, including a HTTP client, HTTP server, TCP client, UDP client, and web socket client.  Using the basic setup code in the HTTP client example, I added code from my previous <a href="/2013/08/29/arduino-fio-graphical-lcd-console/">Arduino FIO Graphical LCD Console</a> to make a simple &#8220;clock&#8221; that updates approximately every 3 seconds using the <a href="http://tf.nist.gov/tf-cgi/servers.cgi">time-c.nist.gov</a> <a href="http://www.nist.gov/pml/div688/grp40/its.cfm">time server</a>.  I used the console code because it allows for very simple debug printing (since the Fio&#8217;s serial TX/RX pins are shared with the XBee socket).  Here an admittedly boring short video illustrating the &#8220;clock&#8221; being startup and allowed to run (the value on the far left is an indicator of the wireless signal strength, <a href="https://en.wikipedia.org/wiki/Received_signal_strength_indication">RSSI</a>):</p>
<p><iframe title="WiFi enabled Arduino Fio using the WiFly RN-XV" width="648" height="365" src="https://www.youtube.com/embed/bx8jDz5C-J8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p>And finally, here&#8217;s the Arduino sketch:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/cf225ac77c26fe001f39.js"></script></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO Graphical LCD Console</title>
		<link>/2013/08/29/arduino-fio-graphical-lcd-console/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Thu, 29 Aug 2013 07:29:18 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[GLCD]]></category>
		<guid isPermaLink="false">/?p=3621</guid>

					<description><![CDATA[I have previously shown how to use the Arduino Fio and the mini12864 graphical LCD to create a simple oscilloscope. For this post, I wanted to demonstrate the u8glib console demo because I plan on using the GLCD to debug some of my projects and to provide a visual interface for experiments with the Microchip [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>I have previously shown how to use the <a href="http://arduino.cc/en/Main/ArduinoBoardFio" target="_blank">Arduino Fio</a> and the mini12864 graphical LCD to create a <a href="/2013/05/28/arduino-fio-lcd-oscilloscope/">simple oscilloscope</a>.  For this post, I wanted to demonstrate the <a href="https://code.google.com/p/u8glib/" target="_blank">u8glib</a> console demo because I plan on using the GLCD to debug some of my projects and to provide a visual interface for experiments with the <a href="http://www.microchip.com/wwwproducts/en/RN171XV" target="_blank">Microchip RN-171-XV</a>.</p>
<p><a href="/2013/08/29/arduino-fio-graphical-lcd-console/"><img fetchpriority="high" decoding="async" src="/wp-content/uploads/2013/08/IMG_6922_cropped-1024x595.jpg" alt="IMG_6922_cropped" width="600" height="348" class="aligncenter size-large wp-image-3636" srcset="/wp-content/uploads/2013/08/IMG_6922_cropped-1024x595.jpg 1024w, /wp-content/uploads/2013/08/IMG_6922_cropped-300x174.jpg 300w" sizes="(max-width: 600px) 100vw, 600px" /></a></p>
<p>More information on the project, a video of it in operation, and its code after the break.<br />
<span id="more-3621"></span></p>
<p>A little while ago, I picked up an Arduino Fio (available on <a href="https://www.amazon.com/dp/B005K0O1PA/?tag=semifluidcom-20" target="_blank">Amazon.com</a>) and the mini12864 graphical LCD (available on <a href="http://dx.com/p/153821?Utm_rid=62305252&#038;Utm_source=affiliate" target="_blank">dx.com</a> &amp; <a href="http://www.amazon.com/dp/B009VILK8S/?tag=semifluidcom-20" target="_blank">Amazon.com</a>) for some microcontroller tinkering.  It turned out that a great graphical LCD library was available &#8212; <a href="https://code.google.com/p/u8glib/" target="_blank">u8glib</a> &#8212; that supports the mini12864&#8217;s controller (the <a href="http://www.lcd-module.de/eng/pdf/zubehoer/uc1701.pdf" target="_blank">UC1701</a>).</p>
<p>Using u8glib, the Arduino and the GLCD communicate flawlessly.  Thankfully, the mini12864 is 3.3V compatible, so there are no issues setting it up with the Arduino Fio and the simple SPI connection makes setup surprisingly easy.  As mentioned, I was able to use u8glib to port my oscilloscope code from CCS C to the Arduino:</p>
<ul>
<li><a href="/2013/05/28/arduino-fio-lcd-oscilloscope/">Arduino FIO LCD Oscilloscope</a></li>
<li><a href="/2013/08/02/arduino-fio-2-channel-lcd-oscilloscope/">Arduino FIO 2 Channel LCD Oscilloscope</a></li>
</ul>
<p>In addition to all of the functions u8glib provides, the library also comes with a nice little serial console/terminal demonstration program. The current u8glib console code can be found <a href="https://code.google.com/p/u8glib/source/browse/sys/arduino/Console/Console.pde" target="_blank">here</a>.</p>
<p>I added four functions that would allow me to quickly and easily debug my applications u8g_print, u8g_println, u8g_print_P, and u8g_println_P.  u8g_print allows one to print a character array, u8g_println does the same, but then adds a new line to the end of the string, u8g_print_P allows you to print a character array saved in program memory, and u8g_println_P does the same but adds a new line.  Here are the new functions:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/21422d7cec87ebe5ef7b.js?file=new_functions.ino"></script></p>
<p>This allowed me to create this simple demo of the GLCD debug console code:</p>
<p><center><br />
<iframe title="Arduino Fio GLCD Console Demo" width="648" height="365" src="https://www.youtube.com/embed/EAcKEw0Ciu4?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
</center></p>
<p>And last but not least, here is the Arduino Sketch used to produce the above output:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/21422d7cec87ebe5ef7b.js?file=u8glib_FioConsole.ino"></script></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO 2 Channel LCD Oscilloscope</title>
		<link>/2013/08/02/arduino-fio-2-channel-lcd-oscilloscope/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Fri, 02 Aug 2013 23:25:42 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[GLCD]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">http://semifluid.com/?p=3391</guid>

					<description><![CDATA[After using my Arduino Fio to make an Arduino LCD oscilloscope, I wanted to try adding a second channel. Using the single channel Arduino FIO LCD Oscilloscope code as a template, I modified the project and added a second channel. Here&#8217;s a short demonstration video of the new two channel project: Click through the break [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>After using my Arduino Fio to make an <a href="/2013/05/28/arduino-fio-lcd-oscilloscope/">Arduino LCD oscilloscope</a>, I wanted to try adding a second channel.  Using the single channel Arduino FIO LCD Oscilloscope code as a template, I modified the project and added a second channel.</p>
<p><a href="/2013/08/02/arduino-fio-2-channel-lcd-oscilloscope"><img loading="lazy" decoding="async" src="/wp-content/uploads/2013/08/Arduino-Fio-2-Channel-LCD-Oscilloscope-1024x576.jpg" alt="Arduino-Fio-2-Channel-LCD-Oscilloscope" width="600" height="337" class="aligncenter size-large wp-image-3525" srcset="/wp-content/uploads/2013/08/Arduino-Fio-2-Channel-LCD-Oscilloscope-1024x576.jpg 1024w, /wp-content/uploads/2013/08/Arduino-Fio-2-Channel-LCD-Oscilloscope-300x168.jpg 300w, /wp-content/uploads/2013/08/Arduino-Fio-2-Channel-LCD-Oscilloscope.jpg 1920w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Here&#8217;s a short demonstration video of the new two channel project:</p>
<p><center><br />
<iframe loading="lazy" title="Arduino FIO 2 Channel LCD Oscilloscope" width="648" height="486" src="https://www.youtube.com/embed/JH9s9POwMFg?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
</center></p>
<p>Click through the break to check out the code.<br />
<span id="more-3391"></span></p>
<p>The project used an Arduino Fio (available on <a href="https://www.amazon.com/dp/B005K0O1PA/?tag=semifluidcom-20" target="_blank">Amazon.com</a>) and the mini12864 128&#215;64 pixel graphical LCD (available on <a href="http://dx.com/p/153821?Utm_rid=62305252&#038;Utm_source=affiliate" target="_blank">dx.com</a> &amp; <a href="http://www.amazon.com/dp/B009VILK8S/?tag=semifluidcom-20" target="_blank">Amazon.com</a>).</p>
<p>The basic modification was to include a second set of variables that is used to store the second channel&#8217;s readings.  A more elegant solution would have been to make each variable an N-channel array (so that one could easily scale to more channels), but the low-resolution monochrome display really limits the possibilities, unfortunately.  In addition, the sampling rate for the single channel oscilloscope was already quite low (with a maximum sampling rate of approximately 28kHz), but two channels could allow for some interesting possibilities as long as one can deal with the slower acquisition speed.</p>
<p>The display refresh is triggered by a rising signal (useThreshold == 1) on the channel A input (analog pin 7, as defined by theAnalogPinA = 7), but you could easily modify the code to make this switchable so that either channel acts as the trigger. The code is very similar to my previous code, including the serial port parameter controls, so I recommend taking a look at that post first, if you have any questions: <a href="/2013/05/28/arduino-fio-lcd-oscilloscope/">Arduino FIO LCD Oscilloscope</a></p>
<p>As with the previous single channel project, you need to make sure that you have the <a href="https://code.google.com/p/u8glib/" target="_blank">u8glib</a> library installed to compile the code.</p>
<p>Here&#8217;s the Arduino sketch for the oscilloscope:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/e6cc9f132bc17ab97243.js"></script></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO LCD Oscilloscope</title>
		<link>/2013/05/28/arduino-fio-lcd-oscilloscope/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Tue, 28 May 2013 15:08:23 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[GLCD]]></category>
		<category><![CDATA[Programming]]></category>
		<guid isPermaLink="false">http://semifluid.com/?p=3376</guid>

					<description><![CDATA[It has been 7 years (!) since I posted my PIC18F2550 KS0108 Graphical LCD Oscilloscope code and schematics. I have long since taken the circuit apart, sold my PIC microcontrollers, and moved on in my life (as one can surmise from my most recent posts detailing my graduate and postdoctoral work). However, I still get [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>It has been 7 years (!) since I posted my <a href="http://semifluid.com/2006/08/21/pic18f2550-ks0108-graphical-lcd-oscilloscope/">PIC18F2550 KS0108 Graphical LCD Oscilloscope</a> code and schematics.  I have long since taken the circuit apart, sold my PIC microcontrollers, and moved on in my life (as one can surmise from my most recent posts detailing my graduate and postdoctoral work).  However, I still get inquiries about the Microchip PIC oscilloscope, so I decided to recreate it using a simpler setup using my Arduino Fio.</p>
<p><a href="/2013/05/28/arduino-fio-lcd-oscilloscope/"><img loading="lazy" decoding="async" src="/wp-content/uploads/2013/05/IMG_4199-1024x682.jpg" alt="IMG_4199" width="600" height="399"  class="aligncenter size-large wp-image-3428" srcset="/wp-content/uploads/2013/05/IMG_4199-1024x682.jpg 1024w, /wp-content/uploads/2013/05/IMG_4199-300x200.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Here&#8217;s a short teaser video just to show that, yes, it works (going through a couple different sine wave frequencies, some random noise, etc. just to illustrate it working):</p>
<p><center><br />
<iframe loading="lazy" title="Arduino FIO LCD Oscilloscope - Teaser" width="648" height="365" src="https://www.youtube.com/embed/Sa-n04G7uA8?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
</center></p>
<p>Click through the break to get more information on the setup.<br />
<span id="more-3376"></span></p>
<p>I used an <a href="http://arduino.cc/en/Main/ArduinoBoardFio" target="_blank">Arduino Fio</a> board that I picked up from SparkFun.com (available at <a href="https://www.amazon.com/dp/B005K0O1PA/?tag=semifluidcom-20" target="_blank">Amazon.com</a>) and a small SPI graphical LCD board that I picked up for a few bucks at dx.com (SKU <a href="http://dx.com/p/153821?Utm_rid=62305252&#038;Utm_source=affiliate" target="_blank">153821</a>, also apparently available at <a href="http://www.amazon.com/dp/B009VILK8S/?tag=semifluidcom-20" target="_blank">Amazon.com</a>).  Since I don&#8217;t have a soldering iron here, I had to improvise with some female to female cables, also purchased from dx.com (SKU <a href="http://dx.com/p/151650?Utm_rid=62305252&#038;Utm_source=affiliate" target="_blank">151650</a>).</p>
<p>Dx.com describes the LCD as a 5V module, but the GLCD board designer&#8217;s page (mini12864) states otherwise (translated from Chinese via Google Translate):</p>
<blockquote><p>
Dimensions (L × W × H): 47mm × 38mm × 6mm (excluding pins)<br />
LCD sight (L × W): 33.7mm × 33.5mm<br />
LCD Active Display Area (L × W): 30.7mm × 23mm<br />
Backlight: White LED backlight bracket<br />
<strong>Operating voltage: 3.3V ~ 5.5V</strong> (built-in booster circuit, without pressure)<br />
Control IC: UC1701<br />
Display format: 128 × 64 rows<br />
Display: Blue on White
</p></blockquote>
<p>(<a href="http://semifluid.com/wp-content/uploads/2013/05/mini12864.pdf">mini12864 datasheet</a>)</p>
<p>So, I ordered one of the graphical LCDs, waited a few weeks for delivery (because dx.com is a notoriously slow shipper), received it, hooked it up, and tried out the following simple &#8220;Hello World&#8221; script to confirm that that the GLCD/FIO combo functioned:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/e8cda31673fc12509fd0.js?file=U8glib_Hello_World.ino"></script></p>
<p>And it worked!</p>
<p>Thankfully, the code I <a href="http://semifluid.com/2006/08/21/pic18f2550-ks0108-graphical-lcd-oscilloscope/">previously posted</a> was written in C, so porting to the Arduino took only a few minutes.  I took advantage of a great open source graphical LCD library (<a href="https://code.google.com/p/u8glib/" target="_blank">u8glib</a>) to handle the brunt of the work and added a serial port menu for manipulating the various display parameters.  One important difference between this project and the previous one: Since the Arduino Fio is a 3.3V device, it can only handle 0-3.3V inputs, limiting its utility as an &#8220;oscilloscope&#8221; without proper input protection/voltage scaling.  However, the code is extremely portable, meaning that you should be able to program any other Arduino and have it up-and-running in no time.</p>
<p><img loading="lazy" decoding="async" src="/wp-content/uploads/2013/05/IMG_4203-1024x682.jpg" alt="IMG_4203" width="600" height="399" class="aligncenter size-large wp-image-3429" srcset="/wp-content/uploads/2013/05/IMG_4203-1024x682.jpg 1024w, /wp-content/uploads/2013/05/IMG_4203-300x200.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></p>
<p>Here&#8217;s another 2 videos of the oscilloscope in action:</p>
<p><center><br />
<iframe loading="lazy" title="Arduino FIO LCD Oscilloscope - In action #1" width="648" height="365" src="https://www.youtube.com/embed/ZW6zGcie58w?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
</center></p>
<p><center><br />
<iframe loading="lazy" title="Arduino FIO LCD Oscilloscope - In action #2" width="648" height="365" src="https://www.youtube.com/embed/I8EWdJlqu-Y?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe><br />
</center></p>
<p>And finally, here&#8217;s the Arduino sketch for the oscilloscope:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/e8cda31673fc12509fd0.js?file=U8glib_Oscilloscope.ino"></script></p>
<p>Here&#8217;s the Arduino sketch for the square wave generator shown in the second video:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/e8cda31673fc12509fd0.js?file=arduino_square_wave_gen.ino"></script></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO DS18B20 Temperature Logger</title>
		<link>/2012/09/10/arduino-fio-ds18b20-temperature-logge/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Tue, 11 Sep 2012 00:04:51 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RF]]></category>
		<guid isPermaLink="false">http://semifluid.com/?p=1337</guid>

					<description><![CDATA[We have a Arduino Fio temperature logger, so now maybe we can increase the accuracy by adding an external temperature sensor. I have a couple of DS18B20 Programmable Resolution 1-Wire Digital Thermometers, so I thought, heck, let&#8217;s try one out! These temperature sensors are much more accurate out-of-the-box, so I don&#8217;t need to deal with [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>We have a <a href="http://semifluid.com/2012/09/09/arduino-fio-internal-voltmeter-and-thermometer">Arduino Fio temperature logger</a>, so now maybe we can increase the accuracy by adding an external temperature sensor.  I have a couple of <a href="http://datasheets.maximintegrated.com/en/ds/DS18B20.pdf">DS18B20</a> Programmable Resolution 1-Wire Digital Thermometers, so I thought, heck, let&#8217;s try one out!</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0246.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0246-1024x768.jpg" alt="" title="Arduino Fio DS18B20" width="600" height="450" class="aligncenter size-large wp-image-1357" srcset="/wp-content/uploads/2012/09/IMG_0246-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0246-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>These temperature sensors are much more accurate out-of-the-box, so I don&#8217;t need to deal with calibration (which I did need to worry about with the internal thermometer).  In addition, using separate, discrete components allows for the possibility of putting temperature sensors directly on/in whatever you may want to measure (rather than merely measuring the ambient temperature) and the potential for multiple temperature sensors with a single Arduino Fio (which are available at <a href="https://www.amazon.com/dp/B005K0O1PA/ref=as_li_ss_til?tag=semifluidcom-20&#038;camp=0&#038;creative=0&#038;linkCode=as4&#038;creativeASIN=B005K0O1PA&#038;adid=1KB2CEGSB0E1856D3DXX&#038;" target="_blank">Amazon.com</a>).</p>
<p><span id="more-1337"></span></p>
<p>So, the most important addition is the <a href="http://www.arduino.cc/playground/Learning/OneWire">Arduino OneWire.h library</a>.  Once we have that, all that&#8217;s needed is two simple declarations:</p>
<p>[code lang=&#8221;arduino&#8221;]<br />
#include &lt;OneWire.h&gt; // Get here: http://www.arduino.cc/playground/Learning/OneWire<br />
OneWire ds(DS18B20Data);<br />
[/code]</p>
<p>And a modified readTemp function:</p>
<p>[code lang=&#8221;arduino&#8221;]<br />
// See: http://www.arduino.cc/playground/Learning/OneWire<br />
float readTempDS18B20() {<br />
  int HighByte, LowByte, TReading, SignBit, Tc_100;<br />
  byte i;<br />
  byte present = 0;<br />
  byte data[12];<br />
  byte addr[8];<br />
  float resultTempFloat;</p>
<p>digitalWrite(DS18B20Power,HIGH);     // Power up the DS18B20<br />
  delay(250);</p>
<p>ds.search(addr);<br />
  if ( OneWire::crc8( addr, 7) != addr[7]) {<br />
      return 0.0;                      // CRC is not valid!<br />
  }</p>
<p>ds.reset();<br />
  ds.select(addr);<br />
  ds.write(0x44,1);                   // Start conversion, with parasite power on at the end</p>
<p>delay(1000);                        // Maybe 750ms is enough, maybe not<br />
                                      // We might do a ds.depower() here,<br />
                                      // but the reset will take care of it.</p>
<p>present = ds.reset();<br />
  ds.select(addr);<br />
  ds.write(0xBE);                     // Read Scratchpad</p>
<p>for ( i = 0; i &lt; 9; i++) {          // we need 9 bytes<br />
    data[i] = ds.read();<br />
  }<br />
  LowByte = data[0];<br />
  HighByte = data[1];<br />
  TReading = (HighByte &lt;&lt; 8) + LowByte;<br />
  SignBit = TReading &amp; 0x8000;        // Test most sig bit<br />
  if (SignBit)                        // Negative<br />
  {<br />
    TReading = (TReading ^ 0xffff) + 1;    // Take 2&#8217;s comp<br />
  }</p>
<p>ds.reset_search();<br />
  digitalWrite(DS18B20Power,LOW);     // Turn off DS18B20</p>
<p>resultTempFloat = (float) (6 * TReading) + TReading / 4;  // Multiply by (100 * 0.0625) or 6.25<br />
  resultTempFloat = resultTempFloat/100;<br />
  resultTempFloat = resultTempFloat * 1.8 + 32.0;  // Convert to F<br />
  return resultTempFloat;<br />
}<br />
[/code]</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0247.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0247-1024x768.jpg" alt="" title="Arduino Fio DS18B20 Close-up" width="600" height="450" class="aligncenter size-large wp-image-1358" srcset="/wp-content/uploads/2012/09/IMG_0247-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0247-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>And we are ready to read!  Note that the measurement times are a bit longer (I measured ~75 seconds in between transmissions) because of the 1 second settling time for the DS18B20.  Here is some example output from <a href="https://ttssh2.osdn.jp/index.html.en">TeraTerm</a> (I measured the ambient temperature for measurements 1-10, then put my thumb onto the DS18B20 for measurements 11 &amp; 12, and then allowed the DS18B20 to return to ambient for readings 13-20):</p>
<p>[code gutter=&#8221;false&#8221;]<br />
ª       0       0       0<br />
~<br />
 Aª     1       3.303   71.70<br />
~<br />
 Aª     2       3.303   71.14<br />
~<br />
 @ª     3       3.303   71.22<br />
~<br />
 @ª     4       3.303   71.07<br />
~<br />
 ?ª     5       3.303   71.30<br />
~<br />
 @ª     6       3.303   70.95<br />
~<br />
 @ª     7       3.303   71.26<br />
~<br />
 ?ª     8       3.303   71.60<br />
~<br />
 ?ª     9       3.303   71.35<br />
~<br />
 0ª     10      3.303   71.01<br />
~<br />
 7ª     11      3.303   77.35<br />
~<br />
 6ª     12      3.303   77.35<br />
~<br />
 Aª     13      3.303   73.72<br />
~<br />
 Aª     14      3.303   72.14<br />
~<br />
 Aª     15      3.303   71.66<br />
~<br />
 Aª     16      3.303   71.49<br />
~<br />
 Aª     17      3.303   71.27<br />
~<br />
 Aª     18      3.303   71.40<br />
~<br />
 Aª     19      3.303   71.23<br />
~<br />
 Aª     20      3.303   70.91<br />
[/code]</p>
<p>I stored the data for another 40 readings, cut out all of the trash data between the carriage returns (deliminating the readings) and sync characters (which visually show up as &#8220;ª&#8221; in TeraTerm), removed the initial sync reading, and <a href="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyDS18B20.nb">plotted the temperature data in Mathematica</a> (voltage was constant):</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyDS18B20.png"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyDS18B20-300x177.png" alt="" title="SuperSleepyDS18B20" width="300" height="177" class="aligncenter size-medium wp-image-1347" srcset="/wp-content/uploads/2012/09/SuperSleepyDS18B20-300x177.png 300w, /wp-content/uploads/2012/09/SuperSleepyDS18B20.png 360w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Compare to the temperature results of the <a href="http://semifluid.com/2012/09/09/arduino-fio-internal-voltmeter-and-thermometer">Arduino Fio internal temperature sensor</a>:</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyTempAndVolts.png"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyTempAndVolts-300x177.png" alt="" title="SuperSleepyTempAndVolts" width="300" height="177" class="aligncenter size-medium wp-image-1334" srcset="/wp-content/uploads/2012/09/SuperSleepyTempAndVolts-300x177.png 300w, /wp-content/uploads/2012/09/SuperSleepyTempAndVolts.png 360w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0248.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0248-1024x768.jpg" alt="" title="Arduino Fio DS18B20 DOF" width="600" height="450" class="aligncenter size-large wp-image-1359" srcset="/wp-content/uploads/2012/09/IMG_0248-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0248-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Here&#8217;s all of the Arduino Fio SuperSleepyDS18B20 code:</p>
<p>[code lang=&#8221;arduino&#8221;]<br />
/*<br />
 * SuperSleepyDS18B20 SuperSleepyDS18B20.ino<br />
 * Steven A Cholewiak &#8211; www.semifluid.com<br />
 *<br />
 * This sketch takes advantage of the XBee&#8217;s hibernation mode as<br />
 * well as the Ardunio Fio&#8217;s Power Save Mode to grossly reduce power<br />
 * consumption.  It impliments a temperature logging IC (DS18B20)<br />
 * That has been connected to D3,D4,D5.  Provides a much more<br />
 * accurate temperature measurement than the internal thermometer<br />
 * (see SuperSleepyTempAndVolts.ino).<br />
 *<br />
 */</p>
<p>#include &lt;avr/wdt.h&gt;<br />
#include &lt;avr/sleep.h&gt;<br />
#include &lt;avr/interrupt.h&gt;<br />
#include &lt;OneWire.h&gt; // Get here: http://www.arduino.cc/playground/Learning/OneWire</p>
<p>const int ledPin = 13;<br />
const int DS18B20Ground = 3;           // DS18B20 Pin 1<br />
const int DS18B20Data = 4;             // DS18B20 Pin 2 NOTE: 4.7k pull-up resistor required between data and power<br />
const int DS18B20Power = 5;            // DS18B20 Pin 3<br />
const int XBeeSleep = 2;               // Connect to XBee DTR<br />
const int waitPeriod = 8;              // Number of 8 second cycles before waking<br />
                                       // up XBee and sending data (8*8 = 64 seconds)</p>
<p>OneWire ds(DS18B20Data);               // Setup DS18S20 Temperature chip I/O</p>
<p>// See: http://code.google.com/p/tinkerit/wiki/SecretVoltmeter<br />
float readVcc() {<br />
  signed long resultVcc;<br />
  float resultVccFloat;<br />
  // Read 1.1V reference against AVcc<br />
  ADMUX = _BV(REFS0) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);<br />
  delay(10);                           // Wait for Vref to settle<br />
  ADCSRA |= _BV(ADSC);                 // Convert<br />
  while (bit_is_set(ADCSRA,ADSC));<br />
  resultVcc = ADCL;<br />
  resultVcc |= ADCH&lt;&lt;8;<br />
  resultVcc = 1126400L / resultVcc;    // Back-calculate AVcc in mV<br />
  resultVccFloat = (float) resultVcc / 1000.0; // Convert to Float<br />
  return resultVccFloat;<br />
}</p>
<p>// See: http://www.arduino.cc/playground/Learning/OneWire<br />
float readTempDS18B20() {<br />
  int HighByte, LowByte, TReading, SignBit, Tc_100;<br />
  byte i;<br />
  byte present = 0;<br />
  byte data[12];<br />
  byte addr[8];<br />
  float resultTempFloat;</p>
<p>digitalWrite(DS18B20Power,HIGH);     // Power up the DS18B20<br />
  delay(250);</p>
<p>ds.search(addr);<br />
  if ( OneWire::crc8( addr, 7) != addr[7]) {<br />
      return 0.0;                      // CRC is not valid!<br />
  }</p>
<p>ds.reset();<br />
  ds.select(addr);<br />
  ds.write(0x44,1);                   // Start conversion, with parasite power on at the end</p>
<p>delay(1000);                        // Maybe 750ms is enough, maybe not<br />
                                      // We might do a ds.depower() here,<br />
                                      // but the reset will take care of it.</p>
<p>present = ds.reset();<br />
  ds.select(addr);<br />
  ds.write(0xBE);                     // Read Scratchpad</p>
<p>for ( i = 0; i &lt; 9; i++) {          // we need 9 bytes<br />
    data[i] = ds.read();<br />
  }<br />
  LowByte = data[0];<br />
  HighByte = data[1];<br />
  TReading = (HighByte &lt;&lt; 8) + LowByte;<br />
  SignBit = TReading &amp; 0x8000;        // Test most sig bit<br />
  if (SignBit)                        // Negative<br />
  {<br />
    TReading = (TReading ^ 0xffff) + 1;    // Take 2&#8217;s comp<br />
  }</p>
<p>ds.reset_search();<br />
  digitalWrite(DS18B20Power,LOW);     // Turn off DS18B20</p>
<p>resultTempFloat = (float) (6 * TReading) + TReading / 4;  // Multiply by (100 * 0.0625) or 6.25<br />
  resultTempFloat = resultTempFloat/100;<br />
  resultTempFloat = resultTempFloat * 1.8 + 32.0;  // Convert to F<br />
  return resultTempFloat;<br />
}</p>
<p>void sleepNow()<br />
{<br />
  /* Now is the time to set the sleep mode. In the Atmega8 datasheet<br />
   * http://www.atmel.com/dyn/resources/prod_documents/doc2486.pdf on page 35<br />
   * there is a list of sleep modes which explains which clocks and<br />
   * wake up sources are available in which sleep modus.<br />
   *<br />
   * In the avr/sleep.h file, the call names of these sleep modus are to be found:<br />
   *<br />
   * The 5 different modes are:<br />
   *     SLEEP_MODE_IDLE         -the least power savings<br />
   *     SLEEP_MODE_ADC<br />
   *     SLEEP_MODE_PWR_SAVE<br />
   *     SLEEP_MODE_STANDBY<br />
   *     SLEEP_MODE_PWR_DOWN     -the most power savings<br />
   *<br />
   *  the power reduction management &lt;avr/power.h&gt;  is described in<br />
   *  http://www.nongnu.org/avr-libc/user-manual/group__avr__power.html<br />
   */</p>
<p>set_sleep_mode(SLEEP_MODE_PWR_SAVE); // Sleep mode is set here</p>
<p>sleep_enable();                      // Enables the sleep bit in the mcucr register<br />
                                       // so sleep is possible. just a safety pin<br />
  sleep_mode();                        // Here the device is actually put to sleep!!<br />
                                       // THE PROGRAM CONTINUES FROM HERE AFTER WAKING UP<br />
  sleep_disable();                     // Dirst thing after waking from sleep:<br />
                                       // disable sleep&#8230;<br />
}</p>
<p>ISR (WDT_vect) {                       // WDT Wakeup<br />
  cli();<br />
  wdt_disable();<br />
  sei();<br />
}</p>
<p>// Variable Definition<br />
volatile int MeasurementID = 1;<br />
volatile int timeKeeper = 0;<br />
volatile float averageVcc = 0.0;<br />
volatile float averageTemp = 0.0;</p>
<p>void setup(void) {<br />
  Serial.begin(57600);<br />
  pinMode(DS18B20Ground, OUTPUT);<br />
  digitalWrite(DS18B20Ground, 0);      // Ground the DS18B20 GND pin<br />
  pinMode(XBeeSleep, OUTPUT);</p>
<p>digitalWrite(XBeeSleep, 0);          // Enable XBee<br />
  digitalWrite(ledPin, 1);             // Turn on Notification LED<br />
  delay(4000);                         // 4 second LED blink, good for wireless programming<br />
  digitalWrite(ledPin, 0);             // Turn off Notification LED</p>
<p>Serial.write( 170 );                 // Sync Byte<br />
  Serial.print( &#8216;\t&#8217; );                // Tab<br />
  Serial.print( &#8216;0&#8217; );                 // Reading # (0)<br />
  Serial.print( &#8216;\t&#8217; );                // Tab<br />
  Serial.print( &#8216;0&#8217; );                 // Voltage (unmeasured, so 0)<br />
  Serial.print( &#8216;\t&#8217; );                // Tab<br />
  Serial.println( &#8216;0&#8217; );               // Temperature (unmeasured, so 0)</p>
<p>digitalWrite(XBeeSleep, 1);          // Disable XBee<br />
}</p>
<p>void loop(void) {<br />
  averageVcc = averageVcc + (float) readVcc();<br />
  averageTemp = averageTemp + (float) readTempDS18B20();</p>
<p>if (timeKeeper == (waitPeriod-1)) {  // Transmit every 8*8 (64) seconds<br />
    digitalWrite(XBeeSleep, 0);        // Enable XBee<br />
    delay(50);                         // Wait for XBee Wakeup</p>
<pre><code>Serial.write( 170 );               // Sync Byte
Serial.print( '\t' );
Serial.print( MeasurementID, DEC );
Serial.print( '\t' );
Serial.print( (float) (averageVcc/waitPeriod) , 3);
Serial.print( '\t' );
Serial.println( (float) (averageTemp/waitPeriod) , 2);
MeasurementID++;

digitalWrite(ledPin, 1);           // Turn on Notification LED
delay(50);                         // Blink LED
digitalWrite(ledPin, 0);           // Turn off Notification LED

digitalWrite(XBeeSleep, 1);        // Disable XBee

averageVcc = 0;                    // Reset voltage for new measurements
averageTemp = 0;                   // Reset temperature for new measurements
timeKeeper = 0;
</code></pre>
<p>} else {                             // Add a reading to the average<br />
    digitalWrite(ledPin, 1);           // Turn on Notification LED<br />
    delay(1);                          // Blink LED very quickly<br />
    digitalWrite(ledPin, 0);           // Turn off Notification LED</p>
<pre><code>timeKeeper++;
</code></pre>
<p>}</p>
<p>wdt_reset();                         // Get ready to go to sleep&#8230;<br />
  watchdogEnable();                    // Turn on the watchdog timer<br />
  sleepNow();                          // Go to sleep, watchdog timer will wake later<br />
}</p>
<p>void watchdogEnable() {                // Turn on watchdog timer; interrupt mode every 8.0s<br />
  cli();<br />
  MCUSR = 0;<br />
  WDTCSR |= B00011000;<br />
  //WDTCSR = B01000111;                // 2 Second Timeout<br />
  //WDTCSR = B01100000;                // 4 Second Timeout<br />
  WDTCSR = B01100001;                  // 8 Second Timeout<br />
  sei();<br />
}<br />
[/code]</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO Internal Voltmeter and Thermometer</title>
		<link>/2012/09/09/arduino-fio-internal-voltmeter-and-thermometer/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Sun, 09 Sep 2012 19:06:15 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RF]]></category>
		<guid isPermaLink="false">http://semifluid.com/?p=1324</guid>

					<description><![CDATA[Let&#8217;s extend the low power Ardunio Fio + Xbee setup that I previously blogged about. &#160;I wanted to see if I could create a simple wireless temperature sensor that could allow for long(er) term logging. &#160;Interestingly, the&#160;ATmega328P&#160;on the Arduino Fio has both a &#8220;secret&#8221; internal thermometer and internal voltmeter, meaning that I could (potentially) create [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>Let&#8217;s extend the low power Ardunio Fio + Xbee setup that I <a href="http://semifluid.com/2012/09/07/arduino-fio-low-power-setup/">previously blogged about</a>. &nbsp;I wanted to see if I could create a simple wireless temperature sensor that could allow for long(er) term logging. &nbsp;Interestingly, the&nbsp;<a href="http://www.atmel.com/devices/atmega328p.aspx">ATmega328P</a>&nbsp;on the Arduino Fio has both a &#8220;secret&#8221; <a href="http://code.google.com/p/tinkerit/wiki/SecretThermometer">internal thermometer</a> and <a href="http://code.google.com/p/tinkerit/wiki/SecretVoltmeter">internal voltmeter</a>, meaning that I could (potentially) create a wireless sensor with no external additional external components (other than the Fio, XBee, and battery).</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0243.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0243-1024x768.jpg" alt="" title="Arduino Fio Internal Thermometer" width="600" height="450" class="aligncenter size-large wp-image-1352" srcset="/wp-content/uploads/2012/09/IMG_0243-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0243-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>So, taking advantage of the available hardware and the code available, I went about creating a wireless  temperature logger using an Arduino Fio (available from <a href="https://www.amazon.com/dp/B005K0O1PA/ref=as_li_ss_til?tag=semifluidcom-20&#038;camp=0&#038;creative=0&#038;linkCode=as4&#038;creativeASIN=B005K0O1PA&#038;adid=1KB2CEGSB0E1856D3DXX&#038;" target="_blank">Amazon.com</a>) and two XBees (one for the Fio and one for the coordinator).</p>
<p><span id="more-1324"></span></p>
<p>I already have code for a very low power logger setup that takes advantage of the Arduino Fio&#8217;s sleep mode as well as the XBee&#8217;s hibernation mode (see <a href="http://semifluid.com/2012/09/07/arduino-fio-low-power-setup/">here</a>). &nbsp;So, all I needed to do was to add the thermometer and voltmeter code that <a href="http://code.google.com/p/tinkerit/">tinkerit</a> documented.</p>
<p>Here is their <a href="http://code.google.com/p/tinkerit/wiki/SecretThermometer">internal thermometer</a> example code:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/9e51a0a6c3bcc8ff3871.js?file=readTemp.ino"></script></p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0244.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0244-1024x768.jpg" alt="" title="Arduino Fio Internal Thermometer Close-up" width="600" height="450" class="aligncenter size-large wp-image-1353" srcset="/wp-content/uploads/2012/09/IMG_0244-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0244-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>I modified the readTemp() function so that it returned a &#8220;human-readable&#8221; float in Fahrenheit (my local method of measuring temperature).  In addition, I added a small calculation to return a more accurate temperature (calibrated against a thermometer at my house).  If you want to calibrate the internal thermometer, put the Arduino Fio into a glass of ice water (I recommend putting it into a plastic bag and vacuuming out as much air as possible!), measure the values it returns, then put it into a cup of hot water, of known temperature, and measure the values it returns.  It would be best to have multiple measurements along a series of temperatures, confirmed with a pre-calibrated thermometer (i.e., mercury thermometer).  After making the measurements, you can fit a linear model (i.e., best fit line) to the data to get the slope and y-intercept for your device.</p>
<p><script src="https://gist.github.com/OrganicIrradiation/9e51a0a6c3bcc8ff3871.js?file=readTemp_human.ino"></script></p>
<p>I also added their <a href="http://code.google.com/p/tinkerit/wiki/SecretVoltmeter">internal voltmeter</a> example code:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/9e51a0a6c3bcc8ff3871.js?file=readVcc.ino"></script></p>
<p>The only modification was to convert the decimal to a float for (again) human readable format:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/9e51a0a6c3bcc8ff3871.js?file=readVcc_human.ino"></script></p>
<p>And last, but not least, I&#8217;ve been finding &#8220;trash data&#8221; that can be transmitted when the XBee is woken from hibernation, so I added a sync byte (DEC 170), that allows for easier parsing of the data.  Here is some example output from <a href="https://ttssh2.osdn.jp/index.html.en">TeraTerm</a> (I measured the ambient temperature for measurements 1-10, then put my thumb onto the ATmega328P for measurements 11 &amp; 12, and then allowed the Arduino to return to ambient for readings 13-20):</p>
<p>[code gutter=&#8221;false&#8221;]<br />
ª       0       0       0<br />
~<br />
 ?ª     1       3.303   69.83<br />
~<br />
 ?ª     2       3.303   69.62<br />
~<br />
 ?ª     3       3.303   69.62<br />
~<br />
 @ª     4       3.303   69.41<br />
~<br />
 ?ª     5       3.303   69.41<br />
~<br />
 ?ª     6       3.303   69.83<br />
~<br />
 ?ª     7       3.303   69.41<br />
~<br />
 ?ª     8       3.303   68.78<br />
~<br />
 ?ª     9       3.303   69.20<br />
~<br />
 #ª     10      3.303   69.20<br />
~<br />
 &#8216;ª     11      3.303   72.35<br />
~<br />
 (ª     12      3.303   72.77<br />
~<br />
 #ª     13      3.303   72.14<br />
~<br />
 &gt;ª     14      3.303   72.35<br />
~<br />
 ?ª     15      3.303   70.88<br />
~<br />
 &gt;ª     16      3.303   70.25<br />
~<br />
 &gt;ª     17      3.303   69.62<br />
~<br />
 &gt;ª     18      3.303   69.41<br />
~<br />
 &gt;ª     19      3.303   69.41<br />
~<br />
 &gt;ª     20      3.303   68.36<br />
[/code]</p>
<p>Yes, I have poor circulation in my hands (hence only a 3 degree jump).  I stored the data for another 30 readings, cut out all of the trash data between the carriage returns (deliminating the readings) and sync characters (which visually show up as &#8220;ª&#8221; in TeraTerm), removed the initial sync reading, and <a href="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyTempAndVolts.nb">plotted the temperature data in Mathematica</a> (voltage was constant for the ~50 minutes while I wrote this post):</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyTempAndVolts.png"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/SuperSleepyTempAndVolts-300x177.png" alt="" title="SuperSleepyTempAndVolts" width="300" height="177" class="aligncenter size-medium wp-image-1334" srcset="/wp-content/uploads/2012/09/SuperSleepyTempAndVolts-300x177.png 300w, /wp-content/uploads/2012/09/SuperSleepyTempAndVolts.png 360w" sizes="auto, (max-width: 300px) 100vw, 300px" /></a></p>
<p>Nice!</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0245.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0245-1024x768.jpg" alt="" title="Arduino Fio Overall" width="600" height="450" class="aligncenter size-large wp-image-1354" srcset="/wp-content/uploads/2012/09/IMG_0245-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0245-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Here&#8217;s all of the Arduino Fio SuperSleepyTempAndVolts code:</p>
<p><script src="https://gist.github.com/OrganicIrradiation/9e51a0a6c3bcc8ff3871.js?file=SuperSleepyTempAndVolts.ino"></script></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Arduino FIO Low Power Setup</title>
		<link>/2012/09/07/arduino-fio-low-power-setup/</link>
		
		<dc:creator><![CDATA[Steven A. Cholewiak]]></dc:creator>
		<pubDate>Fri, 07 Sep 2012 21:39:31 +0000</pubDate>
				<category><![CDATA[Arduino]]></category>
		<category><![CDATA[Electronics]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[RF]]></category>
		<guid isPermaLink="false">/?p=624</guid>

					<description><![CDATA[As usually, I have been very sporadic in posting new/updated projects due to my prioritization of my doctoral work (i.e., not much time for fun little electronics projects!). &#160;However, I&#8217;ve been playing around with the Arduino Fio (available from Amazon.com) in my free time for a little while now, so I wanted to post some [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>As usually, I have been very sporadic in posting new/updated projects due to my prioritization of my doctoral work (i.e., not much time for fun little electronics projects!). &nbsp;However, I&#8217;ve been playing around with the <a href="http://arduino.cc/en/Main/ArduinoBoardFio">Arduino Fio</a> (available from <a href="https://www.amazon.com/dp/B005K0O1PA/ref=as_li_ss_til?tag=semifluidcom-20&#038;camp=0&#038;creative=0&#038;linkCode=as4&#038;creativeASIN=B005K0O1PA&#038;adid=1KB2CEGSB0E1856D3DXX&#038;" target="_blank">Amazon.com</a>) in my free time for a little while now, so I wanted to post some notes on a very low power usage setup that I was able to put together.</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0240.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0240-1024x768.jpg" alt="" title="Arduino Fio with XBee - Front Shot" width="600" height="450" class="aligncenter size-large wp-image-1293" srcset="/wp-content/uploads/2012/09/IMG_0240-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0240-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>As my free hobby time has dwindled, so has the time I&#8217;ve been able to devote to debugging programs written for my little Microchip PICs. &nbsp;So, given my limited time, I decided to dive right into Arduinos &#8212; which utilize a higher-level programming language, making things a little quicker and easier for me to tinker &#8212; and try to get some wireless communication working. &nbsp;After looking through the possibilities, I settled on the Arduino Fio. &nbsp;The Arduino Fio is a great little Arduino-compatible board that includes a socket for an XBee&nbsp;802.15.4 wireless module along with a <a href="http://en.wikipedia.org/wiki/Lithium-ion_polymer_battery">LiPo</a> plug and charger circuit.</p>
<p><span id="more-624"></span></p>
<p>I picked up a pair of Arduino Fios from sparkfun.com (my <a href="https://www.sparkfun.com/products/9712">older revision</a> was recently <a href="https://www.sparkfun.com/products/10116?">updated</a> with a newer battery charging IC), along with an <a href="https://www.sparkfun.com/products/8687">XBee Explorer USB</a> (to directly interface/program the XBee modules with my desktop computer) and 3 XBee XB24-AWI-001 modules&nbsp;(XBee 802.15.4 low-power modules with wire antennas).</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0242.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0242-1024x768.jpg" alt="" title="Arduino Fios" width="600" height="450" class="aligncenter size-large wp-image-1299" srcset="/wp-content/uploads/2012/09/IMG_0242-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0242-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>I may go into a bit more &#8220;nitty-gritty detail&#8221; for this post, but this is partially because I wanted to recreate all of the steps for this blog post (since I&nbsp;actually&nbsp;last worked on this about a year ago). &nbsp;After receiving all of the components in the mail, I first updated XBee firmware using <a href="http://www.digi.com/support/productdetail?pid=3352&amp;osvid=57&amp;type=utilities">X-CTU</a> to 17ED using the firmware image from digi.com,&nbsp;<a href="ftp://ftp1.digi.com/support/firmware/update/xbee/xb24_15_4_10ed.zip">xb24_15_4_10ed.zip</a>&nbsp;(available here:&nbsp;<a href="ftp://ftp1.digi.com/support/firmware/update/xbee/">ftp://ftp1.digi.com/support/firmware/update/xbee/</a>). &nbsp;Digi has some <a href="http://ftp1.digi.com/support/firmware/Instructions%20for%20firmware%20upgrades.pdf">firmware upgrade instructions</a> that spell everything out.</p>
<p>After pressing &#8220;Restore&#8221; in X-CTU, the baud rate is reverted to 9600. BD (Interface Data Rate) needed to be changed from &#8220;3 &#8211; 9600&#8221; to &#8220;6 &#8211; 57600&#8221; for use with the Arduino Fio.&nbsp; Selecting &#8220;Always update firmware&#8221; and pressing &#8220;Write&#8221; updated the firmware and adjusted the baud rate.</p>
<p>I initially setup the programming and slave XBee modems using the funnel-1.0-r806&nbsp;XBeeConfigTool&nbsp;available at <a href="http://funnel.cc/Hardware/FIO">http://funnel.cc/Hardware/FIO</a>&nbsp;(direct link to the downloads <a href="http://code.google.com/p/funnel/downloads/list">here</a>, after unzipping, the config tool is in &#8220;funnel-1.0-r806\tools\XBeeConfigTool\application.windows64\XBeeConfigTool.exe&#8221;). &nbsp;Here are the specific settings for my setup of 3 XBees:</p>
<p>For the coordinator/programming XBee (<a href="http://semifluid.com/wp-content/uploads/2012/09/XBeeCoordinator.pro">X-CTU configuration profile</a>):</p>
<ul>
<li>Mode: Programming radio</li>
<li>Baud rate: 57600</li>
<li>PAN ID (The ID of the network these two devices will share) = 8484</li>
<li>MY ID (The unique ID of the device on the PAN network) = 0000</li>
<li>DL ID (Destination Address, FFFF means broadcast to all) = FFFF</li>
</ul>
<p>For the XBee slave 1 (<a href="http://semifluid.com/wp-content/uploads/2012/09/XBeeSlave1.pro">X-CTU configuration profile</a>):</p>
<ul>
<li>Mode: Arduino Fio radio</li>
<li>Baud rate: 57600</li>
<li>PAN ID (The ID of the network these two devices will share) = 8484</li>
<li>MY ID (The unique ID of the device on the PAN network) = 0001</li>
<li>DL ID (Destination Address, 0000 means send only to coordinator radio) = 0000</li>
</ul>
<p>For the XBee slave 2 (<a href="http://semifluid.com/wp-content/uploads/2012/09/XBeeSlave2.pro">X-CTU configuration profile</a>):</p>
<ul>
<li>Mode: Arduino Fio radio</li>
<li>Baud rate: 57600</li>
<li>PAN ID (The ID of the network these two devices will share) = 8484</li>
<li>MY ID (The unique ID of the device on the PAN network) = 0002</li>
</ul>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0241.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0241-1024x768.jpg" alt="" title="XBees" width="600" height="450" class="aligncenter size-large wp-image-1298" srcset="/wp-content/uploads/2012/09/IMG_0241-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0241-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>In order to use the XBEEs in low-power pin-controlled sleep mode, go into X-CTU and set SM (Sleep Mode) to &#8220;1 &#8211; PIN HIBERNATE&#8221;. &nbsp;Here&#8217;s the relevant information from the <a href="http://www.sparkfun.com/datasheets/Wireless/Zigbee/XBee-Datasheet.pdf">XBee datasheet</a>:</p>
<blockquote><p><strong>Pin Hibernate (SM = 1)</strong></p>
<ul>
<li>Pin/Host-controlled</li>
<li>Typical power-down current: &lt; 10 µA (@3.0 VCC)</li>
<li>Wake-up time: 13.2 msec</li>
</ul>
<p>Pin Hibernate Mode minimizes quiescent power (power consumed when in a state of rest or inactivity). This mode is voltage level-activated; when Sleep_RQ (pin 9) is asserted, the module will<br />
finish any transmit, receive or association activities, enter Idle Mode, and then enter a state of<br />
sleep. The module will not respond to either serial or RF activity while in pin sleep.</p>
<p>To wake a sleeping module operating in Pin Hibernate Mode, de-assert Sleep_RQ (pin 9). The<br />
module will wake when Sleep_RQ is de-asserted and is ready to transmit or receive when the CTS<br />
line is low. When waking the module, the pin must be de-asserted at least two &#8216;byte times&#8217; after<br />
CTS goes low. This assures that there is time for the data to enter the DI buffer.</p></blockquote>
<p>In addition, D3 (DIO3 Configuration) to &#8220;5 &#8211; DO HIGH&#8221; and IU (I/O Output Enable) to &#8220;0 &#8211; DISABLED&#8221;. &nbsp;I&#8217;ve attached the X-CTU configuration profiles for each of the XBees above. &nbsp;Now&#8230; onto the Arduino!</p>
<p>The DTR line on the Ardunio FIO is connected to pin 9 on the XBee (Sleep_RQ), so in order to take advantage of the pin hibernation, it needs to be pulled to ground and tied to the Arduino FIO D2 &nbsp;to control the XBee&#8217;s hibernation. &nbsp;I soldered a header onto the CTS and DTR pins on the FIO, connected D2 to DTR using a wire and pulled the line to ground using a resistor:</p>
<p><a href="http://semifluid.com/wp-content/uploads/2012/09/IMG_0239.jpg"><img loading="lazy" decoding="async" src="http://semifluid.com/wp-content/uploads/2012/09/IMG_0239-1024x768.jpg" alt="" title="Arduino Fio with XBee" width="600" height="450" class="aligncenter size-large wp-image-1291" srcset="/wp-content/uploads/2012/09/IMG_0239-1024x768.jpg 1024w, /wp-content/uploads/2012/09/IMG_0239-300x225.jpg 300w" sizes="auto, (max-width: 600px) 100vw, 600px" /></a></p>
<p>Finally, I took advantage of the Ardunio power-save&nbsp;sleep mode of the&nbsp;ATmega328P to lower the power usage further (see the&nbsp;ATmega328P&nbsp;datasheet). &nbsp;Here is some barebones code, where the Arduino puts the radio to sleep and wakes up every 8 seconds, checks if the  timekeeper variable has hit 8, and, if so, transmits an increasing variable (MeasurementID).  Basically, MeasurementID is transmitted every approximately 64 seconds.</p>
<p><script src="https://gist.github.com/OrganicIrradiation/b31a6699d3f7c41a9ae2.js"></script></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
