arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
259 stars 264 forks source link

Documentation updates related to the 2.0.0 release #67

Closed per1234 closed 6 years ago

per1234 commented 6 years ago

Changes to existing pages

I have also included improvement suggestions not related to the 2.0.0 release for the affected reference pages because it seems like it will be easier for the person updating the page to make all necessary changes to a page at the same time, rather than addressing multiple issue reports.


https://www.arduino.cc/en/Reference/Libraries Change:

  • Ethernet / Ethernet 2 - for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH

To:

  • Ethernet - for connecting to the internet using the Arduino Ethernet Shield, Arduino Ethernet Shield 2 and Arduino Leonardo ETH

https://www.arduino.cc/en/Reference/Ethernet Change:

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.

To:

Ethernet library

This library is designed to work with the Arduino Ethernet Shield, Arduino Ethernet Shield 2, Leonardo Ethernet, and any other W5100/W5200/W5500-based devices. The library allows 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 library supports up to eight (W5100 and boards with <= 2 kB SRAM are limited to four) concurrent connections (incoming, outgoing, or a combination).

The Arduino board 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 Ethernet controller chip, but it must be kept as an output or the SPI interface won't work.


https://www.arduino.cc/en/Tutorial/WebClient Change:

The results of this search are viewable as HTML through your Arduino's serial window.

To:

The results of this search are viewable as HTML in the Serial Monitor.


Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/WebClientRepeating

Change:

The conent of the page is viewable through your Arduino's serial window.

To:

The content of the page is viewable in the Serial Monitor.


Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/WebServer

Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/BarometricPressureWebServer

Change:

Your Barometric Pressure sensor will be attached to pins 6,7, and 11 - 13

To:

Your Barometric Pressure sensor will be attached to pins 6, 7, and the SPI pins


Change:

Your sensor's MOSI (Master Out Slave In) pin should then be connected to digital pin 11, and it's counterpart MISO (Master In Slave Out) to digital pin 12. Finally, connect the SCK pin, the SPI clock input on your sensor, to digital pin 13 on your device, and make sure that the two share a common ground.

To:

Your sensor's MOSI (Master Out Slave In), MISO (Master In Slave Out), and SCK (SPI clock input) pins should then be connected to the SPI pins on your Arduino board/shield. The SPI pin numbers differ depending on which Arduino board you're using and are listed in the SPI reference page. Make sure that the two share a common ground.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/UDPSendReceiveString

Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/UdpNtpClient

Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/DhcpChatServer

Change:

The Serial monitor works well for this purpose.

To:

The Serial Monitor works well for this purpose.


Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/DhcpAddressPrinter

Change:

Using the localIP() function, the assigned IP address is sent out via the serial monitor.

To:

Using the localIP() function, the assigned IP address is sent out via the Serial Monitor.


Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Tutorial/TelnetClient

Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


Change:

The Serial monitor works well for this purpose.

To:

The Serial Monitor works well for this purpose.


Change:

The Ethernet shield allows you to connect a WizNet Ethernet controller to the Arduino or Genuino boards via the SPI bus.

To:

The Ethernet shield allows you to connect a WIZnet Ethernet controller to the Arduino or Genuino boards via the SPI bus.


Change:

It uses pins 10, 11, 12, and 13 for the SPI connection to the WizNet.

To:

It uses the ICSP header pins and pin 10 as chip select for the SPI connection to the Ethernet controller chip.


Change:

The shield should be connected to a network with an ethernet cable.

To:

The shield should be connected to a network with an Ethernet cable.


Change:

image developed using Fritzing.

To:

Image developed using Fritzing.

Remove: Please note: according to your hardware setup, you need to comment / uncomment the libraries at the beginning of the sketch. Use Ethernet.h with the Arduino Ethernet Shield or Ethernet2.h with the Arduino Ethernet Shield 2 and Leonardo Ethernet.


https://www.arduino.cc/en/Guide/ArduinoEthernetShield

