• 2012 Ethernet W5100 Network Shield For Arduino UNO Mega 2560 1280 328
  • 2012 Ethernet W5100 Network Shield For Arduino UNO Mega 2560 1280 328

Ethernet W5100 Network Shield For Arduino UNO/Mega

£10.79
VAT included

This Ethernet Shield is based on the Wiznet W5100 Ethernet Chip and gives you an easy way to get your Arduino online.

Quantity
block Currently Out of Stock

This Ethernet Shield is based on the Wiznet W5100 Ethernet Chip and gives you an easy way to get your Arduino online. It is directly supported by the official Arduino Ethernet Library. It also includes an additional micro-SD card slot, which can be used to store files for serving over the network. It is compatible with the Arduino Duemilanove (168 or 328), Uno as well as Mega (1280/2560) and can be accessed using the SD and Ethernet libraries.
 
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.

 

This product is derived from the Arduino(TM) reference design which was released under the Creative Commons Attribution Share-Alike license.

You can see the license here:

https://creativecommons.org/licenses/by-sa/3.0/legalcode

Technical support for any product sold by Hobby Components should be directed to Hobby Components. We have no affiliation with Arduino.

 

EXAMPLE ARDUINO CODE


 
 
/* FILE:    ARD_Ethernet_Shield_HCARDU0034_SD_Card_Reader_Example.pde
   DATE:    25/04/13
   VERSION: 0.2
 
This is an example of how to use the HobbyComponents Arduino Ethernet shield
(HCARDU0033) and its included micro SD card reader. This Ethernet shield is 
based on the W5100 Ethernet controller and is compatible with the standard Arduino
Ethernet libraries. It requires no additional libraries to work.
 
This example program will serve a web page to a client (i.e. web browser) that 
contains the contents of a text file saved on an inserted micro SD card.
 
For this example to work you will need to have a micro SD card inserted into the 
card reader containing a text file with the name 'test.txt'. The contents of the text 
file can be anything you like. When a client makes a connection, the program will 
attempt to read the contents of the test.txt file and serve it to the client.
 
REVISIONS:
 
V0.1 Initial version
V0.2 Added line to configure pin 53 as an output on Mega's to stop the SPI
     master potentially being configured as a slave by hardware.
 
You may copy, alter and reuse this code in any way you like, but please leave 
reference to HobbyComponents.com in your comments if you redistribute this code. 
This software may not be used directly for the purpose of selling products that 
directly compete with Hobby Components Ltd's own range of products.  
 
THIS SOFTWARE IS PROVIDED "AS IS". HOBBY COMPONENTS MAKES NO WARRANTIES, WHETHER 
EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF 
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ACCURACY OR LACK OF NEGLIGENCE.
HOBBY COMPONENTS SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR ANY DAMAGES, 
INCLUDING, BUT NOT LIMITED TO, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR ANY 
REASON WHATSOEVER.
 
*/
 
/* Include the serial library for communicating with the COM port */
#include <SPI.h>
 
/* Include the standard Ethernet library */
#include <Ethernet.h>
 
/* Include the standard SD card library */
#include <SD.h>
 
/* DIO pin used to control the modules CS pin */
#define SD_CARD_CD_DIO 4 
 
File SDFileData;
 
 
/* MAC address of the Ethernet shield. If you are using this on your 
own network, then the MAC address below will be fine, but remember if 
you use more than one shield on your network they will need to be assigned
unique MAC addresses */
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
 
/* The IP address of the shield. Make sure this matches the IP 
   address range of your network and is not in use by any other 
   device on it */    
IPAddress ip(192, 168, 1, 55 );
 
/* The port number the shield will respond to. Use port 80 
   for standard HTTP requests */
EthernetServer server(80);
 
 
 
void setup()
{  
  //pinMode(53, OUTPUT); //Uncomment this line if using a Mega
  /* Start the Ethernet interface */
  Ethernet.begin(mac, ip);
  server.begin();
 
  /* DIO pin used for the CS function. Note that even if you are not driving this
     function from your Arduino board, you must still configure this as an output 
     otherwise the SD library functions will not work. */
  pinMode(10, OUTPUT);
 
  
  /* Initialise the serial port */
  Serial.begin(9600);
 
  /* Initialise the SD card */
  if (!SD.begin(SD_CARD_CD_DIO)) 
  {
    /* If there was an error output this to the serial port and go no further */
    Serial.println("ERROR: SD card failed to initialise");
    while(1);
  }else
  {
    Serial.println("SD Card OK");
  }
 
}
 
 
/* MAIN PROGRAM LOOP */
void loop()
{
  /* All client requests are terminated with a blank line. This flag will 
    signify if the current line received from this client is a blank line */
  boolean bBlankLineFlag = true;
  
  /* Used to hold the current byre received from the client */
  char cCurrentByte;
  
  /* Used to hold the current byte read from the test.txt file located on the SD card */
  char cCurrentSDByte;
    
  
  /* Wait for a request from a client */
  EthernetClient ethernet = server.available();
  
  if (ethernet) 
  {
    /* Continue to read data from the client one byte at a time until 
       there is no more data */ 
    while (ethernet.connected()) 
    {
      /* Is there still data available to be read? ethernet class 
         ethernet.connected() returns the number of bytes available */
      if (ethernet.available()) 
      {
        /* If data is available read the next byte */ 
        cCurrentByte = ethernet.read();
 
        /* Is the next byte read is a new line termination ? */      
        if (cCurrentByte == '\n')
        { 
          /* If so was it a blank line? */
          if (bBlankLineFlag) 
          {
            
            /* If it was then we can now send a response to the client’s http request... */
            ethernet.println("HTTP/1.1 200 OK");
            ethernet.println("Content-Type: text/html");
            ethernet.println();
 
            ethernet.println("<body>");
            ethernet.println("<big><span style=\"font-weight: bold;\">www.hobbycomponents.com Ethernet Shield Example</span></big><br>");
            ethernet.println("****************************************************<br>");
 
            /* ...and the append the contents of the text.txt file */
  
            SDFileData = SD.open("test.txt");
    
 
            /* Sequentially read the data from the file until there is no more data available */
            while (SDFileData.available())
            {
              cCurrentSDByte = SDFileData.read();
             
              /* Check if the current byte is a line break ASCII and if so send an HTML line break */
              if (cCurrentSDByte == '\n')
              {
                ethernet.println("<br>");
              }else
              {
                /* If not then just send it to the client */
                ethernet.print((char)cCurrentSDByte);
              }
            }
     
            /* Close the file */
            SDFileData.close();  
           
            ethernet.println("</body>");
 
            /* Disconnect from the client */
            ethernet.stop();
          }
        
          /* The last byte received from the client was the start of a 
             new line so flag as no data received for this line yet */
          bBlankLineFlag = true;
        
        /* If the last byte received wasn't a new line then it must be data... */  
        } else if (cCurrentByte != '\r')
        {  
          /* ...and so flag this as not a blank line. */
          bBlankLineFlag = false;
        }
      }
    }
  }
}
 

 
HCARDU0034

Specific References

16 other products in the category

Data Logger Shield

This data logger shield provides an Arduino Uno, Leonardo, or Mega with the ability to log...

£5.99
  • Currently Out of Stock