[Ethernet]
Description
Initializes the Ethernet library and network settings.
This library supports also DHCP. Using Ethernet.begin(mac)
or Ethernet.begin()
with the proper network setup, the Ethernet shield will automatically obtain an IP address.
Syntax
Ethernet.begin(); Ethernet.begin(mac); Ethernet.begin(mac, ip); Ethernet.begin(mac, ip, dns); Ethernet.begin(mac, ip, dns, gateway); Ethernet.begin(mac, ip, dns, gateway, subnet);
Parameters
mac
: an array of 6 bytes that contains an MAC (Media access control) address. Since every 86Duino has a fixed MAC address that cannot be changed, this parameter is unused, and is reserved here just for the purpose of compatibility to Arduino’s Ethernet library.ip
: the device IP address that you want to set for 86Duino (array of 4 bytes)dns
: the IP address of the DNS server (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1gateway
: the IP address of the network gateway (array of 4 bytes). optional: defaults to the device IP address with the last octet set to 1subnet
: the subnet mask of the network (array of 4 bytes). optional: defaults to 255.255.255.0
Returns
The DHCP version of this function, Ethernet.begin(mac)
or Ethernet.begin()
, returns an int: 1 on a successful DHCP connection, 0 on failure. The other versions don’t return anything.
Example
#include <Ethernet.h> byte mac[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; //the IP address: byte ip[] = { 10, 0, 0, 177 }; void setup() { Ethernet.begin(mac, ip); } void loop () {}
Libraries Reference Home
The text of the 86Duino reference is a modification of the Arduino reference and is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the reference are released into the public domain.