Change:

The Arduino Ethernet shield 2

To:

The Arduino Ethernet Shield 2


Remove:

Depending on the shield version you have, you need to use the proper library, as documented in the Ethernet library page.


Change:

Here a list of tutorials that will help you in making very cool things!

To:

Here is a list of tutorials that will help you in making very cool things!


https://store.arduino.cc/arduino-ethernet-shield-2

Change:

Learn more on the Ethernet Shield 2 in the Ethernet2 Library reference

To:

Learn more on the Ethernet Shield 2 in the Ethernet Library reference


https://www.arduino.cc/en/Reference/EthernetBegin

Change:

Initializes the ethernet library and network settings.

To:

Initializes the Ethernet library and network settings.


Change:

With version 1.0, the library supports DHCP.

To:

Version 1.0 and newer of the Ethernet library supports DHCP.


Change:

Using Ethernet.begin(mac) with the proper network setup

To:

Using Ethernet.begin(mac) with the proper network setup

Change: For older shields, choose your own.

To:

For older shields, choose any MAC you like so long as it's unique on your network.


Change:

ip: the IP address of the device (array of 4 bytes)

To:

ip: the IP address of the device (IPAddress)


Change:

the IP address of the DNS server (array of 4 bytes).

To:

the IP address of the DNS server (IPAddress).


Change:

the IP address of the network gateway (array of 4 bytes).

To:

the IP address of the network gateway (IPAddress).


Change:

the subnet mask of the network (array of 4 bytes).

To:

the subnet mask of the network (IPAddress)


Change:

The DHCP version of this function, Ethernet.begin(mac), returns an int

To:

The DHCP version of this function, Ethernet.begin(mac), returns an int


Add:

See also


https://www.arduino.cc/en/Reference/EthernetLocalIP

Change:

Returns

the IP address

To:

Returns

the IP address (IPAddress)


Add:

See also


https://www.arduino.cc/en/Reference/ServerAvailable

Change:

you can close it by calling client.stop().

To:

you can close it by calling client.stop().


Change:

See Also

  • Stream.available()

To:

See Also


New reference pages to create

Based partly on information from Paul Stoffregen's blog post: https://www.pjrc.com/arduino-ethernet-library-2-0-0/


https://www.arduino.cc/en/Reference/EthernetInit

Ethernet.init()

Description

Used to configure the CS (chip select) pin for the Ethernet controller chip. The Ethernet library has a default CS pin, which is usually correct, but with some non-standard Ethernet hardware you might need to use a different CS pin.

Syntax

Ethernet.init(sspin)

Parameters

sspin: the pin number to use for CS (byte)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Ethernet.init(53);  // use pin 53 for Ethernet CS
  Ethernet.begin(mac, ip);
}

void loop () {}

https://www.arduino.cc/en/Reference/ClientRemoteIP

remoteIP()

Description

Returns the IP address of the client.

Syntax

client.remoteIP()

Parameters

none

Returns

the client's IP address (IPAddress)

Example

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup() {
  // 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
  }

  // initialize the Ethernet device
  Ethernet.begin(mac, ip);

  // start listening for clients
  server.begin();
}

void loop() {
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client) {
    Serial.print("Remote IP address: ");
    Serial.println(client.remoteIP());
    client.stop();
  }
}

See also


https://www.arduino.cc/en/Reference/ClientLocalPort

localPort()

Description

Returns the local port number the client is connected to.

Syntax

client.localPort()

Parameters

none

Returns

the local port number the client is connected to (uint16_t)

Example

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup() {
  // 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
  }

  // initialize the Ethernet device
  Ethernet.begin(mac, ip);

  // start listening for clients
  server.begin();
}

void loop() {
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client) {
    Serial.print("Client is connected on port: ");
    Serial.println(client.localPort());
    client.stop();
  }
}

See also


https://www.arduino.cc/en/Reference/ClientRemotePort

