After playing with Arduino for a while, I wanted to connect one to the Internet for a little project. Now you can buy shields for that, but they are quite expensive (like 40$). So I decide to look for alternatives and after a while I found 10$ ENC28J60 Ethernet modules on eBay. While they are not as full fetched as the official (Wiznet based) shield, they are certainly a lot cheaper.

As it turns out, it is quite easy to connect any (3.3 or 5V) Arduino to one of those modules with just six wires:

ENC SO -> Arduino pin 12

ENC SI -> Arduino pin 11

ENC SCK -> Arduino pin 13

ENC CS -> Arduino pin 8

ENC VCC -> Arduino 3V3 pin

ENC GND -> Arduino Gnd pin

After you have done this (see my example) and re-checked all wires again. You can use either the (older) Ethercard library or the (newer) Ethershield library (just download, unzip and rename to the Libraries folder as ‘Ethershield’ or ‘Ethercard’) . A nice example Sketch to get you started is the backsoon Sketch by J.C. Wippler.

Here an example of how to set up a simple webserver, again from J.C. Wippler:

// This is a demo of the RBBB running as webserver with the Ether Card // 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php #include <EtherCard.h> // ethernet interface mac address, must be unique on the LAN static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 }; static byte myip[] = { 192,168,1,203 }; byte Ethernet::buffer[500]; BufferFiller bfill; void setup () { if (ether.begin(sizeof Ethernet::buffer, mymac) == 0) Serial.println( "Failed to access Ethernet controller"); ether.staticSetup(myip); } static word homePage() { long t = millis() / 1000; word h = t / 3600; byte m = (t / 60) % 60; byte s = t % 60; bfill = ether.tcpOffset(); bfill.emit_p(PSTR( "HTTP/1.0 200 OK\r

" "Content-Type: text/html\r

" "Pragma: no-cache\r

" "\r

" "<meta http-equiv='refresh' content='1'/>" "<title>RBBB server</title>" "<h1>$D$D:$D$D:$D$D</h1>"), h/10, h%10, m/10, m%10, s/10, s%10); return bfill.position(); } void loop () { word len = ether.packetReceive(); word pos = ether.packetLoop(len); if (pos) // check if valid tcp data is received ether.httpServerReply(homePage()); // send web page data }

Applications

After that, you might want to control LEDs, relais or send SMS messages with through your new Ethernet interface (change Ethercard.begin pin no from 10 to 8!). Or how about having your Arduino talk with your web app through POSTs or GETs (I have done that with great success with my GrowGuard platform).

So there you have it: Connect any Arduino (or other microcontroller) to the Internet with 6 wires and a 10$ module!

Need a product developed or Want more Arduino and Hardware tips in your inbox?

Next to our own projects, we also develop for other companies (often with wifi, Ethernet, bluetooth, GSM/GPRS). Do you want us to develop or built a prototype for you? Feel free to contact us: hans@cloudsensor.us

Do you want to hear more about Arduino, embedded hardware and hardware startups? Click on the “Follow” button on the right, I appreciate it.