Difference between revisions of "Arduino ENC28J60 Ethernet Module"

From Geeetech Wiki
Jump to: navigation, search
(Example code)
(Example code)
Line 21: Line 21:
  
 
==Example code==
 
==Example code==
Open Arduino IDE Files - Examples - ENC28J60 - WebServer
+
Open Arduino IDE Files - Examples - ENC28J60 - WebServer<br>
 
IP address in the example code need to change for the address assigened to ENC28J60 module.
 
IP address in the example code need to change for the address assigened to ENC28J60 module.
  

Revision as of 03:04, 21 May 2012

Introduction

ENC28J60 1.jpg

Besides W5100, ENC28J60 is another widely used network chip, the early Arduino network module is accomplished by means of ENC28J60, although later a new Arduino network module come up based on W5100, but the ENC28J60 is also widely used due to its stable and reliable.


Description

  • Brand New and High Quality
  • With this Ethernet Shield, your Arduino board can be used to connect to internet
  • Genuine Microchip's ENC28J60 SPI ethernet controller and HR911102A RJ45 socket
  • Open-source TCP/IP protocol stack as an Arduino library.
  • Web client application to use Arduino as a distributed network sensor

Usage

ENC28J60 2.jpg

ENC28J60 usage1.jpg

To get it work, ENC28J60 library need to be used.Due to the function name of ENC28J60 library is same as the original Ethernet library, the original Ethernet library in the library folder must be removed.

Example code

Open Arduino IDE Files - Examples - ENC28J60 - WebServer
IP address in the example code need to change for the address assigened to ENC28J60 module.

#include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 10, 0, 0, 177 };
Server server(80);
void setup()
{
 Ethernet.begin(mac, ip);
 server.begin();
}
void loop()
{
 Client client = server.available();
 if (client) {
   // an http request ends with a blank line
   boolean current_line_is_blank = true;
   while (client.connected()) {
     if (client.available()) {
       char c = client.read();
       // if we've gotten to the end of the line (received a newline
       // character) and the line is blank, the http request has ended,
       // so we can send a reply
       if (c == '\n' && current_line_is_blank) {
         // 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 i = 0; i < 6; i++) {
           client.print("analog input ");
           client.print(i);
           client.print(" is ");
           client.print(analogRead(i));
           client.println("
"); } break; } if (c == '\n') { // we're starting a new line current_line_is_blank = true; } else if (c != '\r') { // we've gotten a character on the current line current_line_is_blank = false; } } } // give the web browser time to receive the data delay(1); client.stop(); } }

How to buy

Click here to buy Arduino ENC28J60 Ethernet Module