Leonardo ETH V2 with ATmega32U4 & W5500 Ethernet
Opis
The Leonardo ETH is a microcontroller board based on the ATmega32U4 and the W5500 TCP/IP embedded Ethernet controller.
It has 22 digital input/output pins (of which 7 can be used as PWM outputs and 12 as analog inputs), a 16MHz crystal oscillator, a RJ45 connector, a micro USB connector, a DC power jack, an ICSP header, and a RESET button. The board can be easily connected to a computer by means of a Micro-USB cable. Power can be supplied either from a battery (not included), an AC-to-DC adapter (not included) or through the USB port directly from a PC.
An onboard microSD card slot allows adding a microSD card to store files for serving over the network. The card is accessible through the SD Library.
Depending on your preferences and libraries used, Leonardo ETH can appear as a native mouse and/or keyboard to a connected computer, in addition to a virtual (CDC) serial / COM port.
Optional Power over Ethernet module can be used with this board as well.
Documents
Dimensional drawing (DIM) |
||||
Input and Output (I/O) diagram |
||||
Schematic |
...........
Tutorial
Pins usage on Leonardo ETH (V2)
For Ethernet W5500 Chipset:
- D10 — SS (CS1)
- D16 — MOSI
- D14 — MISO
- D15 — SCK
- D8 — INT (select with W5500-INT pin jumper)
- D11/3.3V — RST (select with W5500-RST pin jumper, 3.3V — default)
For SD card reader:
- D4 — CS(CS2)
- D16 — MOSI/DI
- D14 — MISO/DO
- D15 — SCK/CLK
Steps for Arduino IDE:
- Select port:
- Select board:
- Please install the libraries:
- SD.h — SD Library
- SPI.h — SPI library
- Ethernet.h/Ethernet2.h/ Ethernet3.h — Ethernet / Ethernet2 / Ethernet3 libraries
- Copy below code into the sketch and then upload:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
/* Initialize code for Leonardo ETH, Ethernet module W5500 */ #include #include #include #define SS 10 //W5500 CS #define RST 11 //W5500 RST #define CS 4 //SD CS pin // Enter a MAC address for your controller below. // Newer Ethernet shields have a MAC address printed on a sticker on the shield #if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io ; #else byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED}; #endif // Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client; File myFile; boolean state=true; void setup() { pinMode(LED_BUILTIN, OUTPUT); digitalWrite(LED_BUILTIN, HIGH); pinMode(SS, OUTPUT); pinMode(RST, OUTPUT); pinMode(CS, OUTPUT); digitalWrite(SS, LOW); digitalWrite(CS, HIGH); // Open serial communications and wait for port to open: Serial.begin(9600); Serial.println("Start!"); // this check is only needed on the Leonardo: while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only } // start the Ethernet connection: #if defined(WIZ550io_WITH_MACADDRESS) // Use assigned MAC address of WIZ550io if (Ethernet.begin() == 0) { #else if (Ethernet.begin(mac) == 0) { #endif 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(); digitalWrite(SS, HIGH); digitalWrite(CS,LOW); delay(10); if (!SD.begin(CS)) { Serial.println("No SD card!"); return; } // open the file. note that only one file can be open at a time, // so you have to close this one before opening another. myFile = SD.open("test.txt", FILE_WRITE); // if the file opened okay, write to it: if (myFile) { Serial.print("Writing to test.txt..."); myFile.println("testing 1, 2, 3."); // close the file: myFile.close(); Serial.println("done."); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } // re-open the file for reading: myFile = SD.open("test.txt"); if (myFile) { Serial.println("test.txt:"); // read from the file until there's nothing else in it: while (myFile.available()) { Serial.write(myFile.read()); } // close the file: myFile.close(); } else { // if the file didn't open, print an error: Serial.println("error opening test.txt"); } SD.remove("test.txt"); delay(50); } void loop() { digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level) delay(1000); // wait for a second digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW delay(1000); Serial.print("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(); Serial.println(); delay(5000); }
- If you want to control Reset function of W5500 Ethernet controller, with I/O D7. Please add to sketch:
1
digitalWrite(RST,HIGH);
- Result