Reference   Language | Libraries | Comparison | Changes

Ethernet / Ethernet 2 library

These libraries are designed to work with the Arduino Ethernet Shield (Ethernet.h) or the Arduino Ethernet Shield 2 and Leonardo Ethernet (Ethernet2.h). The libraries are allow an Arduino board to connect to the internet. The board can serve as either a server accepting incoming connections or a client making outgoing ones. The libraries support up to four concurrent connection (incoming or outgoing or a combination). Ethernet library (Ethernet.h) manages the W5100 chip, while Ethernet2 library (Ethernet2.h) manages the W5500 chip; all the functions remain the same. Changing the library used allows to port the same code from Arduino Ethernet Shield to Arduino Ethernet 2 Shield or Arduino Leonardo Ethernet and vice versa.

Arduino communicates with the shield using the SPI bus. This is on digital pins 11, 12, and 13 on the Uno and pins 50, 51, and 52 on the Mega. On both boards, pin 10 is used as SS. On the Mega, the hardware SS pin, 53, is not used to select the W5100, but it must be kept as an output or the SPI interface won't work.

Examples

Ethernet class

The Ethernet class initializes the ethernet library and network settings.

IPAddress class

The IPAddress class works with local and remote IP addressing.

Server class

The Server class creates servers which can send data to and receive data from connected clients (programs running on other computers or devices).

Client class

The client class creates clients that can connect to servers and send and receive data.

EthernetUDP class

The EthernetUDP class enables UDP message to be sent and received.

Reference Home

Corrections, suggestions, and new documentation should be posted to the Forum.

The text of the Arduino reference is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.

Share