remotePort()

Description

Returns the port of the host that sent the current incoming packet.

Syntax

client.remotePort()

Parameters

none

Returns

the port of the host that sent the current incoming packet (uint16_t)

Example

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup() {
  // 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
  }

  // initialize the Ethernet device
  Ethernet.begin(mac, ip);

  // start listening for clients
  server.begin();
}

void loop() {
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client) {
    Serial.print("Remote port: ");
    Serial.println(client.remotePort());
    client.stop();
  }
}

See also


https://www.arduino.cc/en/Reference/EthernetSetRetransmissionTimeout

Ethernet.setRetransmissionTimeout()

Description

Set the Ethernet controller's timeout. The initial value is 200 ms. A 200 ms timeout times the default of 8 attempts equals a blocking delay of 1600 ms during a communications failure. You might prefer to set a shorter timeout to make your program more responsive in the event something goes wrong with communications. You will need to do some experimentation to determine an appropriate value for your specific application.

Syntax

Ethernet.setRetransmissionTimeout(milliseconds)

Parameters

milliseconds: the timeout duration (uint16_t)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Ethernet.begin(mac, ip);
  Ethernet.setRetransmissionTimeout(50);  // set the Ethernet controller's timeout to 50 ms
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSetRetransmissionCount

Ethernet.setRetransmissionCount()

Description

Set the number of transmission attempts the Ethernet controller will make before giving up. The initial value is 8. 8 transmission attempts times the 200 ms default timeout equals a blocking delay of 1600 ms during a communications failure. You might prefer to set a lower number to make your program more responsive in the event something goes wrong with communications. Despite the name, this sets the total number of transmission attempts (not the number of retries after the first attempt fails) so the minimum value you would ever want to set is 1.

Syntax

Ethernet.setRetransmissionCount(number)

Parameters

number: number of transmission attempts the Ethernet controller should make before giving up (byte)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Ethernet.begin(mac, ip);
  Ethernet.setRetransmissionCount(1);  // configure the Ethernet controller to only attempt one transmission before giving up
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetClientSetConnectionTimeout

setConnectionTimeout()

Description

Set the timeout for client.connect() and client.stop(). The initial value is 1000 ms. You might prefer to set a lower timeout value to make your program more responsive in the event something goes wrong.

Syntax

client.setConnectionTimeout(milliseconds)

Parameters

milliseconds: the timeout duration for client.connect() and client.stop() (uint16_t)

Returns

Nothing

Example

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup() {
  // 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
  }

  // initialize the Ethernet device
  Ethernet.begin(mac, ip);

  // start listening for clients
  server.begin();
}

void loop() {
  // if an incoming client connects, there will be bytes available to read:
  EthernetClient client = server.available();
  if (client) {
    client.setConnectionTimeout(100);  // set the timeout duration for client.connect() and client.stop()
  }
}

See also


https://www.arduino.cc/en/Reference/EthernetServerAccept

accept()

Description

The traditional server.available() function would only tell you of a new client after it sent data, which makes some protocols like FTP impossible to properly implement.

The intention is programs will use either available() or accept(), but not both. With available(), the client connection continues to be managed by EthernetServer. You don’t need to keep a client object, since calling available() will give you whatever client has sent data. Simple servers can be written with very little code using available().

With accept(), EthernetServer gives you the client only once, regardless of whether it has sent any data. You must keep track of the connected clients. This requires more code, but you gain more control.

Syntax

server.accept()

Parameters

none

Returns

a Client object. If no client has data available for reading, this object will evaluate to false in an if-statement. (EthernetClient)

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(192, 168, 69, 104);

// telnet defaults to port 23
EthernetServer server(23);

EthernetClient clients[8];

void setup() {
  Ethernet.begin(mac, ip);

  // 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
  }

  // start listening for clients
  server.begin();
}

