Arduino Ethernet Shield

Mã sản phẩm: (Đang cập nhật...)
Thương hiệu: cập nhật
Còn hàng
156.000₫

Arduino Ethernet Shield Hoạt động tại điện áp 5V, Tốc độ kết nối: 10/100Mb, Kết nối với mạch Arduino qua cổng SPI

Freeship đơn hàng từ 500k

Kiểm tra khi nhận hàng

Hỗ trợ khách hàng 24/7

Phiên bản shield này có tích hợp  khe cắm thẻ micro SD, có thể được sử dụng để lưu trữ các tập tin phục vụ qua mạng. Mạch Arduino Ethernet Shield tương thích với Arduino Uno và Mega (sử dụng Ethernet Thư viện). Bạn có thể truy cập vào khe cắm thẻ trên board và sử dụng thư viện SD được bao gồm  tích hợp trong bộ thư viện có sẵn trong trình biên dịch arduino.

IC điều khiển W5100 trên Arduino Ethernet Shield có thể thực hiện truyền dữ liệu thông qua 2 giao thức là TCP và UDP. Số đường truyền dữ liệu song song tối đa là 4. Đây chính là điểm mạnh của W5100 so với Microchip ENC28J60. Khả năng truyền song song cùng lúc 4 luồng dữ liệu giúp board có khả năng nhận dữ liệu từ internet với tỉ lệ lỗi thấp hơn (nguyên nhân thường là do mất dữ liệu trên đường truyền hoặc do thời gian truyền vượt quá giới hạn – time out).

THÔNG SỐ Arduino Ethernet Shield

  • Để sử dụng phải có board mạch Arduino đi kèm
  • Hoạt động tại điện áp 5V (được cấp từ mạch Arduino)
  • Chip Ethernet: W5100 với buffer nội 16K
  • Tốc độ kết nối: 10/100Mb
  • Kết nối với mạch Arduino qua cổng SPI
  • Thư viện và code mẫu có sẵn trong chương trình Arduino.

Lưu ý : Bởi vì W5100 và SD card sử dụng chung chuẩn truyền SPI, vì vậy một thiết bị duy nhất có thể được hoạt động tại một thời điểm. Nếu bạn đang sử dụng cả hai thiết bị ngoại vi trong chương trình của bạn, điều này cần được xử lý bởi các thư viện tương ứng. 

HÌNH ẢNH THỰC TẾ

HƯỚNG DẪN SỬ DỤNG

Thư viện SPI.h

Thư viện Ethernet.h

——————————-CODE MẪU——————————————

/*  
  Mở Control Panel -> Network and Internet -> View network status and tasks -> Wi-Fi (Linh Kien Dien Tu NSHOP) -> Details... -> IP v4 Address: 192.168.1.7
  Copy  192.168.1 từ IP v4 Address paste vào IPAddress ip(192, 168, 19, 177);, giữ lại 177 ở cùng, tức là IPAddress ip(192, 168, 1, 177);
  Cắm shield vào arduino nạp code ethernetShield.ino
  Cắm dây LAN vào shield.
  Truy cập web 192.168.1.177 để kiểm tra.
*/

#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, 177); //--------------------------------------------------------------thay địa chỉ IP v4 ở đây

// 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() {
  // You can use Ethernet.init(pin) to configure the CS pin
  //Ethernet.init(10);  // Most Arduino shields
  //Ethernet.init(5);   // MKR ETH shield
  //Ethernet.init(0);   // Teensy 2.0
  //Ethernet.init(20);  // Teensy++ 2.0
  //Ethernet.init(15);  // ESP8266 with Adafruit Featherwing Ethernet
  //Ethernet.init(33);  // ESP32 with Adafruit Featherwing Ethernet

  // Open serial communications and wait for port to open:
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Ethernet WebServer Example");

  // start the Ethernet connection and the server:
  Ethernet.begin(mac, ip);

  // Check for Ethernet hardware present
  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.  Sorry, can't run without hardware. :(");
    while (true) {
      delay(1); // do nothing, no point running without Ethernet hardware
    }
  }
  if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Ethernet cable is not connected.");
  }

  // start the server
  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
    bool 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 == '
' && 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 == '
') {
          // 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");
  }
}
Xem thêm Thu gọn

Xin mời nhập nội dung tại đây