Building Arduino Projects for the Internet of Things

(Steven Felgate) #1
CHAPTER 2 ■ INTERNET CONNECTIVITY



  1. Attach the Ethernet shield to the top of Arduino. All the pins
    should align.




  2. Connect an Ethernet cable from Arduino to the LAN (Local
    Area Network) port of your router. The router should already
    be connected to the Internet.




Once the Ethernet shield has been attached to Arduino, it should look similar to
Figure  2-2.


Figure 2-2. Ethernet shield attached to the top of Arduino Uno


Code (Arduino)


Now that your Arduino is physically connected to Ethernet, you are going to write the
code that will allow your Arduino to send and receive data over the Internet.
Start Arduino IDE and type the code provided here or download it from the book's
site and open it. All the code goes into a single source file ( *.ino ), but in order to make it
easy to understand and reuse, it is divided into three sections.



  • External libraries

  • Internet connectivity (Ethernet)

  • Standard functions

Free download pdf