void loop() {
  // check for any new client connecting, and say hello (before any incoming data)
  EthernetClient newClient = server.accept();
  if (newClient) {
    for (byte i = 0; i < 8; i++) {
      if (!clients[i]) {
        newClient.print("Hello, client number: ");
        newClient.println(i);
        // Once we "accept", the client is no longer tracked by EthernetServer
        // so we must store it into our list of clients
        clients[i] = newClient;
        break;
      }
    }
  }

  // check for incoming data from all clients
  for (byte i = 0; i < 8; i++) {
    while (clients[i] && clients[i].available() > 0) {
      // read incoming data from the client
      Serial.write(clients[i].read());
    }
  }

  // stop any clients which disconnect
  for (byte i = 0; i < 8; i++) {
    if (clients[i] && !clients[i].connected()) {
      clients[i].stop();
    }
  }
}

See also


https://www.arduino.cc/en/Reference/IfEthernetServer

Description

Indicates whether the server is listening for new clients. You can use this to detect whether server.begin() was successful. It can also tell you when no more sockets are available to listen for more clients, because the maximum number have connected.

Syntax

if (server)

Parameters

none

Returns

whether the server is listening for new clients (bool)

Example

#include <Ethernet.h>
#include <SPI.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

// telnet defaults to port 23
EthernetServer server = EthernetServer(23);

void setup() {
  // 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
  }

  // initialize the Ethernet device
  Ethernet.begin(mac, ip);

  // start listening for clients
  server.begin();
}

void loop() {
  if (server) {
    Serial.println("Server is listening");
  }
  else {
    Serial.println("Server is not listening");
  }
}

https://www.arduino.cc/en/Reference/EthernetHardwareStatus

Ethernet.hardwareStatus()

Description

Ethernet.hardwareStatus() tells you which WIZnet Ethernet controller chip was detected during Ethernet.begin(), if any. This can be used for troubleshooting. If no Ethernet controller was detected then there is likely a hardware problem.

Syntax

Ethernet.hardwareStatus()

Parameters

none

Returns

which WIZnet Ethernet controller chip was detected during Ethernet.begin() (EthernetHardwareStatus):

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  // 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
  }

  Ethernet.begin(mac, ip);

  if (Ethernet.hardwareStatus() == EthernetNoHardware) {
    Serial.println("Ethernet shield was not found.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5100) {
    Serial.println("W5100 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5200) {
    Serial.println("W5200 Ethernet controller detected.");
  }
  else if (Ethernet.hardwareStatus() == EthernetW5500) {
    Serial.println("W5500 Ethernet controller detected.");
  }
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetLinkStatus

Ethernet.linkStatus()

Description

Tells you whether the link is active. LinkOFF could indicate the Ethernet cable is unplugged or defective. This feature is only available when using the W5200 and W5500 Ethernet controller chips.

Syntax

Ethernet.linkStatus()

Parameters

none

Returns

the link status (EthernetLinkStatus):

Example

#include <SPI.h>
#include <Ethernet.h>

void setup() {
  // 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
  }
}

void loop () {
  if (Ethernet.linkStatus() == Unknown) {
    Serial.println("Link status unknown. Link status detection is only available with W5200 and W5500.");
  }
  else if (Ethernet.linkStatus() == LinkON) {
    Serial.println("Link status: On");
  }
  else if (Ethernet.linkStatus() == LinkOFF) {
    Serial.println("Link status: Off");
  }
}

See also


https://www.arduino.cc/en/Reference/EthernetSetMACAddress

Ethernet.setMACAddress()

Description

Set the MAC address. Not for use with DHCP.

Syntax

Ethernet.setMACAddress(mac)

Parameters

mac: the MAC address to use (array of 6 bytes)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Ethernet.begin(mac, ip);
  byte newMac[] = {0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02};
  Ethernet.setMACAddress(newMac);  // change the MAC address
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSetLocalIP

Ethernet.setLocalIP()

Description

Set the IP address of the device. Not for use with DHCP.

Syntax

Ethernet.setLocalIP(local_ip)

Parameters

local_ip: the IP address to use (IPAddress)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Ethernet.begin(mac, ip);
  IPAddress newIp(10, 0, 0, 178);
  Ethernet.setLocalIP(newIp);  // change the IP address
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSetDnsServerIP

Ethernet.setDnsServerIP()

Description

Set the IP address of the DNS server. Not for use with DHCP.

Syntax

Ethernet.setDnsServerIP(dns_server)

Parameters

dns_server: the IP address of the DNS server (IPAddress)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);

