<?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"
	>

<channel>
	<title>Projects &#38; news from nuelectronics.com</title>
	<atom:link href="http://www.nuelectronics.com/estore/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.nuelectronics.com/estore</link>
	<description>Just another WordPress weblog</description>
	<pubDate>Tue, 26 Aug 2008 06:52:20 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
	<language>en</language>
			<item>
		<title>Ethernet Shield for Arduino - a Web client example</title>
		<link>http://www.nuelectronics.com/estore/?p=14</link>
		<comments>http://www.nuelectronics.com/estore/?p=14#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:47:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Arduino projects]]></category>

		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[ethernet]]></category>

		<category><![CDATA[php]]></category>

		<category><![CDATA[sensor network]]></category>

		<category><![CDATA[web client]]></category>

		<guid isPermaLink="false">http://www.nuelectronics.com/eblog/?p=14</guid>
		<description><![CDATA[Project note &#8212; Ethernet Shield for Arduino - a Web client example
This project shows how to implement a distributed sensor network by using the arduino and the ethernet shield.
 
1. Web Client concept
Since I published ethernet Shield web-server project note a few months ago [link], I&#8217;ve got a few emails about how to use the [...]]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><strong style="text-decoration: underline; font-style: italic;"><span style="color: #804040;"><span>Project note &#8212; Ethernet Shield for Arduino - a Web client example</span></span></strong></h2>
<p>This project shows how to implement a distributed sensor network by using the arduino and the ethernet shield.</p>
<p style="text-align: center;"><a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&amp;cPath=1&amp;products_id=4"> <img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/Etehrnet_shield_2.jpg" alt="Arduino Ethernet shield V1.0" /></a></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">1. Web Client concept</span></p>
<p style="text-align: justify;" align="left">Since I published ethernet Shield web-server project note a few months ago [link], I&#8217;ve got a few emails about how to use the Ethernet shield as a web client.  In a sense, a web client application is more appropriate for a small device such as the Ethernet shield on Arduino.  </p>
<p>Based on the TCP/IP protocol, it is the web client (such as a web browser) who initializes the TCP connections, requests data from or sends data to the web server. Therefore the ethernet shield running in web client mode can be used as a distributed sensor node in the network.  It can send periodic or interrupt driven sensor data to a web server.  The web server can then record, process and show the sensor data from one or multiple web client.</p>
<p>In this project, a web client application is devloped for the ethernet shield, which can send periodic data (such as temperature reading) or spontaneous data (such as infrared sensor data or switch press) to a webserver.  PHP scripts that used to save and show the data received on the websever are also developed.</p>
<p><span style="font-weight: bold;">2. Web Client TCP/IP implementation</span></p>
<p>The Web client TCP/IP protocol is implemented in the client_process() routine, which is called in the main Arduino sketch loop() routine.  The client process uses a state machine to control the TCP/IP protocol as shown in the following code segment &#8211;</p>
<pre class="codebox">void client_process ( void )
{
    uint16_t plen;
	uint8_t i;
    if (client_data_ready == 0)  return;     // nothing to send

	if(client_state == IDLE){   // initialize ARP
       es.ES_make_arp_request(buf, dest_ip);

	   client_state = ARP_SENT;
	   return;
	}

	if(client_state == ARP_SENT){

        plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

		// destination ip address was found on network
        if ( plen!=0 )
        {
            if ( es.ES_arp_packet_is_myreply_arp ( buf ) ){
                client_state = ARP_REPLY;
				syn_ack_timeout=0;
				return;
            }

		}
	        delay(10);
		syn_ack_timeout++;

		if(syn_ack_timeout== 100) {  //timeout, server ip not found
			client_state = IDLE;
			client_data_ready =0;
			syn_ack_timeout=0;
			return;
		}
    }

 // send SYN packet to initial connection
	if(client_state == ARP_REPLY){
		// save dest mac
		for(i=0; i&lt;6; i++){
			dest_mac[i] = buf[ETH_SRC_MAC+i];
		}

        es.ES_tcp_client_send_packet (
                       buf,
                       80,
                       1200,
                       TCP_FLAG_SYN_V,                 // flag
                       1,                                              // (bool)maximum segment size
                       1,                                              // (bool)clear sequence ack number
                       0,                                              // 0=use old seq, seqack : 1=new seq,seqack no data : new seq,seqack with data
                       0,                                              // tcp data length
		      dest_mac,
		      dest_ip
                       );

		client_state = SYNC_SENT;
	}
  // get new packet
  if(client_state == SYNC_SENT){
    plen = es.ES_enc28j60PacketReceive(BUFFER_SIZE, buf);

       // no new packet incoming
    if ( plen == 0 )
    {
        return;
    }

       // check ip packet send to avr or not?
       // accept ip packet only
    if ( es.ES_eth_type_is_ip_and_my_ip(buf,plen)==0){
		return;
    }

       // check SYNACK flag, after AVR send SYN server response by send SYNACK to AVR
    if ( buf [ TCP_FLAGS_P ] == ( TCP_FLAG_SYN_V | TCP_FLAG_ACK_V ) )
    {

               // send ACK to answer SYNACK

               es.ES_tcp_client_send_packet (
                       buf,
                       80,
                       1200,
                       TCP_FLAG_ACK_V,                 // flag
                       0,                                              // (bool)maximum segment size
                       0,                                              // (bool)clear sequence ack number
                       1,                                              // 0=use old seq, seqack : 1=new seq,seqack no data : new seq,seqack with data
                       0,                                              // tcp data length
						dest_mac,
						dest_ip
                       );
               // setup http request to server
               plen = gen_client_request( buf );
               // send http request packet
               // send packet with PSHACK
               es.ES_tcp_client_send_packet (
                                       buf,
                                       80,                                             // destination port
                                       1200,                                   // source port
                                       TCP_FLAG_ACK_V | TCP_FLAG_PUSH_V,                        // flag
                                       0,                                              // (bool)maximum segment size
                                       0,                                              // (bool)clear sequence ack number
                                       0,                                              // 0=use old seq, seqack : 1=new seq,seqack no data : &gt;1 new seq,seqack with data
                                       plen,                           // tcp data length
                                       dest_mac,
									   dest_ip
									   );
               return;
       }
       // after AVR send http request to server, server response by send data with PSHACK to AVR
       // AVR answer by send ACK and FINACK to server
       if ( buf [ TCP_FLAGS_P ] == (TCP_FLAG_ACK_V|TCP_FLAG_PUSH_V) )
       {
               plen = es.ES_tcp_get_dlength( (uint8_t*)&amp;buf );

               // send ACK to answer PSHACK from server
               es.ES_tcp_client_send_packet (
                                       buf,
                                       80,                                             // destination port
                                       1200,                                   // source port
                                       TCP_FLAG_ACK_V,                  // flag
                                       0,                                              // (bool)maximum segment size
                                       0,                                              // (bool)clear sequence ack number
                                       plen,                                           // 0=use old seq, seqack : 1=new seq,seqack no data : &gt;1 new seq,seqack with data
                                       0,                              // tcp data length
				      dest_mac,
				      dest_ip
               );;
               // send finack to disconnect from web server

               es.ES_tcp_client_send_packet (
                                       buf,
                                       80,                                             // destination port
                                       1200,                                   // source port
                                       TCP_FLAG_FIN_V|TCP_FLAG_ACK_V,                  // flag
                                       0,                                              // (bool)maximum segment size
                                       0,                                              // (bool)clear sequence ack number
                                       0,                                           // 0=use old seq, seqack : 1=new seq,seqack no data : &gt;1 new seq,seqack with data
                                       0,
										dest_mac,
										dest_ip
				);

               return;

       }
       // answer FINACK from web server by send ACK to web server
       if ( buf [ TCP_FLAGS_P ] == (TCP_FLAG_ACK_V|TCP_FLAG_FIN_V) )
       {
               // send ACK with seqack = 1
               es.ES_tcp_client_send_packet(

                                       buf,
                                       80,                                             // destination port
                                       1200,                                   // source port
                                       TCP_FLAG_ACK_V,                 // flag
                                       0,                                              // (bool)maximum segment size
                                       0,                                              // (bool)clear sequence ack number
                                       1,                                              // 0=use old seq, seqack : 1=new seq,seqack no data : &gt;1 new seq,seqack with data
                                       0,
									   dest_mac,
									   dest_ip
				);
			client_state = IDLE;		// return to IDLE state
			client_data_ready =0;		// client data sent
		}
  }
}</pre>
<p>The client data is generated in the gen_client_request routine.  The following example shows that a temperature reading is filled into the http buffer.  The keyword &#8220;pwd&#8221;, &#8220;client&#8221; and &#8220;status&#8221; are used for the server php script to identify the data that client sends.</p>
<pre class="codebox">uint16_t gen_client_request(uint8_t *buf )
{
	uint16_t plen;
	byte i;

	plen= es.ES_fill_tcp_data_p(buf,0, PSTR ( "GET /ethershield_log/save.php?pwd=secret&amp;client=" ) );
        for(i=0; client_ip[i]!='\0'; i++){
            buf[TCP_DATA_P+plen]=client_ip[i];
            plen++;
        }
        plen= es.ES_fill_tcp_data_p(buf,plen, PSTR ( "&amp;status=temperature-" ) );
        for(i=0; sensorData[i]!='\0'; i++){

                buf[TCP_DATA_P+plen]=sensorData[i];
                plen++;
        }	

	plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( " HTTP/1.0\r\n" ));
	plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "Host: 192.168.1.4\r\n" ));
	plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "User-Agent: AVR ethernet\r\n" ));
        plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "Accept: text/html\r\n" ));
	plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "Keep-Alive: 300\r\n" ));
	plen= es.ES_fill_tcp_data_p(buf, plen, PSTR ( "Connection: keep-alive\r\n\r\n" ));

	return plen;
}</pre>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">3. Web Server and PHP scripts</span></p>
<p style="text-align: justify;" align="left">To test the web client application, I set up a web server in my home LAN environment.  I used the <a href="http://www.wampserver.com/"> wampserver </a> package, which has Apache, PHP and MYSQL, in the windows.  The installation is straightforward, after installation you need to allow the client ip address to access your apache webserver by modifying the httpd.conf file.  For me, I just enable all my local ip addresses as &#8211;</p>
<pre class="codebox">

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #
#   onlineoffline tag - don't remove
    Order Deny,Allow
