Book Image

Arduino Networking

By : Marco Schwartz
Book Image

Arduino Networking

By: Marco Schwartz

Overview of this book

Table of Contents (13 chapters)

Preface

Arduino is an amazing platform to quickly create exciting electronics projects. Using the Arduino platform, even non-experts can connect sensors, actuators, and displays together and build complex projects that provide immediate applications for everyday life.

However, these projects are even better when they are connected, meaning they have some way to communicate with other devices, and not necessarily with other Arduino boards. There are many ways to connect Arduino projects together and to other devices such as computers: WiFi, XBee, Bluetooth, and Ethernet. This book will focus entirely on how to create amazing projects using this latest technology to connect Arduino projects.

Using Ethernet has several advantages over wireless solutions: it is fast, cheap, and you will find plenty of help on the subject on the Internet. For me, the most important thing is that the Ethernet library for Arduino is very well documented, and comes built-in with the Arduino software. It's hardware counterpart, the Arduino Ethernet shield, is also very well built and well supported by the Arduino community.

In this book, we are going to see how to use the Ethernet shield and the Ethernet library via six exciting projects. We are going to start with the very basics and see how to connect the Ethernet shield to your local network and the Web. Then, we will send data from the Ethernet shield to a server located on your local network. Finally, we will integrate the Ethernet shield in an "Internet of Things" framework, by building several projects connected directly to the Web.

What this book covers

Chapter 1, Discover the Arduino Ethernet Shield, introduces the Arduino Ethernet shield by showing you how to set up everything so you can easily build more exciting applications in the next chapters. We are going to connect the Ethernet shield to your router, and make sure that it can access the Web.

Chapter 2, Sending Data to a Web Server, explains how to connect a temperature and humidity sensor to your Arduino board and use the Ethernet shield to send this data continuously to a web server running on your computer. We will also plot this data in real time on the web server so that you can visualize it in your browser.

Chapter 3, Data Logging Station, uses the same hardware as in the previous chapter, but we will make the Arduino Ethernet more independent. We will log the data measured by the board locally on an SD card, and also create a web server on the Ethernet shield so that it can be accessed from any device in your local network.

Chapter 4, Controlling Objects from Anywhere, covers how to connect a relay module to our Arduino and Ethernet shield hardware so that it can be controlled via the network. We are first going to control this relay module from within your local network, and then use a dedicated service to be able to control this relay from anywhere. As an example, we are also going to connect a lamp to this relay module.

Chapter 5, Internet of Things with Xively, continues with cloud-connected projects by interfacing the Ethernet shield with a cloud service called Xively. Using this service, we will be able to send the data measured by our project to the Web and monitor it in real time from the Xively website, from anywhere in the world.

Chapter 6, Logging Data in Google Docs, uses the web service Temboo to interface the Ethernet shield with even more web services such as Google Docs or Gmail. For example, we are going to make measurements using our Arduino board and automatically log these results in a Google Docs spreadsheet, which can be accessed from anywhere in the world.

What you need for this book

You will need several hardware and software components to make all the projects found in this book. Of course, you can just read the description of the projects and learn this way. However, I really recommend actually doing the projects yourself to really learn about how to use the Arduino Ethernet shield to build exciting networking applications.

The hardware components required are detailed at the beginning of each chapter. However, what you will really need for all the projects is an Arduino board.

All the projects of the book are based on the Arduino Uno board:

http://arduino.cc/en/Main/arduinoBoardUno

For all the projects of this book, you will also need the Arduino Ethernet shield:

http://arduino.cc/en/Main/ArduinoBoardEthernet

On the software side, there is some software that we will use in all the chapters of the book. The first software that we will use in all the chapters is the Arduino IDE that you need to install. You can download it from:

http://arduino.cc/en/main/software

The Ethernet library itself is contained within the Arduino IDE, so you won't need to install it yourself. There are also several external libraries you will need, but these are detailed in each chapter where they are necessary.

You will also need a web server running on your computer for some of the projects. I recommend using software that integrates a web server and a database, and that handles all the details for you.

If you are working on Windows, I recommend using EasyPHP:

http://www.easyphp.org/

Under OS X, I recommend using MAMP:

http://www.mamp.info/

For Linux, you can follow the instructions provided at the following link to install a web server:

http://doc.ubuntu-fr.org/lamp

Make sure that the server is running at this point; we are going to use it in several projects in this book.

Who this book is for

This book is for all those who are willing to build exciting connected Arduino projects using the Ethernet shield. You actually don't need to know the Arduino platform beforehand as all the projects will be explained step by step with clear instructions. You also don't need any prior knowledge in the Ethernet technology. The only thing you need to understand is the projects found in this book are just basic knowledge in electronics and programming.

This book is also for electronic hobbyists who want to learn more about the Arduino platform. By executing the projects found in this book, you will learn about many possible ways to use the Arduino Ethernet shield. You will also learn how to connect sensors and actuators to Arduino and control them within your local network.

Finally, this book is also for those who are willing to learn more about the Internet of Things framework using the Arduino Ethernet shield. The last chapters of the book are dedicated to building projects that are connected to cloud services and can be accessed from anywhere in the world, simply by connecting your Arduino projects to your Internet router via Ethernet.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "In the setup() function of the sketch, we will try to get an IP address using DHCP."

A block of code is set as follows:

String log_time = String(day()) + "/" + 
String(month()) + "/" + String(year()) + " " + 
String(hour()) + ":" + String(minute()) + ":" + 
String(second());

Any command-line input or output is written as follows:

# 192.168.1.103/digital/7/1

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "If you are using Windows, you will find the information you need under Network Settings in your Control Panel."

Note

Warnings or important notes or some additional information appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

All the up-to-date code for the projects of this book can also be found at the following address:

https://github.com/openhomeautomation/arduino-networking/

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.