Con el shield Ethernet W5100S de DFRobot podrá conectar su Arduino a Internet con un cable RJ45. Usa este shield es tan fácil como montarlo sobre la placa Arduino, grabar el código de muestras (ver la sección de ejemplos) en tu Arduino y luego podrás hacer proyectos de IoT de forma fácil con una comunicación estable.
Este shield esta basada en el chip Ethernet WizNet WS5100S, esta placa integra un stack de protocolos TCP/IP cableados completo y tiene 4 Socket de Hardware independientes.
Su placa Arduino puede comunicarse con el W5100S y la tarjeta SD a través de la Interfaz SPI (use el pin ICPI). La shield Ethernet es compatible con Arduino UNO y MEGA
Descripción de Indicadores LEDs
LED (Serigrafía) | Descripción |
---|---|
L | Indicador de Señal PIN D13 |
PWR | Indicador de Aliemntación |
COL | Indicador de detección de conflicto de conexión Nivel bajo: se produce conflicto Nivel alto: sin conflicto |
ACT | Indicador de actividad Sin flash: conectado, pero no se transmiten ni reciben datos Parpadeando: conectado, parpadeando según la transmisión de datos |
DPX | Indicador de Full duplex Nivel bajo: Full duplex Nivel alto: Half duplex |
100M | Indicador de velocidad de conexión Nivel bajo: 100Mbps Nivel alto: 10Mbps |
LINK | Indicador de estado de conexión Nivel bajo: conectado Nivel alto: desconectado |
Características
# | Descripción | Valor |
---|---|---|
1 | Voltaje de funcionamiento | 5V |
2 | Buffers | 16GB TX/RX |
3 | Hardware independientes | 4 Sockets (simultáneamente) |
4 | Stack | Protocolo TCP/IP de hardware completo + MAC + PHY |
5 | Temperatura de funcionamiento | -40ºC ~ 85ºC |
6 | Dimensiones | 70mm × 55mm × 30mm (2.76″ × 2.15″ × 1.18″) |
Documentación
Título | Link |
---|---|
Libreria para Arduino | |
Conexiones | |
Dimensiones | |
Modelo 3D (SnapEDA) |
Tutorial
Requisitos
Hardware
- 1x Arduino UNO
- 1x Ethernet Shield W5100S
- 1x Cable de red
- 1x Ruoter o Switch
- 1x Cables jumper M-M/M-H/H-H
- 2x LED 5mm
- 2x resistencias 330 Ohm
Software
- Arduino IDE
- La libreria Descargada (ver sección Documentación)
Diagrama
Este ejemplo permite que otros dispositivos dentro de la misma LAN controlen el estado de lo pines IO2 e IO3 a través de la página web simple.
#include <SPI.h> #include <Ethernet.h> //Define digital output IO port uint8_t D2 =2; uint8_t D3 =3; int value = LOW; int value1 = LOW; // Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = {0xDE, 0xCD, 0xAE, 0x0F, 0xFE, 0xED }; // 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 //Set digital IO port to output mode pinMode(D2,OUTPUT); pinMode(D3,OUTPUT); // start the Ethernet connection: if(Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // no point in carrying on, so do nothing forevermore: for(;;); } // print your local IP address: Serial.print("My IP address: "); for(byte thisByte = 0; thisByte < 4; thisByte++){ // print the value of each byte of the IP address: Serial.print(Ethernet.localIP()[thisByte], DEC); Serial.print("."); } Serial.println(); // start the Ethernet connection and the server: server.begin(); Serial.print("server is at "); Serial.println(Ethernet.localIP()); } void loop() { // listen for incoming clients EthernetClient client = server.available(); String request; 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); request +=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("Connnection: close"); client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); // add a meta refresh tag, so the browser pulls again every 5 seconds: client.println("<meta http-equiv=\"refresh\" content=\"5\">"); client.println("<link rel=\"stylesheet\" type=\"text/css\" href=\"http://www.dfrobot.com/ihome/stylesheet/stylesheet.css\" />"); client.println("<center> <a href=\"http://www.dfrobot.com\"><img src=\"http://alturl.com/qf6vz\"></a> </center> "); client.println("<br />"); client.println("<div>"); client.flush(); /********************************Page display section***********************************/ //Determines whether there is information in the HTTP request that controls the output pins and, if so, sets the output state of the outlet based on the information if(request.indexOf("GET /D2=ON") != -1){ digitalWrite(D2, HIGH); value = HIGH; } if(request.indexOf("GET /D2=OFF") != -1){ digitalWrite(D2, LOW); value = LOW; } //Reply the status of the set digital IO port according to the request message client.print("Digital_2 output: "); if(value == HIGH){ client.print("ON"); } else{ client.print("OFF"); } client.println("<br><br>"); //In the web page set control D2 port hyperlink, used for web control development board digital output IO port state client.println("Turn <a href=\"/D2=ON\">ON</a><br>"); client.println("Turn <a href=\"/D2=OFF\">OFF</a><br>"); if(request.indexOf("GET /D3=ON") != -1) { digitalWrite(D3, HIGH); value1 = HIGH; } if(request.indexOf("GET /D3=OFF") != -1){ digitalWrite(D3, LOW); value1 = LOW; } client.println("<br />"); client.print("Digital_3 output: "); if(value1 == HIGH){ client.print("ON"); } else{ client.print("OFF"); } client.println("<br><br>"); client.println("Turn <a href=\"/D3=ON\">ON</a><br>"); client.println("Turn <a href=\"/D3=OFF\">OFF</a><br>"); /****************************************************************************/ client.println("</html>"); 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 disonnected"); } }
Resultados
Cargue el código a su placa Arduino y luego abra el monitor en serie, copie la dirección IP desde el moniutor en serie y pégala en el navegador de otro dispositivo dentro de la misma LAN para acceder a la página web y ver o controlar el estado de los pines I/O a través de ella.
Valoraciones
No hay valoraciones aún.