
Description:
The Ethernet Shield W5500 and mount a data logger to store data on an SD card installed in the shield.
The Ethernet Shield W5500:
The first difference that we notice in the Ethernet Shield W5500 and which is quite pleasing is the size and positioning of the ethernet connector (RJ45). Unlike other boards, it has a reduced size and has been placed in such a way that you can fit another shield over it, if necessary:
We also have a reset button and also an SD card slot (maximum of 2GB, FAT16 or FAT32), which allows you to store web data on a memory card or even upload a web page from it.
Internally, the W5500 has stability and performance enhancements and increased connection capacity: 8 sockets, which means you can connect the W5500, for example, to 8 web pages simultaneously, or create a web server that accepts 8 connections at the same time. For comparison purposes, the W5100 supports up to 4 connections.
Another very important detail of the W5500 ethernet shield is that it works with 3.3V on the signal pins, but is tolerant to 5V, so you can use the shield with both Arduino Uno and Mega, working with 5V, as with Arduino Due, Intel Edison and Linkit One, which work with 3.3V.
Below, other features of the W5500 shield:
Supported Protocols: TCP, UDP, ICMP, IPv4, ARP, IGMP, PPPoE
Power Down Mode
Wake on Lan (UDP) support
32K internal memory for receive and transmit buffers (RX / TX)
10BaseT / 100BaseTX Ethernet PHY
Auto negotiation: full and half duplex
Led indicators: Full / Halp Duples, Link, Speed and Active
And finally, the pins used by the shield to communicate with the Arduino:
Digital Pin 4: CS (Chip Select) of the SD card
Digital Pin 10: CS (Chip Select) of the W5500
Digital Pin 11: SPI Interface – MOSI
Digital Pin 12: SPI Interface – MISO
Digital Pin 13: SPI Interface – SCK
Data logger and Web Server with W5500:
// Program: Datalogger with Ethernet Shield W5500 // Author: Arduino e Cia #include <SD.h> #include <SPI.h> #include <Ethernet.h> const int chipSelect = 4 ; // Define the MAC Address using the card's address or // assigning a MAC manually #if defined (WIZ550io_WITH_MACADDRESS) ; #else mac byte [] = { 0xDE , 0xAD , 0xBE , 0xEF , 0xFE , 0xED }; #endif // Change the IP below according to the IP address of your network IPAddress ip ( 192 , 168 , 15 , 100 ); // Initialize the Web server on port 80 EthernetServer server ( 80 ); void setup () { Serial.begin ( 9600 ); // Initialize ethernet connection #if defined (WIZ550io_WITH_MACADDRESS) Ethernet.begin (ip); #else Ethernet.begin (mac, ip); #endif server.begin (); // Displays the Serial.print IP address on the serial monitor ( "Server not IP address:" ); Serial.println (Ethernet.localIP ()); // Initializes SD card Serial.print ( "Initializing SD card ..." ); // Check if the card is present or with error if (! SD.begin (chipSelect)) { Serial.println ( "Error in card or card not inserted!" ); // do not do anything more: return ; } Serial.println ( "Initialized Card." ); Serial.println (); Serial.println ( "Waiting for connections ...." ); } void loop () { // Awaiting connections EthernetClient client = server.available (); if (client) { Serial.println ( "New connection" ); boolean currentLineIsBlank = true; while (client.connected ()) { if (client.available ()) { char c = client.read (); Serial.write (c); if (c == '\ n' && currentLineIsBlank) { // Send a standard response HTTP client.println ( "HTTP / 1.1 200 OK" ); client.println ( "Content-Type: text / html" ); client.println ( "Connection: close" ); // Reload the page every 10 seconds client.println ( "Refresh: 10" ); client.println (); client.println ( "<! DOCTYPE HTML>" ); client.println ( "<html>" ); // Read analog ports int value_porta0 = analogRead ( 0 ); int value_port1 = analogRead ( 1 ); int value_porta2 = analogRead ( 2 ); // Displays the values in the client.print browser ( "Analog port 0:" ); client.print (value_port0); client.print ( "<br/>" ); client.print ( "Analog port 1:" ); client.print (value_port1); client.print ( "<br/>" ); client.print ( "Analog port 2:" ); client.print (value_port2); client.print ( "<br/>" ); // Write values read on SD card // Open file .txt File datafile = SD.open ( "datalogger.txt" , FILE_WRITE); // If file.txt is available, write the data if (datafile) { datafile.print ( "Analog port 0:" ); datafile.println (value_port0); datafile.print ( "Analog port 1:" ); datafile.println (value_port1); datafile.print ( "Analog port 2:" ); datafile.println (value_port2); datafile.println (); datafile.close (); // Warning message on serial monitor Serial.println ( "Data recorded on SD card" ); } // Error message if datalogger.txt is not available // else { Serial.println ( "Error opening datalogger.txt" ); } break ; } if (c == '\ n' ) { currentLineIsBlank = true; } else if (c! = '\ r' ) { currentLineIsBlank = false; } } } delay ( 1 ); client.stop (); Serial.println ( "client disconnected" ); } }
The program performs the configuration of the Ethernet Shield IP settings (IP address, mask, gateway, etc.), and also verifies that the SD card has been correctly inserted. If everything is ok, show this information in the Serial Monitor and wait for the connection to the web server:
In the browser of your choice, enter the IP address that was shown on the serial monitor. Information about the analog ports will be shown on the screen:
More Information :
https://www.arduinoecia.com.br/2017/08/data-logger-ethernet-shield-w5500.html
COMMENTS