Ks0156 keyestudio W5100 Ethernet Shield: Difference between revisions

From Keyestudio Wiki
Jump to navigation Jump to search
No edit summary
Line 1: Line 1:
[[image:ks0156.png|thumb|600px|right|Keyestudio W5100 Ethernet Shield]]
[[image:ks0156.png|thumb|500px|right|Keyestudio W5100 Ethernet Shield]]


==Introduction==
==Introduction==

Revision as of 09:30, 27 September 2018

Keyestudio W5100 Ethernet Shield

Introduction

keyestudio W5100 Ethernet Shield gives you an easy way to get your Arduino Online. It can turn your Arduino into a simple web server or use the Internet to read /write its digital and analog outputs/inputs.
Compatible with the UNO R3 board and Mega 2560 R3.
It is directly supported by Arduino official Ethernet Library. It also supports the read &write of mini SD card (TF card).
The shield adopts stackable design. You can directly plug it to Arduino board or plug other shields onto this Ethernet shield. .

Features

  • Compatible with UNO R3 and MEGA 2560 control board.
  • Comes with a SD card slot, supporting the read/write of mini SD card (TF card).
  • Comes with a reset button
  • Onboard comes with a D13 led
  • Comes with a network connector, used to connect the network.
  • Comes with several LED indicators for various status, such as network connection, powering on and communication situation.
  • Support TCP/IP protocols


thumb

Technical Details

  • Dimensions: 73mm x 54mm x 29mm
  • Weight: 25.4g


thumb

PINOUT Instruction


thumb

Indicator light functions

  • L: D13 LED ( D13 light up at HIGH, off at LOW)
  • PWR: power led
  • LINK: the network is connected. It will flash when send or receive the data
  • 100M: the network connection is in 100M/s
  • FULLD: the network connection is full duplex communication
  • COLL: flashing when the network detects a conflict.
  • RX: flashing when the network receives data.
  • TX: flashing when the network sends data.


Test Code

Below is an example code.
Click here to download the libraries.
Click here to download the code
Or you can directly copy and paste the code below to Arduino IDE.

#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[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1,129);//modifying according your own IP
// 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:
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");
// 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 each analog input pin
for (int analogChannel = 0; analogChannel < 6; analogChannel++) {
int sensorReading = analogRead(analogChannel);
client.print("analog input ");
client.print(analogChannel);
client.print(" is ");
client.print(sensorReading);
client.println("<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");
}
}

Code to Note:
1.Before compile the code, do remember to add the necessary libraries inside the libraries directory of Arduino IDE.
Download the libraries from below link:
https://drive.google.com/open?id=13zBGFTWGFiu6g2E-eACOB_Q52B3tVGiS
2. In the code, you can set the MAC, byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }, the content value can be set by yourself. It is hexadecimal.
3. Set the IP address ip(192,168,1,129) in the code. It is the IP address that connected to the network connector on the shield.

Example Result

Stack the shield onto the MEGA2560 board, then upload the code to MEGA 2560 and connect the network, open the Google browser and enter the IP address, it will display the analog data of A0-A5. Shown below.
thumb thumb

Resources

PDF
https://drive.google.com/open?id=17r39-lmR9UtkqUgdGAtCBKcQ-MS-veL2

Get One Now

Official Website
http://www.keyestudio.com/keyestudio-w5100-ethernet-shield-for-arduino-uno-r3-mega-2560.html

Amazon
https://www.amazon.com/keyestudio-Ethernet-Shield-Arduino-Mega2560-Uno-R3/dp/B01E5JY7UU/ref=sr_1_fkmr0_1?ie=UTF8&qid=1479111445&sr=8-1-fkmr0&keywords=Keyestudio+W5100+Ethernet+Shield+for+arduino+UNO+R3+%2BMega+2560