#    Deny from all
    Allow from 127.0.0.1 192.168.1</pre>
<p>Two PHP script are developed for saving and showing the web client data.  The save.php is used to save web client data to a data.txt file.  It looks for the keywords &#8220;pwd&#8221;, &#8220;client&#8221; and &#8220;status&#8221; in the http data sent by the client, and then record them with timestamps.</p>
<pre class="codebox">&lt;?php
function get_val ( $val )
{

		return $_GET[$val];

}

$password = get_val ( 'pwd' );

if ( $password != 'secret' )
{
	echo "&lt;font color=red&gt;&lt;b&gt;Access denied!!!&lt;/b&gt;&lt;/font&gt;";
	exit;
}

$client = get_val('client');
if ( $client == '' )
{
	echo "&lt;font color=red&gt;&lt;b&gt;Wrong client number!!!&lt;/b&gt;&lt;/font&gt;";
	exit;
}

$status = get_val ( 'status' );

if ( $status == '' )
{
	echo "&lt;font color=red&gt;&lt;b&gt;Wrong client status!!!&lt;/b&gt;&lt;/font&gt;";
	exit;
}

$filename = "./data.txt";
$time = date ("Y-n-j H:i:s");

$string = $client . '|' .$time.';'.$status."\r\n";
$a = fopen("$filename", "a+");
fputs($a, $string);
fclose($a);
?&gt;</pre>
<p>The index.php script dynamically reads data from the data.txt file and shows them in a table format.  It can be accessed for a web browser as shown below.</p>
<p><img style="border: 0px solid; height: 800px;" src="/estore/images/nustore/Ether_shield_client_list.jpg" alt="Arduino Ethernet shield V1.0" /></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">4. Software structure</span></p>
<p style="text-align: justify;" align="left">A new version of ethernet shield software is developed based on <a href="http://www.tuxgraph.org">tuxgraph&#8217;s code</a> and <a href="http://www.avrportal.com">avrnet code</a>.  The software is in the form of Arduino library and completes with a few examples, which consists of -</p>
<ul>
<li><strong>etherShield.cpp</strong> - a wrapper cpp file, as an Arduino library interface.</li>
<li><strong>ip_arp_udp_tcp.c</strong> - the IP, ARP, UDP and TCP protocol implementation, now with new web client founctions.</li>
<li><strong>enc28j60.c</strong> - ENC28J60 SPI routines</li>
<li><strong>net.h</strong> - network protocol definitions.</li>
<li><strong>/example</strong>s -
<ul>
<li> <strong>etherShield_ping</strong> - the PING example</li>
<li> <strong>etherShield_web_temperature</strong> - a Web server temperature sensor example</li>
<li> <strong>etherShield_web_switch</strong> - a Web server led switch exampe</li>
<li> <strong>etherShield_web_client</strong> - a Web client example that sends periodic temeperature sensor reading.</li>
<li> <strong>etherShield_web_client1</strong> - a Web client example that sends spontaneous infrared sensor stauts</li>
</ul>
</li>
</ul>
<p><a><span style="color: #000000;"><span style="font-weight: bold;">5. Links &amp; Downloads</span><br />
</span> </a></p>
<ul>
<li><a href="http://www.nuelectronics.com/download/projects/Ethernet_v1_0.pdf"><span style="color: #000000;">Arduino Ethernet Shield schematic V1.0</span></a></li>
<li><a href="http://www.nuelectronics.com/download/projects/etherShield.zip">Arduino ethershield library - new version with web client funtions &amp; examples</a></li>
<li><a href="http://ww1.microchip.com/downloads/en/DeviceDoc/39662c.pdf"><span style="color: #000000;">Microchip ENC28J60 datasheet</span></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nuelectronics.com/estore/?feed=rss2&amp;p=14</wfw:commentRss>
		</item>
		<item>
		<title>Ethernet Shield on Arduino - a webserver example</title>
		<link>http://www.nuelectronics.com/estore/?p=12</link>
		<comments>http://www.nuelectronics.com/estore/?p=12#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:45:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Arduino projects]]></category>

		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[ethernet]]></category>

		<category><![CDATA[network]]></category>

		<category><![CDATA[ping]]></category>

		<category><![CDATA[project]]></category>

		<category><![CDATA[web server]]></category>

		<guid isPermaLink="false">http://www.nuelectronics.com/eblog/?p=12</guid>
		<description><![CDATA[Project note &#8212; Arduino Ethernet Shield V1.0 
 
1. Schematic
The Arduino Ethernet Shield V1.0 is dedicated for the Arduino boards.  It uses the Microchip&#8217;s ENC28J60 SPI based stand-alone Ethernet controller (download datasheet here) and a compatible RJ45 socket with magnetics.   Since the ENC28J60 is a 3V3 device that only drive 3V3 logic [...]]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><b  style="text-decoration: underline; font-style: italic;"><span  style="color: rgb(128, 64, 64);"><font>Project note &#8212; Arduino Ethernet Shield V1.0 </font></span></b><font  size="2"><span style="color: rgb(128, 64, 64);"></span></font></h2>
<p style="text-align: center;"><a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&#038;cPath=1&#038;products_id=4"> <img style="border: 0px solid ; width: 480x; height: 360px;"  alt="Arduino Ethernet shield V1.0" src="http://www.nuelectronics.com/estore/images/nustore/Etehrnet_shield_2.jpg"></a></p>
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;">1. Schematic</span></p>
<p style="text-align: justify;" align="left">The Arduino Ethernet Shield V1.0 is dedicated for the Arduino boards.  It uses the Microchip&#8217;s ENC28J60 SPI based stand-alone Ethernet controller (<a  href="http://ww1.microchip.com/downloads/en/DeviceDoc/39662c.pdf">download datasheet here</a>) and a compatible RJ45 socket with magnetics.   Since the ENC28J60 is a 3V3 device that only drive 3V3 logic level output but capable of accepting 5V logic input, a 5V CMOS/TTL quad positive AND gates 74HCT08D is used to convert the 3.3 logic level output to 5V logic level.</p>
<p style="text-align: center;"><a  href="http://www.nuelectronics.com/download/projects/Ethernet_v1_0.pdf"><img  style="border: 0px solid ; width: 750px; height: 530px;"  alt="Ethernet V1.0 Schematic" src="/estore/images/nustore/projects/ethshield_schematic.jpg"></a></p>
<div style="text-align: center;"><span  style="font-weight: bold;">Fig 1. Arduino Ethernet Shield schematic</span> </div>
<p style="text-align: justify;" align="left">
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;">2. Software Structure</span></p>
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;"><span  style="font-weight: bold;"></span></span><span  style="font-weight: normal;">The Ethernet Shield software is in the format of Arduino library, which you can download from <a  href="http://www.nuelectronics.com/download/projects/etherShield.zip">here</a>.  The library is implemented based on <a  href="http://www.tuxgraphics.org/electronics/200611/article06111.shtml">tuxgraphics.org</a>&#8217;s open-source TCP/IP stack for Atmega88 and ENC28J60.  The main files in the library are &#8211;</span></p>
<ul>
<li><span style="font-weight: normal;">etherShield.cpp &#8212; a wrapper cpp file, as an Arduino library interface with tuxgraphic&#8217;s code</span></li>
<li><span style="font-weight: normal;">ip_arp_udp_tcp.c &#8212; simplified TCP/IP stack implementation</span></li>
<li><span style="font-weight: normal;">enc28j60.c  &#8212; ENC28J60 SPI routines</span></li>
<li><span style="font-weight: normal;">net.h  &#8212; network protocol definitions</span></li>
</ul>
<p> <span style="font-weight: bold;">3. TCP/IP implementation</p>
<p> </span>The standard TCP is a protocl to establish a connection.  To do this, a number of  packets needs to be exchaged between two sides first to establish the connection; then data packets can be exchaged.  Usually a complicated state-machine is needed to  implement the TCP protocol.  </p>
<p> For Auduino&#8217;s ATMEGA168, a 8-bit AVR microcontroller with 1K SRAM, it is impossible to implement the full TCP stack.  Also the webpage for 8-bit microcontroller that normally is used to control a relay or read a temperature sensor etc., is very simple. Therefore, instead of implementing full TCP protocl, a single data packet TCP protocol is used.  You webpage contents, including all html tags, must be in one packet.  The length of packet is limited by the SRAM size, currently half of the RAM space (500 bytes) is used for network Packet buffer.   It is sufficient for simple webpages as shown below.</p>
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;">4. Ethersheild library installation &#038; modification</span></p>
<p> First download the ethershield library <a  href="http://www.nuelectronics.com/download/projects/etherShield.zip">here</a>, then copy &#038; unzip the library in your Arduino IDE library directory (for example  arduino-0010/hardware/libraries/).
<p style="text-align: justify;" align="left">There are three examples in the ethershield library,  you might need to change the ip address in the example sketch (.pde) files. The ip address must be a free address with your network range</p>
<pre style="background-color: rgb(51, 255, 255);"><code>static uint8_t mymac[6] = {0x54,0x55,0x58,0x10,0x00,0x24}; 

static uint8_t myip[4] = {192,168,1,15}; 

static char baseurl[]="http://192.168.1.15/";  </code></pre>
<p> Also you might like to change the webpage contents in the print_webpage funtion.  Note that the webpage contents are stored in the PROGMEM (using PSTR declaration) to save the precious SRAM space.   </p>
<p style="text-align: justify;" align="left">
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;"><a><font color="#000000">5. Examples</font></a></span></p>
<p> <a><font color="#000000">Three examples are included in the ethershield library &#8211;<br /> </font></a>
<ul>
<li style="font-weight: bold;">
<h3>ethershield_ping.pde &#8212; a PING example </h3>
<p>     <img style="width: 670px; height: 439px;"  alt="Ethernet ping" src="/estore/images/nustore/projects/eth_ping.jpg">        </li>
<li>
<h3><span style="font-weight: bold;">ethershield_webserver.pde &#8212; a general webserver example</span></h3>
<p>     <img style="width: 617px; height: 529px;"  alt="ethershield webserver" src="/estore/images/nustore/projects/eth_webserver.jpg">        </li>
<li>
<h3>ethershield_web_temperature.pde  &#8212; a webserver with temperature sensor (DS18B20) readings</h3>
<p>     <img style="width: 614px; height: 528px;"  alt="eth temperature" src="/estore/images/nustore/projects/eth_webserver_temp.jpg">        </li>
<li>
<h3><span style="font-weight: bold;">ethershield_web_switch.pde &#8212; New &#8212; Webserver example, switch on/off LED</span></h3>
<p>     <img style="width: 617px; height: 529px;"  alt="ethershield webserver" src="/estore/images/nustore/projects/eth_web_switch.jpg">        </li>
</ul>
<p> <a><font color="#000000"><span  style="font-weight: bold;">5. Links &#038; Downloads</span><br /> </font> </a>
<ul>
<li><a  href="http://www.nuelectronics.com/download/projects/Ethernet_v1_0.pdf"><font  color="#000000">Arduino Ethernet Shield schematic V1.0</font></a></li>
<li><a  href="http://www.nuelectronics.com/download/projects/etherShield.zip">Arduino ethershield library - new version with web client funtions &#038; examples</a></li>
<li><a  href="http://ww1.microchip.com/downloads/en/DeviceDoc/39662c.pdf"><font  color="#000000">Microchip ENC28J60 datasheet</font></a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nuelectronics.com/estore/?feed=rss2&amp;p=12</wfw:commentRss>
		</item>
		<item>
		<title>LCD Keypad Shield example - LCD Smartie on Arduino</title>
		<link>http://www.nuelectronics.com/estore/?p=9</link>
		<comments>http://www.nuelectronics.com/estore/?p=9#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:44:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Arduino projects]]></category>

		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[keypad]]></category>

		<category><![CDATA[LCD]]></category>

		<category><![CDATA[LCD smartie]]></category>

		<category><![CDATA[PC]]></category>

		<category><![CDATA[shield]]></category>

		<category><![CDATA[USB]]></category>

		<guid isPermaLink="false">http://www.nuelectronics.com/eblog/?p=9</guid>
		<description><![CDATA[Project note &#8212; LCD Smartie on Arduino 
 
1. LCD Smartie 
 LCD Smartie is an open-source software for Windows that you can use to show lots of different types of information on your  LCD/VFD that connects to the PC via USB/Serial/Parallel ports.
It can display: CPU frequecy, load etc; BBC World News (or any [...]]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><strong style="text-decoration: underline; font-style: italic;"><span style="color: #804040;"><span>Project note &#8212; LCD Smartie on Arduino </span></span></strong><span style="font-size: x-small;"></span></h2>
<p style="text-align: center;"><a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&amp;cPath=1&amp;products_id=2"> <img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_title.jpg" alt="LCD Smartie on Arduino" /></a></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">1. LCD Smartie </span></p>
<p style="text-align: justify;" align="left"><a href="http://lcdsmartie.sourceforge.net/"> LCD Smartie</a> is an open-source software for Windows that you can use to show lots of different types of information on your  LCD/VFD that connects to the PC via USB/Serial/Parallel ports.<br />
It can display: CPU frequecy, load etc; BBC World News (or any other RSS feed!); WinAmp stats; Network stats  (speed, total bytes, etc); Disk available/free, memory usage, Email details, game stats, and many more&#8230;</p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">2. Firmware Features </span></p>
<p><a href="http://www.nuelectronics.com/estore/index.php?main_page=product_info&amp;cPath=1&amp;products_id=2">The LCD Keypad Shield for Arduino</a> is a perfect platform for implementing the LCD Smartie on Arduino. An Arduino sketch is developed to interface the LCD Smartie software running on the PC, and it has following features -</p>
<ul>
<li>Drives the LCD Keypad Shield using the modified LCD_4Bit library <a href="http://www.nuelectronics.com/download/projects/LCD4Bit_mod.zip"> download here </a></li>
<li>Implements a basic subset of the Matrix Orbital commands</li>
<li>Baud Rate 19200, 8bits, 1 stop, no parity</li>
<li>Interrupt driven 5-key Joystick keypad reading routine to send key press to the PC</li>
</ul>
<p>You can download the sketch from <a href="http://www.nuelectronics.com/download/projects/lcd_smartie_v1.pde"> here </a></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">3. Firmware Description </span></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">3.1 Main loop() routine</span><br />
The main loop() routine implements a command interpreter to accept and execute the commands and data sent by  the LCD smartie software running on the PC.  It implements a basic subset of the Matrix Orbital commands &#8211;</p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">3.2 Interrupt driven Keypad scanning routine</span><br />
An interrupt driven Keypad scanning routine is used to capture key press from the Joystick keypad inputs.  Timer2 is used to generate interrupt at 4ms interval.  The interrupt routine records the key press by reading AD0 value and comparing with keypad value stored in an array.  A debounce mechnism is also implemented.  The interrupt routine then transfer the key press to LCD Smartie software running on the PC. The key press is useful for controlling PC applications, such as Winamp Player.</p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">4. Hardware and Software Setup Procedure </span></p>
<ul>
<li> Download &amp; install the modified LCD_4bit library as shown <a href="http://www.nuelectronics.com/estore/index.php?main_page=project_lcd">here </a>.</li>
<li> Download the Arduino LCD Smartie sketch <a href="http://www.nuelectronics.com/download/projects/lcd_smartie_v1.pde"> here </a>.</li>
<li> Compile and upload your sketch to the Arduino/Freeduino board</li>
<li> Setup the LCD Smartie software as following pictures &#8211;</li>
</ul>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">Fig 1. LCD Smartie 5.4 Plugin setup tab &#8211;<br />
Display Plugin &#8212; choose matrix.dll<br />
Startup Paramters &#8212; Choose COM number (for Arduino boards) &amp; 19200 baud rate<br />
</span></p>
<p><img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_setup1.jpg" alt="LCD Smartie on Arduino" /></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;"> Fig 2. LCD Smartie 5.4 Screen setup tab &#8211;<br />
LCD Size - 2&#215;16</p>
<p></span></p>
<p><img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_setup2.jpg" alt="LCD Smartie on Arduino" /></p>
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">5. Screenshots </span></p>
<p>The following pictures are some screenshots of LCD Smartie on Arduino&#8230; ENJOY !!!  <img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot1.jpg" alt="LCD Smartie on Arduino" /><br />
<img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot2.jpg" alt="LCD Smartie on Arduino" /><br />
<img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot3.jpg" alt="LCD Smartie on Arduino" /><br />
<img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot4.jpg" alt="LCD Smartie on Arduino" /><br />
<img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot5.jpg" alt="LCD Smartie on Arduino" /><br />
<img style="border: 0px solid; height: 360px;" src="http://www.nuelectronics.com/estore/images/nustore/projects/LCD_Smartie_shot6.jpg" alt="LCD Smartie on Arduino" /></p>
]]></content:encoded>
			<wfw:commentRss>http://www.nuelectronics.com/estore/?feed=rss2&amp;p=9</wfw:commentRss>
		</item>
		<item>
		<title>LCD Keypad shield on Arduino</title>
		<link>http://www.nuelectronics.com/estore/?p=6</link>
		<comments>http://www.nuelectronics.com/estore/?p=6#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:43:07 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Arduino projects]]></category>

		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[joystick]]></category>

		<category><![CDATA[keypad]]></category>

		<category><![CDATA[LCD]]></category>

		<category><![CDATA[shield]]></category>

		<guid isPermaLink="false">http://www.nuelectronics.com/eblog/?p=6</guid>
		<description><![CDATA[Project note &#8212; LCD Keypad shield V1.0  

1. Schematic
The LCD Keypad shield is developed for Arduino compatible boards, to provide a user-friendly interface that allows users to go through the menu, make selections etc. It consists of a 1602 white character blue backlight LCD and 5 pushbuttons that form a joystick-style keypad.

Fig 1. LCD [...]]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><b style="text-decoration: underline; font-style: italic;"><span style="color: rgb(128, 64, 64);"><font>Project note &#8212; LCD Keypad shield V1.0 </font></span></b> <font size="2"><span style="color: rgb(128, 64, 64);"></span></font></h2>
<p style="text-align: justify;" align="left">
<p style="text-align: justify;" align="left"><span style="font-weight: bold;">1. Schematic</span></p>
<p style="text-align: justify;" align="left">The LCD Keypad shield is developed for Arduino compatible boards, to provide a user-friendly interface that allows users to go through the menu, make selections etc. It consists of a 1602 white character blue backlight LCD and 5 pushbuttons that form a joystick-style keypad.</p>
<p style="text-align: center;"><a  href="http://www.nuelectronics.com/download/projects/LCDshield_v1_1.pdf"><img style="border: 0px solid ; width: 750px; height: 530px;" alt="LCD Keypad V1.0 Schematic" src="/estore/images/nustore/projects/lcd_schematics.jpg"></a></p>
<div style="text-align: center;"><span  style="font-weight: bold;">Fig 1. LCD Keypad Schematic</span> </div>
<p style="text-align: justify;" align="left">
<p style="text-align: justify;" align="left"><span  style="font-weight: bold;">2. LCD Interface</span></p>
<p style="text-align: justify;" align="left">The LCD interaface uses HD44780D 4-bit compatible interface. In order to preserve the SPI interface for future use, a different set of IO pins is used. The following diagram shows the IO pins used to drive the LCD, you can modify the original 4bit LCD libaray [<a  href="http://www.arduino.cc/playground/Code/LCD4BitLibrary">download here</a>] or you can download the modified 4-bit LCD library [<a  href="http://www.nuelectronics.com/download/projects/LCD4Bit_mod.zip">download here</a>] .</p>
<p> <center> <img  src="/estore/images/nustore/projects/lcd_interface.jpg"  alt="LCD interface" style="width: 328px; height: 252px;"  align="middle" hspace="20"></center>
<div style="text-align: center;"><span  style="font-weight: bold;">Fig 2. LCD Interface</span> </div>
<pre style="background-color: rgb(51, 255, 255);"><code>int USING_RW = false;

//RS, RW and Enable can be set to whatever you like

int RS = 8;

int RW = 11;

int Enable = 9;

//DB should be an unseparated group of pins 

int DB[] = {4, 5, 6, 7}; //wire these to DB4~7 on LCD. 

</code></pre>
<div style="text-align: center;"><span  style="font-weight: bold;">List 1. Code example &#8212; modified pin definition in 4Bit LCD library</span> </div>
<p style="text-align: justify; font-weight: bold;"  align="left">3. Keypad Interface</p>
<p style="text-align: justify; font-weight: bold;"  align="left"><span style="font-weight: normal;">The joystick style keypad consists of 5 keys &#8212; select, up, right, down and left. To save the digital IO pins, the keypad interface only uses one ADC channel. The key value is read through a 5 stage voltage divider as shown below.</span></p>
<p style="text-align: justify;" align="left">When a key is pressed, the ADC reads the voltage value through the voltage divider; the the voltage value is compared to the voltage threshold values stored in an array to identify which key is pressed. </p>
<p> <center><img style="width: 370px; height: 461px;"  alt="Keypad Interface"  src="/estore/images/nustore/projects/keypad_interface.jpg"  align="middle"> </center>
<div style="text-align: center;"><span  style="font-weight: bold;">Fig 3. Joystick style Keypad, uses ONE ADC channel </span> </div>
<pre style="background-color: rgb(51, 255, 255);"><code> int adc_key_val[5] ={30, 150, 360, 535, 760 };

int NUM_KEYS = 5;

....

void loop() 

{ adc_key_in = analogRead(0); // read the value from the

sensor digitalWrite(13, HIGH); 

key = get_key(adc_key_in); // convert into key press 

if (key != oldkey) // if keypress is detected {

delay(50); // wait for debounce time 

adc_key_in = analogRead(0); //read the value from the sensor

key = get_key(adc_key_in); // convert into key press

 if (key != oldkey) { 

oldkey = key; 

if (key >=0){

lcd.cursorTo(2, 0); //line=2, x=0 

lcd.printIn(msgs[key]); 

} 

} 

}

digitalWrite(13, LOW); }</code></pre>
<div style="text-align: center;"><span  style="font-weight: bold;">List 2. Code example &#8212; reading key values from the loop()</span></div>
<p> <span style="font-weight: bold;">4. Examples</span></p>
<p> Two exmaples for LCD keypad shield are included in the midified LCD 4-bit library [download here]<br /> 
<ul>
<li>Example 1 &#8212; Joystick keypad test routine, keypress shown on the LCD screen</li>
<li>Example 2 &#8212; Temperature measurenemt, using prototype shield &#038; LCD keypad shield</li>
</ul>
<p> <center><img style="width: 400px; height: 300px;"  alt="lcd temperature measurement"  src="/estore/images/nustore/projects/temperature_lcd2.jpg"  align="middle"> </center>
<div style="text-align: center;"><span  style="font-weight: bold;">Fig 4. Temperature measurement using LCD keypad shield </span> </div>
<p> <span style="font-weight: bold;">5. Links &#038; Downloads</span><br /> 
<ul>
<li><a  href="http://www.nuelectronics.com/download/projects/LCDshield_v1_1.pdf">LCD keypad shield schematic V1.1</a></li>
<li><a  href="http://www.arduino.cc/playground/Code/LCD4BitLibrary">Original LCD 4-bit library</a></li>
<li><a  href="http://www.nuelectronics.com/download/projects/LCD4Bit_mod.zip">Modified LCD 4-bit libaray with examples</a></li>
<li><span style="color: rgb(128, 64, 64);">New Project note - <a href="http://www.nuelectronics.com/estore/index.php?main_page=project_lcdsmartie">LCD Smartie on Arduino </a></span>, communicate with your PC using the LCD keypad shield.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.nuelectronics.com/estore/?feed=rss2&amp;p=6</wfw:commentRss>
		</item>
		<item>
		<title>Prototype shield kit examples</title>
		<link>http://www.nuelectronics.com/estore/?p=3</link>
		<comments>http://www.nuelectronics.com/estore/?p=3#comments</comments>
		<pubDate>Mon, 25 Aug 2008 21:39:09 +0000</pubDate>
		<dc:creator>admin</dc:creator>
		
		<category><![CDATA[Arduino projects]]></category>

		<category><![CDATA[Arduino]]></category>

		<category><![CDATA[Arduino project]]></category>

		<category><![CDATA[example]]></category>

		<category><![CDATA[kit]]></category>

		<category><![CDATA[PCB]]></category>

		<category><![CDATA[protoshield]]></category>

		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://www.nuelectronics.com/eblog/?p=3</guid>
		<description><![CDATA[Project note &#8212; Arduino ProtoShield Kit V1.0 

Not exactly a project note, just a few photos to show what you can do with the Arduino Protoshield Kit V1.0

Fig 1. Protoshield with Temperature sensor DS18B20 

Fig 2. My first Arudino Ethernet (ENC28J60) prototype on ProtoShield 

Fig 3. USBtinyISP(to download bootloader) on Protoshield 

Fig 4. Temperature measurement [...]]]></description>
			<content:encoded><![CDATA[<h2 style="text-align: center;"><strong style="text-decoration: underline; font-style: italic;"><span style="color: #804040;"><span>Project note &#8212; Arduino ProtoShield Kit V1.0 </span></span></strong></h2>
<p style="text-align: justify;" align="center">
<h3>Not exactly a project note, just a few photos to show what you can do with the Arduino Protoshield Kit V1.0</h3>
<p><img style="width: 400px; height: 300px;" src="/estore/images/nustore/projects/ds18b20_1.jpg" alt=" temperature measurement" align="middle" /></p>
<div style="text-align: center;"><span style="font-weight: bold;">Fig 1. Protoshield with Temperature sensor DS18B20 </span></div>
<p><img style="width: 400px; height: 300px;" src="/estore/images/nustore/projects/protoshield_ethernet.jpg" alt="ProtoShield ethernet" align="middle" /></p>
<div style="text-align: center;"><span style="font-weight: bold;">Fig 2. My first Arudino Ethernet (ENC28J60) prototype on ProtoShield </span></div>
<p><img style="width: 400px; height: 300px;" src="/estore/images/nustore/projects/protoshield_usbisp.jpg" alt="ProtoShield USBtinyisp" align="middle" /></p>
<div style="text-align: center;"><span style="font-weight: bold;">Fig 3. USBtinyISP(to download bootloader) on Protoshield </span></div>
<p><img style="width: 400px; height: 300px;" src="/estore/images/nustore/projects/temperature_eth.jpg" alt="ProtoShield USBtinyisp" align="middle" /></p>
<div style="text-align: center;"><span style="font-weight: bold;">Fig 4. Temperature measurement with Ethernet (Protoshield in the middle of the Stack)</span></div>
<p><img style="width: 400px; height: 300px;" src="/estore/images/nustore/projects/temperature_lcd.jpg" alt="ProtoShield USBtinyisp" align="middle" /></p>
<div style="text-align: center;"><span style="font-weight: bold;">Fig 5. Temperature measurement with LCD shield (Protoshield in the middle of the Stack)</span></div>
]]></content:encoded>
			<wfw:commentRss>http://www.nuelectronics.com/estore/?feed=rss2&amp;p=3</wfw:commentRss>
		</item>
	</channel>
</rss>
