Ethernet Shield

From ElecFreaks
Jump to: navigation, search

Introduction

The Ethernet Shield allows an Arduino board to connect to the internet. It is based on the Wiznet W5100 ethernet chip (datasheet). The Wiznet W5100 provides a network (IP) stack capable of both TCP and UDP. It supports up to four simultaneous socket connections. Use the Ethernet library to write sketches which connect to the internet using the shield. The ethernet shield connects to an Arduino board using long wire-wrap headers which extend through the shield. This keeps the pin layout intact and allows another shield to be stacked on top.

The most recent revision of the board exposes the 1.0 pinout on rev 3 of the Freaduino UNO board.The Ethernet Shield has a standard RJ-45 connection, with an integrated line transformer and Power over Ethernet enabled. There is an onboard micro-SD card slot, which can be used to store files for serving over the network. It is compatible with the Arduino Uno and Mega (using the Ethernet library). The onboard microSD card reader is accessible through the SD Library. When working with this library, SS is on Pin 4.The shield also includes a reset controller, to ensure that the W5100 Ethernet module is properly reset on power-up.

Arduino communicates with both the W5100 and SD card using the SPI bus (through the ICSP header). This is on digital pins 11, 12, and 13 on the Duemilanove and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used to select the W5100 and pin 4 for the SD card. These pins cannot be used for general i/o. On the Mega, the hardware SS pin, 53, is not used to select either the W5100 or the SD card, but it must be kept as an output or the SPI interface won't work.

Model: EF02007

Ethernet shield A.JPGEthernet shield B.JPGEthernet shield D.jpg

Feature

  • Standard Arduino and Arduino Mega compatible
  • Ethernet:WIZ5100
  • Standard RJ45 Ethernet interface
  • Arduino Ethernet Library compatible
  • Support Micro SD Card(no more than 2GB)
  • Arduino/ Freaduino/Mega fully compatible
  • Easy to access reset button
  • Up to 4 TCP/UDP network connections
  • SD Card IO CS:D4 ;MOSI:D11;SCK:D13;MISO:D12
  • Operating voltage:DC5-12V
  • Dimension:78mmx53.5m


Note

Ethernet Shield Micro SD can only support 2GB memory card.

Schematic

Ethernet shield F.jpg


Specification

Ethernet shield E.jpg

Interface Function

Ethernet Shield B.jpg

  • RJ45- Ethernet Port
  • Power LED - Power
  • SPD LED(100M) - Light indicates the link speed is 100Mbps
  • Coll LED - Light indicates the presence of collision activity
  • Rx LED - Light indicates the presence of receiving activity
  • Tx LED - Light indicates the presence of transmitting activity
  • Reset KEY - Reset Ethernet shield and Arduino when pressed
  • SD SOCKET-can be used to insert micro-SD card

Pins usage on Arduino

  • D0 - Unused
  • D1 - Unused
  • D2 - Connects the INT pin of the W5100
  • D3 - Unused
  • D4 - Used for SPI Chip Select
  • D5 - Unused
  • D6 - Unused
  • D7 - Unused
  • D8 - Unused
  • D9 - Unused
  • D10 - Used for SPI LED
  • D11 - Used for SPI MOSI
  • D12 - Used for SPI MISO
  • D13 - Used for SPI SCK
  • D14(A0) - Unused
  • D15(A1) - Unused
  • D16(A2) - Unused
  • D17(A3) - Unused
  • D18(A4) - Unused
  • D19(A5) - Unused

Usage

Connect the ethernet shield with internet via RJ45 connector, and Arduino with PC via USB cable. Insert ethernet shield onto Arduion board:

Hardware Installation

W5100.jpg

Open the Arduino IDE(1.0), open the WebServer example in the Ethernet library:

NX Bridge v o.jpg

micro-SD card Result testing

NX Bridge V1.1 Z.jpg

Open a web browser and enter the web address:192.168.0.177, then you can check the data sent out by Ethernet Shield:

Notice: Make sure the Ethernet Shield and your computer are in the same local area network

NX Bridge v1.1 k.jpg

Programming

Includes important code snippet. Demo code like :

Demo code
{/*
  SD card read/write
 
 This example shows how to read and write data to and from an SD card file 	
 The circuit:
 * SD card attached to SPI bus as follows:
 ** MOSI - pin 11
 ** MISO - pin 12
 ** CLK - pin 13
 ** CS - pin 4
 
   Web Server
 
 A simple web server that shows the value of the analog input pins.
 using an Arduino Wiznet Ethernet shield. 
 
 Circuit:
 * Ethernet shield attached to pins 10, 11, 12, 13
 * Analog inputs attached to pins A0 through A5 (optional)
 
 created 18 Dec 2009
 by David A. Mellis
 modified 4 Sep 2010
 by Tom Igoe
 
 */
 
#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
 
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,0,177);
 
