Pular para o conteúdo principal

W5500 Ethernet Shield v1.0

pir

O W5500 Ethernet Shield v1.0 pode fornecer conectividade com a Internet para seus projetos. O W5500 permite que os usuários tenham conectividade com a Internet em suas aplicações utilizando um único chip, no qual estão incorporados a pilha TCP/IP, MAC Ethernet 10 / 100 e PHY. O shield também possui dois conectores Grove e um soquete para cartão microSD para suportar projetos que exigem o armazenamento de grandes quantidades de dados provenientes de sensores Grove. A porta RJ45 (onde o cabo Ethernet é conectado) é baixa o suficiente para permitir que você empilhe mais shields sobre este, se necessário.

Recursos


  • Suporta protocolos TCP/IP cabeados: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE
  • Suporta 8 sockets independentes simultaneamente
  • Suporta modo de economia de energia (Power down)
  • Suporta Wake on LAN via UDP
  • Suporta interface Serial Peripheral de alta velocidade (SPI MODO 0, 3)
  • Memória interna de 32 Kbytes para buffers TX/RX
  • PHY Ethernet 10BaseT/100BaseTX incorporado
  • Suporta Auto Negotiation (full e half duplex, 10 e 100* baseado)
  • Não suporta fragmentação de IP
  • Operação em 3,3 V com tolerância a sinal de E/S de 5 V
  • Saídas de LED (full/half duplex, link, velocidade, ativo)
  • Soquete para cartão micro-SD
  • Conectores Grove para I2C e UART

Visão Geral de Hardware


pir

Configuração de Hardware

  1. RJ45: Porta Ethernet;
  2. CI W5500: um controlador Ethernet TCP/IP cabeado;
  3. Botão de Reset: reseta o Ethernet shield;
  4. Soquete para Cartão SD: suporta cartão Micro SD em FAT16 ou FAT32; armazenamento máximo é de 2 GB.
  5. Interface I2C
  6. Interface UART

Uso de pinos no Arduino

  1. D4: seleção de chip do cartão SD
  2. D10: seleção de chip do W5200
  3. D11: SPI MOSI
  4. D12: SPI MISO
  5. D13: SPI SCK
nota

Tanto o W5500 quanto o cartão SD se comunicam com o Arduino por meio do barramento SPI. O pino 10 e o pino 4 são pinos de seleção de chip para o W5500 e o slot SD. Eles não podem ser usados como E/S gerais.

Uso

Mostraremos um exemplo. Este exemplo pode enviar dados para uma página web e armazenar os dados do seu sensor no cartão SD.

Hardware

Lista de Peças:

Nome

Função

Qtde

W5500 Ethernet Shield

Fornecer conectividade Ethernet

1

Seeeduino V4.2

Controlador

1

Grove-Temp&Humi Sensor

Sensor

1

Base Shield V2

Base Shield

1

Cartão Micro SD

Armazenar dados

1

Procedimento:

  1. Monte o W5500 Ethernet Shield v1.0 no seu Arduino, monte o Base Shield V2 sobre o Ethernet Shield e conecte o sensor Grove-Temp&Humi à porta Grove D5 do Base Shield; insira o cartão SD.
  2. Conecte o Ethernet Shield à rede com um cabo Ethernet padrão;
  3. Conecte o Arduino ao PC via cabo USB;

pir

Software

  • Instale a biblioteca no seu Arduino IDE quando o download for concluído.
  • Copie o código abaixo para o sketch e, em seguida, faça o upload:
//This sketch uses W5500 Ethernet Shield,Seeeduino V4.2,Grove-Temp&Humi,
//Base Shield V2 Sensor and Micro SD Card to design a temperature and humidity collection station.
//attach the temperature and humidity sensor to base shield D5 grove port.
//It publishes the temperature and humidity data to webpage
//and refresh every 5 seconds, store the data into SD card datalog.txt file.

#include <SD.h>
#include <SPI.h>
#include <Ethernet.h>
#include <dht11.h>
dht11 DHT;
#define DHT11_PIN 5
const int chipSelect = 4;

// Please update IP address according to your local network
#if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io
;
#else
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
#endif
IPAddress ip(192,168,0,177);

// Initialize the Ethernet server library
// with the IP address and port you want to use
// (port 80 is default for HTTP):
EthernetServer server(80);

void setup() {
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}

// start the Ethernet connection and the server:
#if defined(WIZ550io_WITH_MACADDRESS)
Ethernet.begin(ip);
#else
Ethernet.begin(mac, ip);
#endif
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());

//initializing the SD card
Serial.print("Initializing SD card...");

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
}


void loop() {
// listen for incoming clients
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// an http request ends with a blank line
boolean currentLineIsBlank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
Serial.write(c);
// if you've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so you can send a reply
if (c == '\n' && currentLineIsBlank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println("Connection: close"); // the connection will be closed after completion of the response
client.println("Refresh: 5"); // refresh the page automatically every 5 sec
client.println();
client.println("<!DOCTYPE HTML>");
client.println("<html>");

// output the value of input pin on web
int chk;
chk = DHT.read(DHT11_PIN); // READ DATA
client.print("Humidity: ");
client.print(DHT.humidity);
client.println("<br />");
client.print("Temperature: ");
client.print(DHT.temperature);

//write value of input pin into SD card
// make a string for assembling the data to log:
String dataString = "";
// read the humidity and temperature and append to the string:
dataString = String(DHT.humidity) + String(DHT.temperature);
// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.
File dataFile = SD.open("datalog.txt", FILE_WRITE);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
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");
}
}

Resultados

Agora, mostraremos o resultado.

  1. Coloque seu cartão SD no computador; você verá algumas informações de temperatura e umidade.
  2. Além disso, podemos ver as informações na web.

pir

Não é muito fácil? Você já pode começar o seu projeto.

Visualizador Online do Esquemático

Recursos

Suporte Técnico e Discussão de Produto

Obrigado por escolher nossos produtos! Estamos aqui para fornecer diferentes tipos de suporte para garantir que sua experiência com nossos produtos seja a mais tranquila possível. Oferecemos vários canais de comunicação para atender a diferentes preferências e necessidades.

Loading Comments...