Os Ethernet Shield para Arduino facilitam a conexão do seu projeto a redes comuns, ethernet é o padrão que usamos nas nossas redes domésticas. O Ethernet Shield para Arduino tem basicamente duas versões e estaremos falando sobre estas duas. Estes Ethernet Shields podem ser usados em outros microprocessadores, apenas precisam implementar o protocolo SPI.

Ethernet Shield ENC28J60
Foi o meu primerio ethernet shield, tem grandes limitações tendo o único motivo para a sua compra o valor.
Vantagens
- Preço
- Objetivo permite fácil implementação
Desvantagem
- Limite de resposta, geralmente em 500 bytes.
- Muitas libraries, mas nenhuma com suporte oficial.
Quando realizei os testes com este shield Ethernet, tinha inicialmente pensado em responder um HTML para o browser, mas pela limitação de resposta foi possível esta implementação pois o HTML que eu tinha feito ocupava 3k. Assim usei ele como um servidor de webservices e isto foi o que melhor que consegui realizar com este shield ethernet.
Outra questão importante é que embora tenha sido fácil de programar, pois a biblioteca já dava suporte ao request, parâmetros enviados pelo browser, encontrei problemas para deixar a plataforma estável, necessitando de reset de tempos em tempos. Isto pode ter sido uma falha de programação minha, mas não consegui encontrar o erro mesmo depois que migrei para o novo shield.
Ethernet Shield WIZ 5100
Depois de ficar meio decepcionado com o Ethernet Shield ENC28J60, comprei o WIZ 5100 que atualmente é o Ethernet Shield Oficial do Arduino.cc.
Vantagens
- Construção
- Sem limite de buffer
- Cartão SD Integrado
- Library oficial do Arduino.cc.
Desvantagem
- Preço elevado no Brasil
- Cabeçalho completo do request, precisando de uma programação maior.
Após atualizar meu projeto do ENC28J60 vi que teria que re-escrever boa parte pois o requeste não vem separado e sim todo o cabeçalho do request, o que deixa bem mais interessante, mas as vezes manual o nosso desenvolvimento. Com este Shield Ethernet ainda mantive a ideia do webservice, mas notei meu projeto estável sem necessitar de resets.
Segue o código para o Ethernet Shield ENC28J60
// A simple web server that always just says "Hello World"
#include "etherShield.h"
#include "ETHER_28J60.h"
static uint8_t mac[6] = {
0x23, 0x54, 0x12, 0x09, 0xEF, 0x54};
static uint8_t ip[4] = {
192, 168, 145, 15}; // the IP address for your board. Check your home hub
static uint16_t port = 80; // Use port 80 - the standard for HTTP
ETHER_28J60 ethernet;
void setup()
{
Serial.begin(9600);
Serial.println("Start");
ethernet.setup(mac, ip, port);
}
void loop()
{
char* param;
if (param = ethernet.serviceRequest())
{
Serial.println("new client");
String parametro = param;
if ( parametro.indexOf("/") > 0 )
{
String funcao = parametro.substring(0, parametro.indexOf("/"));
parametro = parametro.substring(parametro.indexOf("/")+1);
Serial.println(param);
Serial.println(funcao);
ethernet.print("HTTP/1.1 200 OK\n\r");
ethernet.print("Content-Type: text/plain\n\r \n\r");
ethernet.print("{""param"" : """);
ethernet.print( param );
ethernet.print("""}");
ethernet.respond();
}
ethernet.respond();
delay(1);
}
}
E agora o mesmo código para o Ethernet Shield WIZ 5100:
#include "SPI.h"
#include "Ethernet.h"
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0x23, 0x54, 0x12, 0x09, 0xEF, 0x54 };
IPAddress ip(192,168,145, 15);
EthernetServer server(80);
String param = String(100);
void setup() {
Serial.begin(9600);
Serial.println("Start");
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
}
void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
param = "";
String readString = String(100);
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (readString.length() < 100) { //store characters to string readString += c; } if (readString.substring(0,7) == "100GET " && param == "" ) { if ( c == ' ' ) { if ( readString.length() > 7 )
{
Serial.println("URL Acessada:" + readString.substring(7,100) );
param = readString.substring(7,100);
}
}
}
if (c == '\n' && currentLineIsBlank) {
String parametro = param.substring(1,100);
if ( parametro.indexOf("/") > 0 )
{
String funcao = parametro.substring(0, parametro.indexOf("/"));
parametro = parametro.substring(parametro.indexOf("/")+1);
Serial.println(param);
Serial.println(funcao);
client.print("HTTP/1.1 200 OK\n\r");
client.print("Content-Type: text/plain\n\r\n\r");
client.println();
client.print("{""param"" : """);
client.print( param );
client.print("""}");
}
break;
}
if (c == '\n') {
// you're starting a new line
currentLineIsBlank = true;
}
else if (c != '\r') {
// you've gotten a character on the current line
currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
// close the connection:
client.stop();
Serial.println("client disconnected");
}
}
Concluindo o melhor Ethernet Shield para Arduino é o WIZ 5100, mas se tiver paciência e quiser contornar alguns problemas pode usar o ENC28J60.