<?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>Sebastian Dehne&#039;s Blog</title>
	<atom:link href="http://www.dehnes.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dehnes.com</link>
	<description>Stuff I want to share</description>
	<lastBuildDate>Tue, 15 Feb 2011 18:50:56 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.5</generator>
		<item>
		<title>General purpose RF receiver</title>
		<link>http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/</link>
		<comments>http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/#comments</comments>
		<pubDate>Sun, 10 Oct 2010 18:51:29 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Electronics projects]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[433mhz]]></category>
		<category><![CDATA[HD44780 display]]></category>
		<category><![CDATA[PIC16F690]]></category>
		<category><![CDATA[receiver]]></category>
		<category><![CDATA[RF]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/?p=141</guid>
		<description><![CDATA[In this blog entry, I wrote about my sensor project which transmits it&#8217;s measurements via a 433Mhz wireless communication link. On this page I will describe the details of my self built receiver which receives data from this sensor. Goal To build a general purpose RF receiver module which receives messages from a 433 Mhz ]]></description>
			<content:encoded><![CDATA[<p>In <a href="http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/">this blog entry</a>, I wrote about my sensor project which transmits it&#8217;s measurements via a 433Mhz wireless communication link. On this page I will describe the details of my self built receiver which receives data from this sensor.</p>
<p><strong>Goal</strong></p>
<p>To build a general purpose RF receiver module which receives messages from a 433 Mhz wireless link (for example from my self built <a href="http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/">RF sensor</a>) and forward the received and decoded message to my Linux server via USB, where they are further processed.</p>
<p><strong>Scope</strong></p>
<ul>
<li>A <a href="http://www.rfsolutions.co.uk/acatalog/AM_Superhetrodyne_Receiver_Modules.html">AM-RRQ3-433</a> from RF-solutions is used to receive raw signals from the 433Mhz RF channel</li>
<li>For the USB interface, I&#8217;ll be <a href="http://www.ftdichip.com/Products/Cables/USBTTLSerial.htm">FTDI&#8217;s TTL-to-USB cable</a>, which is a ready-to-use solution for briding 5V TTL signals to RS232 emulation over USB. This enables the microcontroller talk directly to the linux box without any additional components. The linux kernel supports the FTDI chip, so it works out of the box. When this cable is plugged in, the RS232 port is reachable via <em>/dev/ttyUSB0</em>.</li>
<li>This cable also provides also a 5 Volt power source which will be used to power the entire receiver module.</li>
<li>For debugging purposes and possible other future features, the receiver module will be able to write to a HD44780 compatible display (I’ll be using the EAW162B-N3LW) which is attached using a 14 channel flat cable</li>
<li>A potentiometer is used to provide a <em>configurable</em> reference voltage for the purpose of noice filtering.</li>
<li>For the main processor, a PIC16F690 microcontroller will be used, which has a built-in crystal/clock and enough pins to support all interfaces described above.</li>
<li>For re-programming the firmware of the microcontroller without needing to remove the chip from the board, I&#8217;ll be using ICSP (In-Circuit Serial Programming)</li>
</ul>
<p><strong>Protocol</strong></p>
<p>All messages which this receiver module should be able to receive are encoded in my own RF protocol. This protocol is a kind of Ethernet protocol, it contains a <em>destination</em> address field, a <em>source</em> address field a <em>message length</em> and a <em>checksum</em> field. This protocol does not say anything about the kind of content which it carries. The syntax looks as follows:</p>
<table>
<tbody>
<tr>
<th>Position</th>
<th>Contains</th>
<th>Length in number of bits</th>
</tr>
<tr>
<td>1</td>
<td>destination (e.g. receiver&#8217;s address)</td>
<td>8</td>
</tr>
<tr>
<td>2</td>
<td>source (e.g. sender&#8217;s address)</td>
<td>8</td>
</tr>
<tr>
<td>3</td>
<td>Message&#8217;s length</td>
<td>8</td>
</tr>
<tr>
<td>4&#8230;N</td>
<td>message&#8217;s body</td>
<td>(N-3) * 8</td>
</tr>
<tr>
<td>N+1</td>
<td>CRC16 value</td>
<td>16</td>
</tr>
</tbody>
</table>
<p>When transmitted over RF; the message is encoded using <a href="http://en.wikipedia.org/wiki/Manchester_code">Manchester encoding</a> which is a self-clocking signal where each bit is actually sent using two bits. The length of a low-level bit is 0.5 ms which means that each logical bit takes 1 ms to transmit. At the beginning of each message, there is a start bit sent with the value of HIGH for 0.5ms.</p>
<p><strong>Understanding the raw RF signal</strong></p>
<p>The hardest part of this project was to translate the raw signal, which the <em>AM-RRQ3-433 </em>provides, to a usable message and disregard any noice and foreign signals.</p>
<p>The main idea here is that the RSSI port of the AM-RRQ3-433 module is used directly as a signal source (instead of the DATA-OUT port). The RSSI port is an analog port which provides both signal strength information and the information in the signal itself, whereas the DATA-OUT port is a digital port and only provides the digital signal received via RF. The DATA-OUT port will raise to HIGH (=5V) on the slightest noice on the RF channel, while the RSSI port will output a voltage which tells us about how strong the receive signal actually is. So by measuring the output voltage of the RSSI port using AD (analog-digital conversion), it is possible to both receive the signal itself and also the strength of this signal.</p>
<p>So when the microcontroller is receiving a signal from the RF module, a configurable reference voltage provides the minimum required voltage (signal strength) which the RSSI port has to output in order for the microcontroller to recognize this as a HIGH (1). Any voltages which the RSSI port outputs which are below this configurable reference voltage are seen as a LOW (0) by the microcontroller.</p>
<p>The next step after this noice filtering is to translate the received HIGH&#8217;s and LOW&#8217;s into a understandable message. In the attached source code, I&#8217;ve implemented a decoder for <em>manchester encoding</em> which is based on the <a href="http://en.wikipedia.org/wiki/Finite-state_machine">finite-state-machine</a> concept. A state machine is ideal to keep track of the current received bit and to determine which is the next expected next bit. As soon as a mismatch is found, a bit lasts too long (timeout case) or the max message length is exceeded, the state machine goes into error state and further reading is given up.</p>
<p>When the state-machine was able to decode an entire message, the next step is to calculate a CRC16 checksum over the entire message (all fields, except the CRC16 fields) and compare this value to the CRC16 fields in the message (The code I use to calculate the CRC16 checksum is from <a href="http://www.dattalo.com/technical/software/pic/crc16.asm">this</a> website). If the CRC16 values are the same, the next step is to determine whether this messages was intended for this receiver at all. This is done by comparing the destination address in the message against a locally hardcoded address.</p>
<p>In case the destination address matches, the message is then forwarded over the RS232 interface to the linux box. This is done by simply sending the message over a digital output port (port RB5, see below) of the microcontroller which is connected to the TTL-to-USB cable.</p>
<p><strong>The hardware</strong></p>
<p>All components will be placed on a PCB board which is placed in a plastic container with an antenna on top. Here is the schematic of the board:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver_schematic.png" rel="lightbox[141]"><img class="alignnone size-full wp-image-239" title="rf_receiver_schematic" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver_schematic.png" alt="" width="533" height="332" /></a></p>
<p>On the left side is the RF module (AM-RRQ3-433). The R1 is a 10KOhm potentiometer for configuring the RSSI reference voltage. U1 is the PIC16F690 microcontroller. In the right upper corner you find a 7&#215;2 flat cable connector which is the connection to the display. Below is the TTL-to-USB cable connector and in the right bottom corner is the ICSP connector.</p>
<p>Since I wanted to fit the board into a 59mm x 59mm box, I was forced to use a double layered PCB board. The bottom layer looks as follows:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/10/board_down.png" rel="lightbox[141]"><img class="alignnone size-full wp-image-237" title="board_down" src="http://www.dehnes.com/wp-content/uploads/2010/10/board_down.png" alt="" width="199" height="218" /></a></p>
<p>And the upper layer:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/10/board_up.png" rel="lightbox[141]"><img class="alignnone size-full wp-image-238" title="board_up" src="http://www.dehnes.com/wp-content/uploads/2010/10/board_up.png" alt="" width="199" height="218" /></a></p>
<p>The component at the top is the 2&#215;7 flat cable connector. The long vertical component to the right is the RF module (AM-RRQ3-433). The the PIC is in the middle and below it is the potentiometer. The 6 pin connector in the left bottom corner is the TTL-to-USB cable connector and the 6 pin connector in the right bottom corner is the ICSP connector. All other holes are <em>vias</em> which connect the bottom layer to the upper layer.</p>
<p>I developed the PCB using the same method as explained on my <a href="http://www.dehnes.com/152/2010/03/10/making-pcbs-for-the-wireless-temperature-and-humidity-sensor/">previous blog entry</a> with the additional feature of adding an aligned upper layer. After four attempts, I finally managed to developed a double sided board which works:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-01.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-223" title="rf_receiver-01" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-01.jpg" alt="" width="216" height="144" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-02.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-224" title="rf_receiver-02" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-02.jpg" alt="" width="216" height="144" /></a></p>
<p><strong>More pictures</strong></p>
<p><strong><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-03.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-225" title="rf_receiver-03" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-03.jpg" alt="" width="216" height="144" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-04.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-226" title="rf_receiver-04" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-04.jpg" alt="" width="216" height="144" /></a></strong></p>
<p><strong><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-05.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-227" title="rf_receiver-05" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-05.jpg" alt="" width="212" height="216" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-06.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-228" title="rf_receiver-06" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-06.jpg" alt="" width="216" height="156" /></a></strong></p>
<p>The antenna which I use is: <a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?WT.z_header=search_go&amp;lang=en&amp;site=us&amp;keywords=ANT-433-PW-QW-ND&amp;x=0&amp;y=0">ANT-433-PW-QW-ND</a>.</p>
<p><strong><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-07.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-229" title="rf_receiver-07" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-07.jpg" alt="" width="216" height="136" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-08.jpg" rel="lightbox[141]"><img class="alignnone size-full wp-image-230" title="rf_receiver-08" src="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-08.jpg" alt="" width="216" height="191" /></a></strong></p>
<p><strong><br />
</strong></p>
<p><strong>Downloads</strong></p>
<p>In case you want to build something like this yourself, here are all my project files, including the source for the program on the microcontroller. I developed this using the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en019469&amp;part=SW007002">Microchip MPLAB IDE</a>.</p>
<ul>
<li>The binary executable for the PIC16F690 microcontroller: <a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver-v1.hex">rf_receiver-v1.hex</a></li>
<li>The assembly source code: <a href="http://www.dehnes.com/wp-content/uploads/2010/10/rf_receiver_source-v1.rar">rf_receiver_source-v1.rar</a></li>
<li>The eagle project files: <a href="http://www.dehnes.com/wp-content/uploads/2010/10/RF_receiver_eagle_files-v1.rar">RF_receiver_eagle_files-v1.rar</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Landscape of Norway</title>
		<link>http://www.dehnes.com/204/2010/03/27/landscape-of-norway/</link>
		<comments>http://www.dehnes.com/204/2010/03/27/landscape-of-norway/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 11:49:43 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photographs]]></category>
		<category><![CDATA[Ålesund]]></category>
		<category><![CDATA[Dalsnibba]]></category>
		<category><![CDATA[Geiranger]]></category>
		<category><![CDATA[lofoten]]></category>
		<category><![CDATA[lom]]></category>
		<category><![CDATA[saltstrømmen]]></category>
		<category><![CDATA[svartisen]]></category>
		<category><![CDATA[tromsø]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/?p=204</guid>
		<description><![CDATA[A selection of photographs which were taken during summer 2009: Can you guess which picture was taken where]]></description>
			<content:encoded><![CDATA[<p>A selection of photographs which were taken during summer 2009:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-072.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-186" title="Stavkirke i Lom" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-072.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-074.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-187" title="small-SommerFerie2009-074" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-074.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-075.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-188" title="small-SommerFerie2009-075" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-075.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-094.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-189" title="small-SommerFerie2009-094" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-094.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-174.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-190" title="small-SommerFerie2009-174" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-174.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-201.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-191" title="small-SommerFerie2009-201" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-201.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-203.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-192" title="small-SommerFerie2009-203" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-203.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-209.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-193" title="small-SommerFerie2009-209" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-209.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-210.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-194" title="small-SommerFerie2009-210" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-210.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-236.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-196" title="small-SommerFerie2009-236" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-236.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-225.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-195" title="small-SommerFerie2009-225" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-225.jpg" alt="" width="557" height="117" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-241.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-197" title="small-SommerFerie2009-241" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-241.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-246.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-198" title="small-SommerFerie2009-246" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-246.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-339.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-199" title="small-SommerFerie2009-339" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-339.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-382.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-200" title="small-SommerFerie2009-382" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-382.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-392.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-201" title="small-SommerFerie2009-392" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-392.jpg" alt="" width="259" height="173" /></a> <a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-412.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-202" title="small-SommerFerie2009-412" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-412.jpg" alt="" width="259" height="173" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-451.jpg" rel="lightbox[204]"><img class="alignnone size-full wp-image-203" title="small-SommerFerie2009-451" src="http://www.dehnes.com/wp-content/uploads/2010/03/small-SommerFerie2009-451.jpg" alt="" width="518" height="135" /></a></p>
<p>Can you guess which picture was taken where?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/204/2010/03/27/landscape-of-norway/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Making PCB&#8217;s for the wireless temperature and humidity sensor</title>
		<link>http://www.dehnes.com/152/2010/03/10/making-pcbs-for-the-wireless-temperature-and-humidity-sensor/</link>
		<comments>http://www.dehnes.com/152/2010/03/10/making-pcbs-for-the-wireless-temperature-and-humidity-sensor/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 21:33:03 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Electronics projects]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[PCB UV-lamp etching]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/?p=152</guid>
		<description><![CDATA[In my previous post I showed you my wireless temperature and humidity sensor project which didn&#8217;t have a nice home yet. So today, I&#8217;m going to show you how I developed my own PCB to build a more useful and permanent version of my sensor, which I&#8217;ll place around my house to monitor the climate ]]></description>
			<content:encoded><![CDATA[<p>In my <a href="http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/">previous post</a> I showed you my wireless temperature and humidity sensor project which didn&#8217;t have a nice home yet. So today, I&#8217;m going to show you how I developed my own <a href="http://en.wikipedia.org/wiki/Printed_circuit_board">PCB</a> to build a more useful and permanent version of my sensor, which I&#8217;ll place around my house to monitor the climate inside and outside.</p>
<p>There are many different ways to fabricate you own PCB&#8217;s at home, the method I choose was to use photo-resist laminate since that way I could use my inkjet printer and didn&#8217;t have to buy a laser printer (for the toner-transfer method). The basic idea is that the board is covered with a thin film of a photosensitive layer, which prevents the etching solution to reach the copper. By exposing this thin film of photosensitive layer with UV light and developing it afterwards, the photoresist layer is removed everywhere where the copper is not supposed to be. I&#8217;ll show you how it&#8217;s done in more detail now.</p>
<p><strong>Building a UV Lamp</strong></p>
<p>First a UV lamp is needed. Instead of buying a rather expensive professional UV exposure box, I built my own using UV LEDs. I ordered some cheap LEDs from ebay which have a wavelength of about 400nm, a strength of 7000mcd, voltage drop of 3.4V and which require a current of 20mA. I arranged the LEDs is rows of 3 with a 100Ohm resistor such that I can use a 12V DC power supply. After soldering the LEDs in a 3 x 9 x 2 formation onto a prototype board, I mounted the lamp in a box as shown on the following pictures:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-001.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-153" title="UVLamp-001" src="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-001.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-002.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-154" title="UVLamp-002" src="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-002.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-003.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-155" title="UVLamp-003" src="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-003.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-004.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-156" title="UVLamp-004" src="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-004.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-005.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-157" title="UVLamp-005" src="http://www.dehnes.com/wp-content/uploads/2010/03/UVLamp-005.jpg" alt="" width="150" height="100" /></a></p>
<p>Result: a fully functional UV exposure box, which consumes about 0.39A @ 12V.</p>
<p><strong>Printing the art work</strong></p>
<p>Next step is to design and print the PCB layout. I used the wonderful program <a href="http://www.cadsoft.de/">Eagle</a> to do this. You can download my eagle project files (including all self created library files) at the button of this page. I sized the board in such a manner that it will fit into a plastic case which I have (see below). The final result is:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/board2.png" rel="lightbox[152]"><img class="alignnone size-full wp-image-159" title="board2" src="http://www.dehnes.com/wp-content/uploads/2010/03/board2.png" alt="" width="250" height="251" /></a></p>
<p>For the PCB to be a good as possible, it is crucial that your print is of good quality and has nice smooth lines. To achieve this, I exported the board layout from eagle using 1200 DPI and set the print quality to best. Then I used photoshop to actually print the file onto the transparent film (I used <a href="http://www.amazon.de/Pelikan-Transparentfolie-Tintenstrahldrucker-Transparenz-Farbwiedergabe/dp/B0002FY7DY">Transparency Film from Pelikan</a> for my standard HP inkjet printer) because it provides the possibility to print additional orientation marks. I used those orientation marks to align two prints on top of each other, to create an even thinker layer of black, which is supposed to stop the UV light from getting to the board.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-001.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-143" title="SensorPCB-001" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-001.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-004.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-146" title="SensorPCB-004" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-004.jpg" alt="" width="150" height="100" /></a></p>
<p><strong>Preparing the laminate</strong></p>
<p>Once the artwork is prepared and taped down onto a glass plate, I prepared the laminate; the actual boards. I measured the pieces and cut them out using my <a href="http://en.wikipedia.org/wiki/Dremel">Dremel</a>.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-002.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-144" title="SensorPCB-002" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-002.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-003.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-145" title="SensorPCB-003" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-003.jpg" alt="" width="150" height="100" /></a></p>
<p><strong>UV exposure</strong></p>
<p>Now the development can begin. To bring the layout onto the  laminate, the blue protection foil is removed from the laminate and the piece is placed under the glass plate with the art worked taped onto. The UV exposure box goes on top such that the UV light hits the art work first and then the photoresist layer on the laminate. Exposure time is about six minutes.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-005.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-147" title="SensorPCB-005" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-005.jpg" alt="" width="150" height="100" /></a></p>
<p>Once done, the exposed board is placed in a chemical solution (a photo resist developer) to remove the photoresist layer at those places where we don&#8217;t want any copper to be. The result looks like this.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-006.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-148" title="SensorPCB-006" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-006.jpg" alt="" width="150" height="100" /></a></p>
<p>The darker layer on top of the copper is the photoresist layer which will prevent the etching solution to reach the copper (and thus doesn&#8217;t get etched away).</p>
<p><strong>Etching the board</strong></p>
<p>The final step of making our PCB is to etch the copper which we don&#8217;t want away. The board is placed in a etching solution (natrium persulfate) at about 40 degrees for about 20 minutes or so. Once done, I drilled the holes using my Dremel and removed the remaining photoresist layer with nail polish remover. The finished PCB result looks like this:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-007.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-149" title="SensorPCB-007" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-007.jpg" alt="" width="150" height="100" /></a></p>
<p>At last, I soldered all components onto the board and fitted the board into a small plastic housing, which it will live in. The temperature and humidity sensor are clued on the outside of the case, such that they are in contact with the air outside. The finished sensor looks like this:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-008.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-150" title="SensorPCB-008" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-008.jpg" alt="" width="150" height="100" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-009.jpg" rel="lightbox[152]"><img class="alignnone size-full wp-image-151" title="SensorPCB-009" src="http://www.dehnes.com/wp-content/uploads/2010/03/SensorPCB-009.jpg" alt="" width="150" height="100" /></a></p>
<p><strong>Result</strong></p>
<p>I installed two sensors outside at places where the sun doesn&#8217;t reach them both at the same time. Using rrdtool, the following graph was generated by combining the data from the two sensors (assuming the coldest temperature reading is the correct one):</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/outside_temperature.png" rel="lightbox[152]"><img class="alignnone size-full wp-image-182" title="outside_temperature" src="http://www.dehnes.com/wp-content/uploads/2010/03/outside_temperature.png" alt="" width="251" height="155" /></a></p>
<p><strong>Downloads</strong></p>
<ul>
<li><a href="http://www.dehnes.com/wp-content/uploads/2010/03/climat_sensor_v4.zip">Eagle project files v4</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/152/2010/03/10/making-pcbs-for-the-wireless-temperature-and-humidity-sensor/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Dresden, Germany</title>
		<link>http://www.dehnes.com/137/2010/02/09/dresden/</link>
		<comments>http://www.dehnes.com/137/2010/02/09/dresden/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 21:01:32 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Photographs]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/?p=137</guid>
		<description><![CDATA[There were taken in November ]]></description>
			<content:encoded><![CDATA[<p>There were taken in November 2005:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/DresdenPanorama-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-135" title="DresdenPanorama-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/DresdenPanorama-border.jpg" alt="" width="432" height="118" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/Frauenkirche01_border-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-136" title="Frauenkirche01_border-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/Frauenkirche01_border-border.jpg" alt="" width="205" height="277" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/02/dresden4_border-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-134" title="dresden4_border-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/dresden4_border-border.jpg" alt="" width="368" height="251" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/dresden3_border-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-133" title="dresden3_border-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/dresden3_border-border.jpg" alt="" width="294" height="201" /></a><a href="http://www.dehnes.com/wp-content/uploads/2010/02/dresden2_border-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-132" title="dresden2_border-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/dresden2_border-border.jpg" alt="" width="368" height="251" /></a></p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/dresden1_border-border.jpg" rel="lightbox[137]"><img class="alignnone size-full wp-image-131" title="dresden1_border-border" src="http://www.dehnes.com/wp-content/uploads/2010/02/dresden1_border-border.jpg" alt="" width="190" height="277" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/137/2010/02/09/dresden/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Wireless temperature and humidity sensor</title>
		<link>http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/</link>
		<comments>http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 16:13:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Electronics projects]]></category>
		<category><![CDATA[Home automation]]></category>
		<category><![CDATA[433mhz]]></category>
		<category><![CDATA[humidity]]></category>
		<category><![CDATA[PIC16F690]]></category>
		<category><![CDATA[RF]]></category>
		<category><![CDATA[temperature]]></category>
		<category><![CDATA[wireless]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/?p=60</guid>
		<description><![CDATA[In the scope of my personal home automation project, it is vital to know the temperature and humidity in rooms and outside. Besides logging this information and presenting it on a screen or on my cell phone or something, it can be used to control heating, air conditioning or ventilation. With this in mind, I ]]></description>
			<content:encoded><![CDATA[<p>In the scope of my personal home automation project, it is vital to know the temperature and humidity in rooms and outside. Besides logging this information and presenting it on a screen or on my cell phone or something, it can be used to control heating, air conditioning or ventilation. With this in mind, I built my own temperature and humidity sensor, which transmits it&#8217;s measurements to my <a href="http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/">central receiver</a> (connected to my home-server) for further processing.</p>
<p>When designing and building this sensor, it was important to me to use cheap components, since I&#8217;ll be making at least 10 of them and spread them around the house. Another requirement was that the sensor should consume very little power, so that the battery would last for at least a year or so. A <a href="http://en.wikipedia.org/wiki/PIC_microcontroller">PIC</a> micro-controller will be the brain of the sensor.</p>
<p><strong>Wireless communication</strong></p>
<p>First challenge to overcome was how to implement the wireless communication part. There are many different RF modules out there with different features. High end modules will handle the entire protocol including error correction and even encrypt the communication if you want, all you need is to write your message into the RAM memory of those modules and leave the rest to them. The <a href="http://www.digi.com/products/wireless/point-multipoint/xbee-series1-module.jsp#overview">XBee</a> modules are such high end modules. Unfortunately, those modules are way too expensive for my project, so something cheaper was needed.</p>
<p>I decided to go for the 433Mhz band since this band has a large enough range to overcome in-door walls while still providing plenty of bandwidth for my relative small measurements. The transmitter module AM-RT4-433 and the receiver module AM-HRR3-433 from <a href="http://www.rfsolutions.co.uk/">RF Solutions</a> are most suitable for the job. They are relative inexpensive, but lack any kind of data encoding or error correction features. All this does is to either send HIGH or LOW (e.g. send nothing).</p>
<p>In order to be able to transmit any kind of data which is to be understood by the receiver, the bits needed to be encoded somehow (for example, how to transmit the value <code>11111111</code> when you only have HIGH and LOW? Send HIGH for x milliseconds?). Since there is only one communication channel (instead of two: one for data and one for the clock) and I didn&#8217;t want to worry about clock synchronization between the two end-points, I looked into using a so-called self-clocking signal. <a href="http://en.wikipedia.org/wiki/Manchester_code">Manchester encoding</a> is such an encoding algorithm; it provides both clock and content information at the same time.</p>
<p>But how to ensure reliability and error detection? At first, I wanted to use bi-directional communication in order to be able to send acknowledgements back to the sender, but this approach would also mean that the sender needs to be a receiver at the same time, which would have an unacceptable impact on power consumption (receiving data means you need to listen actively for incoming data). So the final strategy is to make the sensor a transmitter only, which simply sends it&#8217;s measurements at regular intervals. For error detected I decided to use <a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC16</a>.</p>
<p>The final protocol syntax which I was going to use looks like this. Each message (package) which is sent, consists of:</p>
<table>
<tbody>
<tr>
<th>Position</th>
<th>Contains</th>
<th>Length in number of bits</th>
</tr>
<tr>
<td>1</td>
<td>destination (e.g. receiver&#8217;s address)</td>
<td>8</td>
</tr>
<tr>
<td>2</td>
<td>source (e.g. sender&#8217;s address)</td>
<td>8</td>
</tr>
<tr>
<td>3</td>
<td>Message&#8217;s length</td>
<td>8</td>
</tr>
<tr>
<td>4&#8230;N</td>
<td>message&#8217;s body</td>
<td>(N-3) * 8</td>
</tr>
<tr>
<td>N+1</td>
<td>CRC16 value</td>
<td>16</td>
</tr>
</tbody>
</table>
<p>The receiver module (covered in <a href="http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/">this</a> article) is able understand the self-clocking signal and check&#8217;s the CRC16 for error detection before passing it onwards for further processing. The result is very usable, inexpensive and low power consuming wireless data transmission. The disadvantage with this approach is that it lacks any kind of security. Anyone can capture the signals and even send fake values to the receiver. Once those signals are going to be used to control something like heating or ventilation, a more secure communication channel is needed to prevent anyone in the neighborhood from doing anything nasty.</p>
<p><strong>Measuring temperature</strong></p>
<p>For temperature measurements I decided to simply use a thermistor together with the PIC&#8217;s internal 10 bits ADC (analog-to-digital converter). This solution is very cheap and by using a suitable thermistor, it is still possible to achieve a pretty good resolution of more than 0.1 degrees Celcius.</p>
<p>I calculated that a 10KOhm thermistor is suitable for in-door temperatures and a 4.7KOhm thermistor would give me the best resolution for common outside temperatures where I live. I choose for the <a href="http://www.epcos.com/inf/50/db/ntc_09/LeadedDisks__B57164__K164.pdf">K164</a> series from epcos. My approach is that the PIC micro-controller will measure the resistance through the sensor and send this value to the central receiver unit for the actual calculation to degrees Celcuis.</p>
<p><strong>Measuring humidity</strong></p>
<p>Humidity was a different subject. Most sensors available are capacitive based, which means that you need to measure <a href="http://en.wikipedia.org/wiki/Farad">farads</a> of the sensor. This can be done by generating a trial-angle wave signal (with the help of an <a href="http://en.wikipedia.org/wiki/Operational_amplifier">op-amp</a>) and measure the time it takes for the capacitive sensor to be charged.</p>
<p>A much simpler approach however is to use a resistive based sensor, which has the same approach as the thermistor sensor (measuring the resistance through the sensor). After a long search, I finally found such a sensor which fitted my budget, the H25K5A. The datasheet contains a lookup table to calculate the relative humidity at a given temperature. I decided it would be easiest to just send the raw ADC values (e.g. the measured resistance of the sensor) to the central RF receiver unit and calculate the relative humidity value using this table there.</p>
<p><strong>Schematic</strong></p>
<p>The following image shows the sensor schematic which I&#8217;ll be using.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/sensor_schema.png" rel="lightbox[60]"><img class="alignnone size-full wp-image-165" title="sensor_schema" src="http://www.dehnes.com/wp-content/uploads/2010/03/sensor_schema.png" alt="" width="432" height="200" /></a></p>
<p><em>B57164-K164</em> is the thermistor which I used and <em>R1</em> is the voltage devider resistor, which has the same value as the thermistor. By letting the PIC control the current flow through the sensor here as well, power can be saved during sleep mode.</p>
<p><em>H25K5A </em>is the humidity sensor and <em>R3</em> is the voltage divider resistor for which I found 220KOhm to be most suitable for in-door temperatures. Q1 is a N-channel MOSFET of type 2N7000 which is used to switch the humidity sensor &#8220;on&#8221; and &#8220;off&#8221;. Why? Since the goal is to consume as little as possible power, there should be no current flowing through the sensor when the PIC micro-controller is in sleep mode. By using this MOSFET, current flow through the sensor is only enabled when the PIC is taking a measurement. <em>R2</em> is a 10KOhm pull-down resistor.</p>
<p><em>C1</em> is a 100pF filter capacitor, <em>U1</em> is a <em>PIC16F690</em> micro controller and RT4-433.9RC is the wireless transmitter module.</p>
<p><strong>Battery &amp; Power consumption</strong></p>
<p>The basic idea is that the PIC micro-controller will sleep for most of the time and only wake for a fraction of a second to take the two measurements and transmit the results via the RF module, before going back to sleep again. The power consumption during the sleep mode turns out to be very low: 1.2 micro Ampere @ 3.2V = 3,84 micro Watt. This allows the usage of a small cell batter of type: CR2032. This battery should last for 20 years if the micro-controller would only be in sleep-mode. However, given the short moment of activity for taking a measurement (and thus more power consumption), the actual life-time will be somewhat shorter. I configured the sleep time to be 16 seconds. This way, three out of four measurements can be missed by the receiver and I still have one measurement per minute.</p>
<p><strong>The software</strong></p>
<p>You can download my assembly code for the pic micro controller here:</p>
<ul>
<li><a href="http://www.dehnes.com/wp-content/uploads/2010/02/rf_sensor-0.1.zip">rf_sensor v0.1</a></li>
</ul>
<p><code>config.inc</code> contains some configuration settings. <code>crc16.asm</code> contains the sub routine for calculating the CRC16 checksum. <code>rf_protocol_tx.asm</code> contains the code to transmit a message wireless. <code>display.asm</code> and <code>math.asm</code> are included but not used; they can be used to display measurements on a HD44780 compatible display connected to the PIC. A compiled binary <code>rf_sensor.hex</code> is included in the archive. To compile the code yourself, I recommend using <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en019469&amp;part=SW007002">Microchip MPLAB IDE</a>.</p>
<p><strong>The sensor on action</strong></p>
<p>The sensor components placed on a breadboard for testing:</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/sensor_prototype.jpg" rel="lightbox[60]"><img class="alignnone size-full wp-image-102" title="sensor_prototype" src="http://www.dehnes.com/wp-content/uploads/2010/02/sensor_prototype.jpg" alt="" width="360" height="311" /></a></p>
<p>The green item on the left is the RF transmitter module. The white plastic sensor between the RF module and the battery is the humidity sensor. The temperature sensor is the gray component which sticks out above the black PIC micro-controller.</p>
<p>The receiver unit (covered in <a href="http://www.dehnes.com/141/2010/10/10/general-purpose-rf-receiver/">this</a> article) is connected to my home server where a small perl script converts the raw values into degrees Celcius and relative humidity and stores those values into a database using <a href="http://oss.oetiker.ch/rrdtool/">rrdtool</a>. The first image shows the humidity in the bath room (watch the humidity raise as someone is using the shower):</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/03/bath_temperature.png" rel="lightbox[60]"><img class="alignnone size-full wp-image-181" title="bath_temperature" src="http://www.dehnes.com/wp-content/uploads/2010/03/bath_temperature.png" alt="" width="293" height="181" /></a></p>
<p><strong>What&#8217;s next</strong></p>
<p>The next step is <a href="http://www.dehnes.com/152/2010/03/10/making-pcbs-for-the-wireless-temperature-and-humidity-sensor/">to design a neat PCB</a> and select a small enclosure and fabricate 10 of those sensors, which I can place around the house and outside. But this will have to wait for the next blog post.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/60/2010/02/09/wireless-temperature-and-humidity-sensor/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Building your own IR Thermometer Part 1</title>
		<link>http://www.dehnes.com/4/2010/02/03/building-your-own-ir-thermometer-part1/</link>
		<comments>http://www.dehnes.com/4/2010/02/03/building-your-own-ir-thermometer-part1/#comments</comments>
		<pubDate>Wed, 03 Feb 2010 23:06:41 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Electronics projects]]></category>
		<category><![CDATA[infra-red]]></category>
		<category><![CDATA[IR]]></category>
		<category><![CDATA[PIC16F690]]></category>
		<category><![CDATA[temperature]]></category>

		<guid isPermaLink="false">http://www.dehnes.com/wordpress/?p=4</guid>
		<description><![CDATA[How about building your own infra-red (IR) Thermometer? Instead of buying a finished product, you might be interested in building your own IR Thermometer instead. This way, you can learn how it works and you are able to design it exactly the way you want it to be. For example, how about building wireless sensors which ]]></description>
			<content:encoded><![CDATA[<p><strong>How about building your own infra-red (IR) Thermometer?</strong></p>
<p>Instead of buying a finished product, you might be interested in building your own IR Thermometer instead. This way, you can learn how it works and you are able to design it exactly the way you want it to be. For example, how about building wireless sensors which transmit data to a central receiver unit?</p>
<p>In this article, I&#8217;ll show you the basics. Components which I&#8217;ll be using for this are:</p>
<ul>
<li>IR temperature sensor: I&#8217;ll be using the <a href="http://www.melexis.com/Sensor-ICs-Infrared-and-Optical/Infrared-Thermometers/MLX90614-615.aspx">MLX90614</a> (<a href="http://search.digikey.com/scripts/DkSearch/dksus.dll?Detail&amp;name=MLX90614ESF-AAA-ND">this</a> version to be precise). It has a range from -70 up to +380 C and a resolution of 0.02 C.</li>
<li>Microcontroller: I&#8217;ll be using a 8-bit microcontroller from Microchip: <a href="http://www.microchip.com/wwwproducts/Devices.aspx?dDocName=en023112">PIC16F690</a>, but the program included in this article can easily be ported to any other 8bit microcontroller.</li>
<li>Display: You can use any HD44780 compatible display; I&#8217;ll be using the EAW162B-N3LW</li>
</ul>
<p>You will also need a programmer (I recommend using the PICKit2) to write your program into the micro-controller and an oscilloscope might came in handy for analyzing and debugging. For source code development, I used the <a href="http://www.microchip.com/stellent/idcplg?IdcService=SS_GET_PAGE&amp;nodeId=1406&amp;dDocName=en019469&amp;part=SW007002">Microchip MPLAB IDE</a>, which you only need if you want to compile your own binary.</p>
<p><strong>The test setup</strong></p>
<p>To test the sensor and the assembly code, I use the following setup. A 9V battery is used for the power supply and the 78L05 voltage regulator converts this to a 5V power rail. If you rather want to use a 5V supply directly, you can of course skip the regulator. For the pull-up resistors R1 and R2 I choose 10KOhm. R3 is a 10KOhm potentiometer which is used to regulate the display contrast. R4 is needed for the LED background light built into the LCD display planet. You should check the datasheet of your display for the correct value. C1 and C2 are for filtering and have a value of 100nF.</p>
<p><a href="http://www.dehnes.com/wp-content/uploads/2010/02/ir_sensor_prototype.png" rel="lightbox[4]"><img class="alignnone size-full wp-image-47" title="ir_sensor_prototype" src="http://www.dehnes.com/wp-content/uploads/2010/02/ir_sensor_prototype.png" alt="" width="485" height="146" /></a></p>
<p>(Please note that the display module shown in the drawing is not the same one which I used for my setup)</p>
<p><strong>Reading the temperature from the sensor</strong></p>
<p>The IR sensor, which is a digital sensor with it&#8217;s own microcontroller on board, provides two temperature readings: A) the sensors own (body) temperature and B) the object-in-sight temperature, measured using infra-red. For this project, I&#8217;ll be reading and showing both values.</p>
<p>The sensor (when not in sleep mode) will constantly measure the current temperature and store the result into it&#8217;s own internal memory. The already calibrated and ready to use temperature measurements can then be fetched from the sensor&#8217;s memory using the <a href="http://en.wikipedia.org/wiki/System_Management_Bus">SMBus</a> protocol. Using the sensor&#8217;s documentation and my oscilloscope, I developed the assembly code needed to read the measurements from the sensor. The source-code for this is provided below and is located in the <code>smbus.asm</code> module.</p>
<p><strong>Converting the data to degrees Celcius</strong></p>
<p>In order to convert the temperature values received from the sensor to degrees celcius, the raw value has to be multiplied by 0.02 according to the <a href="http://www.melexis.com/Assets/IR_sensor_thermometer_MLX90614_Datasheet_5152.aspx">documentation</a>. The result is the temperature in degrees Kelvin with two decimal precision. Substract 273.15 from that and you have the temperature in degrees celcius. To do this calculation on the microcontroller, I first subtract 27315 (273.15 x 100) from the raw value and then divided the result by 100. This way, I don&#8217;t have to worry about the comma until the very last step. The code for this conversion can be found in <code>main.asm</code>. The code makes use of <a href="http://avtanski.net/projects/math/">this</a> excellent assembly math library.</p>
<p><strong>Showing the result</strong></p>
<p>I first sent the readings via the serial port (using rs232) to my PC, but I quickly realized that using this method doesn&#8217;t really promote the idea of making a portable thermometer. So I replaced the rs232 output with an LCD display (HD44780 based) instead. Both the rs232 code and the LCD code is included in the source-code package though and can be found in the <code>rs232.asm</code> and <code>display.asm</code> modules.</p>
<p><strong>Main loop</strong></p>
<p>Now, to see the thermometer in action, I created a tiny main loop in <code>main.asm</code> which clues together the above mentioned modules. It basically configures the microcontroller after power-on-reset and then goes into an infinitive loop performing: A) 1 second delay, B) read latest temperature from the sensor using the <code>smbus.asm</code> module, C) convert to degrees celcius and finally D) show the value on the display using <code>display.asm</code> module.</p>
<p><strong>The source &amp; binary</strong></p>
<p>Download the source code and the binary hex file (compiled for the PIC16F690) here:</p>
<ul>
<li><a title="ir_sensor-0.2.zip" href="http://www.dehnes.com/wp-content/uploads/2010/02/ir_sensor-0.2.zip" target="_self">ir_sensor-0.2.zip</a></li>
</ul>
<p>Sensor in action:</p>
<p><span class="youtube">
<object width="425" height="355">
<param name="movie" value="http://www.youtube.com/v/kinmQh4vWxQ?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" />
<param name="allowFullScreen" value="true" />
<param name="allowscriptaccess" value="always">
<embed src="http://www.youtube.com/v/kinmQh4vWxQ?color1=d6d6d6&amp;color2=f0f0f0&amp;border=0&amp;fs=1&amp;hl=en&amp;autoplay=0&amp;showinfo=0&amp;iv_load_policy=3&amp;showsearch=0&amp;rel=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="425" height="355"></embed>
</object>
</span><p><a href="http://www.youtube.com/watch?v=kinmQh4vWxQ">www.youtube.com/watch?v=kinmQh4vWxQ</a></p></p>
]]></content:encoded>
			<wfw:commentRss>http://www.dehnes.com/4/2010/02/03/building-your-own-ir-thermometer-part1/feed/</wfw:commentRss>
		<slash:comments>23</slash:comments>
		</item>
	</channel>
</rss>