void setup() {
  Ethernet.begin(mac, ip, myDns);
  IPAddress newDns(192, 168, 1, 1);
  Ethernet.setDnsServerIP(newDns);  // change the DNS server IP address
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSetGatewayIP

Ethernet.setGatewayIP()

Description

Set the IP address of the network gateway. Not for use with DHCP.

Syntax

Ethernet.setGatewayIP(gateway)

Parameters

gateway: the IP address of the network gateway (IPAddress)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway);
  IPAddress newGateway(192, 168, 100, 1);
  Ethernet.setGatewayIP(newGateway);  // change the gateway IP address
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSetSubnetMask

Ethernet.setSubnetMask()

Description

Set the subnet mask of the network. Not for use with DHCP.

Syntax

Ethernet.setSubnetMask(subnet)

Parameters

subnet: the subnet mask of the network (IPAddress)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);
IPAddress myDns(192, 168, 1, 1);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 0, 0);

void setup() {
  Ethernet.begin(mac, ip, myDns, gateway, subnet);
  IPAddress newSubnet(255, 255, 255, 0);
  Ethernet.setSubnetMask(newSubnet);  // change the subnet mask
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetMACAddress

Ethernet.MACAddress()

Description

Fills the supplied buffer with the MAC address of the device.

Syntax

Ethernet.MACAddress(mac_address)

Parameters

mac_address: buffer to receive the MAC address (array of 6 bytes)

Returns

Nothing

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  byte macBuffer[6];  // create a buffer to hold the MAC address
  Ethernet.MACAddress(macBuffer); // fill the buffer
  Serial.print("The MAC address is: ");
  for (byte octet = 0; octet < 6; octet++) {
    Serial.print(macBuffer[octet], HEX);
    if (octet < 5) {
      Serial.print('-');
    }
  }
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetDnsServerIP

Ethernet.dnsServerIP()

Description

Returns the DNS server IP address for the device.

Syntax

Ethernet.dnsServerIP()

Parameters

none

Returns

the DNS server IP address for the device (IPAddress)

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  Serial.print("The DNS server IP address is: ");
  Serial.println(Ethernet.dnsServerIP());
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetGatewayIP

Ethernet.gatewayIP()

Description

Returns the gateway IP address for the device.

Syntax

Ethernet.gatewayIP()

Parameters

none

Returns

the gateway IP address for the device (IPAddress)

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  Serial.print("The gateway IP address is: ");
  Serial.println(Ethernet.gatewayIP());
}

void loop () {}

See also


https://www.arduino.cc/en/Reference/EthernetSubnetMask

Ethernet.subnetMask()

Description

Returns the subnet mask of the device.

Syntax

Ethernet.subnetMask()

Parameters

none

Returns

the subnet mask of the device (IPAddress)

Example

#include <SPI.h>
#include <Ethernet.h>

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip(10, 0, 0, 177);

void setup() {
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }

  Ethernet.begin(mac, ip);

  Serial.print("The subnet mask is: ");
  Serial.println(Ethernet.subnetMask());
}

void loop () {}

See also

SimonePDA commented 6 years ago

Working on all the modifications.

Should be done in the next 24 hours.

Thanks for your massive effort!

simone

SimonePDA commented 6 years ago

Done.

The links to stream were omitted in the see also because they are potentially not stable due to the reference new structure.