Ethernet Shield 2 | Arduino Tutorial

Basic Networking Knowledge for Beginners

This part provides basic knowledge for beginners, who do not know anything about networking.

When a device connects to the Internet (via Ethernet or WiFi), it MUST connect to a router or an access point. Router and access point are devices that keep a role as the gateway to the Internet. All data between a device and the Internet is passed through the router or access point.

When a device connects to the Internet, it MUST:

  • Have a MAC address
  • Have an IP address
  • Know network's subnet mask
  • Know gateway's IP address (IP address of router or access point)
  • Know DNS server's IP address (in case of connecting to a domain name)

The device does not work if either:

  • There are one or more other devices in the same network uses the same MAC address of the device (called conflict MAC address)
  • There are one or more other devices in the same network uses the same IP address of the device (called a conflict IP address)

This tutorial does not overload you with the knowledge of networking. Therefore, the tutorial does not explain these concepts. It is out of the scope of this tutorial. Instead, the tutorial shows how to use them.

The MAC address is usually built-in on devices. We do not need to care about it. However, Arduino Ethernet Shield does not have a built-in MAC address. The MAC address is printed on a sticker stuck on the shield. We need to get it and set the MAC address for Arduino Shield in the Arduino code.

There are two methods to assign the IP address, subnet mask, gateway's IP address, and DNS server's IP address to a device (including Arduino):

  1. Use the static IP address:
    • Need to manage the IP address, subnet mask, gateway's IP address, and DNS server's IP address
    • Need to set the IP address, subnet mask, gateway's IP address, and DNS server's IP address manually (for Arduino Ethernet Shield, set this information using Arduino code)
    • It will NOT work if:
      • Set an IP address that is being used by other devices on the same LAN network → IP conflict
      • Set wrong subnet mask, gateway's IP address, and DNS server's IP address
  • Obtain an IP address automatically(DHCP), also called the dynamic IP address
    • The device automatically obtains the IP address, subnet mask, gateway's IP address, and DNS server's IP address from the router or access point using DHCP. We do not need to manage the IP address, subnet mask, gateway's IP address, and DNS server's IP address. Router/access point does this work for us.

    When you connect your smartphone to your WiFi home network, the second method is used.

    When using Arduino, The first method is hard for beginners. The second method is easy and recommended for beginners who do NOT know about networking.

    Tag » Arduino Section Type Conflict