// Initialize the Ethernet server library
// with the IP address and port you want to use 
// (port 80 is default for HTTP):
EthernetServer server(80);
 
File myFile;
 
void setup()
{
  Serial.begin(9600);
  Serial.print("Initializing SD card...");
  // On the Ethernet Shield, CS is pin 4. It's set as an output by default.
  // Note that even if it's not used as the CS pin, the hardware SS pin 
  // (10 on most Arduino boards, 53 on the Mega) must be left as an output 
  // or the SD library functions will not work. 
   pinMode(10, OUTPUT);
  // pinMode(4,OUTPUT);
  if (!SD.begin(4)) {
    Serial.println("initialization failed!");
    return;
  }
  Serial.println("initialization done.");
 
  // open the file. note that only one file can be open at a time,
  // so you have to close this one before opening another.
 
  myFile = SD.open("test.txt",FILE_WRITE);
  // if the file opened or created okay, write to it:
  if (myFile) {
    Serial.print("Writing to test.txt...");
    myFile.println("testing 1, 2, 3.");
	// close the file:
    myFile.close();
    Serial.println("done.");
  } else {
    // if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
 
  // re-open the file for reading:
  myFile = SD.open("test.txt");
  if (myFile) {
    Serial.println("test.txt:");
 
    // read from the file until there's nothing else in it:
    while (myFile.available()) {
    	Serial.write(myFile.read());
    }
    // close the file:
    myFile.close();
  } else {
  	// if the file didn't open, print an error:
    Serial.println("error opening test.txt");
  }
   // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);
  server.begin();
}
unsigned char buff[6];
void loop()
{
  EthernetClient client = server.available();
  if (client) {
    // an http request ends with a blank line
    boolean currentLineIsBlank = true;
    while (client.connected()) {
      if (client.available()) {
        char c = client.read();
        // if you've gotten to the end of the line (received a newline
        // character) and the line is blank, the http request has ended,
        // so you can send a reply
        if (c == '\n' && currentLineIsBlank) {
          // send a standard http response header
          client.println("HTTP/1.1 200 OK");
          client.println("Content-Type: text/html");
          client.println();
 
          // output the value of each analog input pin
          for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
            client.print("analog input ");
            client.print(analogChannel);
            client.print(" is ");
            client.print(analogRead(analogChannel));
            client.println("<br />");
            buff[analogChannel] = analogRead(analogChannel);
          }
           break;
        }
        if (c == '\n') {
          // you're starting a new line
          currentLineIsBlank = true;
        } 
        else if (c != '\r') {
          // you've gotten a character on the current line
          currentLineIsBlank = false;
        }
      }
    }
    // give the web browser time to receive the data
    delay(1);
    // close the connection:
    client.stop();
    myFile = SD.open("test.txt", FILE_WRITE);
    if (myFile) {
      Serial.println("test.txt:");
      for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
      myFile.print("analog input ");
      myFile.print(analogChannel);
      myFile.print(" is ");
      myFile.println(analogRead(analogChannel));
      }
      // read from the file until there's nothing else in it:
      myFile.close();
    }
    else {
    	// if the file didn't open, print an error:
      Serial.println("error opening test.txt");
    }
 
    myFile = SD.open("test.txt");
    if (myFile) {
      Serial.println("test.txt:");
 
      // read from the file until there's nothing else in it:
      while (myFile.available()) {
      	Serial.write(myFile.read());
      }
      // close the file:
      myFile.close();
    }
    else {
    	// if the file didn't open, print an error:
      Serial.println("error opening test.txt");
    }
  }  
}


}

Example

The projects and application examples.

Version Tracker

Revision Descriptions Release
v0.9b Initial public release date

Bug Tracker

Bug Tracker is the place you can publish any bugs you think you might have found during use. Please write down what you have to say, your answers will help us improve our products.

Additional Idea

The Additional Idea is the place to write your project ideas about this product, or other usages you've found. Or you can write them on Projects page.

Resources

How to buy

Click here to buy:http://www.elecfreaks.com/estore/ethernet-shield.html

See Also

Other related products and resources.

Licensing

This documentation is licensed under the Creative Commons Attribution-ShareAlike License 3.0 Source code and libraries are licensed under GPL/LGPL, see source code files for details.

External Links

Links to external webpages which provide more application ideas, documents/datasheet or software libraries