Arduino 1.0 with enc28j60 Ethernet Shield V1.1
18 december 2011 | Classified in: Electronic | Tags: arduino, ethernet, shield
Here is how to use the enc28j60 Ethernet Shield V1.1 with Arduino 1.0.
Introduction
The Arduino team recently released the Arduino software in version 1.0, which adds a lots of new feature and bug fix (see release notes) but also breaks backward compatibility with sketches and libraries written for the previous versions of the software.
From now, in order to use the cheap enc28j60 Ethernet Shield V1.1 you will need a library that is compatible with the latest revision of the Arduino IDE.
After some research on the web, I found a library that works properly but I still had to change a few path name before I could compile a sketch without error.
Download and install the library
- Download the library here: ethershield_v1.1_for_arduino_v1.0.zip
- Extract the zip file.
- Copy the folders "ETHER_28J60" and "etherShield" into your libraries folder.
- On Linux: $HOME/sketchbook/libraries
- On Mac: $HOME/Documents/Arduino/libraries
- On Windows: ..\My Documents\Arduino\libraries
- Open the Arduino software and go to "File → Examples → ETHER_28J60" and try some of the examples.
Use a web browser to turn an LED on or off
- Connect the Ethernet Shield and Ethernet cable to the Arduino.
- Upload the code below.
- Connect an LED between Pin 6 and Ground.
- Open a web browser and visit http://192.168.1.15/
- Click the button to turn the LED on or off.
Code
The code below is taken from the library example with some minor modifications from myself:
// A simple web server that turn an LED on or off"
#include "etherShield.h"
#include "ETHER_28J60.h"
int outputPin = 6;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
static uint8_t ip[4] = {192, 168, 1, 15}; // IP address for the webserver
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 e;
void setup()
{
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<h1><a href='/?led=off'>Arduino Web Remote</a></h1>");
if (strcmp(params, "?led=on") == 0)
{
digitalWrite(outputPin, HIGH);
e.print("<a href='?led=off'><button style='border: 1px solid #ff0000; border-left: 10px solid #ff0000' type='button'>LED IS ON</button></a>");
}
else if (strcmp(params, "?led=off") == 0)
{
digitalWrite(outputPin, LOW);
e.print("<a href='?led=on'><button style='border: 1px solid #000; border-left: 10px solid #000' type='button'>LED IS OFF</button></a>");
}
e.respond();
}
}
Video
Going further
Here is another example using 2 buttons to control 2 LED, as requested in the comments below.
Reader Contribution
EDIT 01/01/2013: Reader "Nio" have sent me a modified version of the library described above, removing the buffer size limit and adding new print_P function.
If you would like to try Nio's version of the library, you will find it here. (*Not* tested yet)


96 comments