Ethernet Shield:
1. Schematic
The Arduino Ethernet Shield V1.0 is dedicated for the Arduino boards. It uses the Microchip'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 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.
Fig 1. Arduino Ethernet Shield schematic
2. Software Structure
The Ethernet Shield software is in the format of Arduino library, which you can download from here. The library is implemented based ontuxgraphics.org's open-source TCP/IP stack for Atmega88 and ENC28J60. The main files in the library are --
- etherShield.cpp -- a wrapper cpp file, as an Arduino library interface with tuxgraphic's code
- ip_arp_udp_tcp.c -- simplified TCP/IP stack implementation
- enc28j60.c -- ENC28J60 SPI routines
- net.h -- network protocol definitions
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.
For Auduino'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.
4. Ethersheild library installation & modification
First download the ethershield library here, then copy & unzip the library in your Arduino IDE library directory (for example arduino-0010/hardware/libraries/).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
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/";
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.
uint16_t print_webpage(uint8_t *buf)
{
uint16_t plen;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OKrnContent-Type: text/htmlrnrn"));
...
return plen;
}
Three examples are included in the ethershield library --ethershield_ping.pde -- a PING example
ethershield_webserver.pde -- a general webserver example
ethershield_web_temperature.pde -- a webserver with temperature sensor (DS18B20) readings
ethershield_web_switch.pde -- New -- Webserver example, switch on/off LED
- Arduino Ethernet Shield schematic V1.0
- Arduino ethershielld library
- NEW-- Webserver example - Switch on/off LED
- Microchip ENC28J60 datasheet
Source of this article: http://www.nuelectronics.com/estore/index.php?main_page=project_eth