Août 122013

Here below a quick how to use an arduino and a cheap enc28j60 ethernet module (5€).

Can be handy to built a quick web server and some sensors (like a ds18b20 for example).

below the wiring :


below a sketch using the ethercard library (provided with Arduino GUI) :

// Present a "Will be back soon web page", as stand-in webserver.
// 2011-01-30 <>
#include <EtherCard.h>

#define STATIC 0  // set to 1 to disable DHCP (adjust myip/gwip values below)

// ethernet interface ip address
static byte myip[] = { 192,168,1,200 };
// gateway ip address
static byte gwip[] = { 192,168,1,1 };

// ethernet mac address - must be unique on your network
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };

byte Ethernet::buffer[500]; // tcp/ip send and receive buffer

char page[] PROGMEM =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Retry-After: 600\r\n"
    "my web page"
    "<h3>hello world !</h3>"

void setup(){
  if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) 
    Serial.println( "Failed to access Ethernet controller");
  ether.staticSetup(myip, gwip);
  if (!ether.dhcpSetup())
    Serial.println("DHCP failed");

  ether.printIp("IP:  ", ether.myip);
  ether.printIp("GW:  ", ether.gwip);  
  ether.printIp("DNS: ", ether.dnsip);  

void loop(){
  // wait for an incoming TCP packet, but ignore its contents
  if (ether.packetLoop(ether.packetReceive())) {
    memcpy_P(ether.tcpOffset(), page, sizeof page);
    ether.httpServerReply(sizeof page - 1);
 Posted by at 14 h 21 min

  3 Responses to “Arduino : use an ethernet controller (enc28j60)”

  1. recently i did experiment with enc28j60 . i was able to run the hello world program using WiFi. The problem is that when i use my cellphone internet and try to access ip after disconnecting wifi the web page doesnt shows up

  2. Hey,
    I am grateful to you, Although you have shared an Example! but still this one helped me solving my problem.
    Thankyou. 🙂

 Leave a Reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>