Introduction

The world of microcontrollers and increasingly capable and popular small computing platforms is enabling many more people to learn, experience, and complete projects that would previously have required dedicated (and expensive) hardware. Rather than purchase a commercial or made-for-consumers kit, enterprising developers can now build their own solutions to meet their needs. Sensor networks are just one example of how these small, powerful, and inexpensive components have made it possible for anyone with a moderate skill set to build their own sensor network.

This book presents a beginner’s guide to sensor networks. I cover topics including what types of sensors exist, how they communicate their values (observations or events), how they can be used in Arduino and Raspberry Pi projects, and how to build your own home temperature sensor network.

I also include an introduction to the MySQL database server and how you can connect to, store, and retrieve data. Why, I even show you how to do it directly from an Arduino!

Who This Book Is For

I have written this book with a wide variety of readers in mind. It is intended for anyone who wants to get started building their own sensor networks or those who want to learn how to use components, devices, and sensors with an Arduino or Raspberry Pi.

Whether you have already been working with sensor networks, or maybe have taken an introductory electronics course, or even have read a good Apress book on the Arduino or Raspberry Pi, you will get a lot out of this book. Best of all, if you ever wanted to know how to combine sensors, Arduinos, XBee, MySQL, and Raspberry Pi to form a cohesive solution, this book is just what you need!

Most importantly, I wrote this book to meet my own needs. Although there are some excellent books on the Arduino, Raspberry Pi, sensors, and MySQL, I could not find a single reference that showed how to put all of these together. That is, until now.

About the Projects

There are nine chapters, seven of which include projects that demonstrate and teach key concepts of building sensor networks. Depending on your skill level with the chapter topic, you may find some of the projects easier to complete than others. It is my hope that you find the projects challenging and enlightening (but, more importantly, informative) so that you can complete your own sensor network projects.

In this section, I present some guidance on how best to succeed and get the most out of the projects.

Strategies

I have tried to construct the projects so that the majority of readers can accomplish them with little difficulty. If you encounter topics that you are very familiar with, I recommend working through the projects anyway instead of simply reading or skipping through the instructions. This is because some of the later projects build on the earlier projects.

On the other hand, if you encounter topics that you are unfamiliar with, I recommend reading through the chapter or section completely at least once before attempting the project. Take some time to fully absorb the material, and pay particular attention to the numerous links, tips, and cautionary portions. Some of those are pure gold for beginners.

Perhaps the most significant advice I can offer when approaching the projects is to attempt them one at a time. By completing the projects one at a time, you gain knowledge that you can build on for future projects. It also helps your establish a pace to work through the book. Although some accomplished readers can probably complete all the projects in a weekend, I recommend working through the book at a pace best suited for your availability (and enjoyment).

With some exceptions, the earlier chapters are independent and can be tackled in any order. This is especially true for the Arduino (Chapter 4) and Raspberry Pi (Chapter 5) chapters. Regardless, it is a good idea to read the book and work on the projects in order.

Tips for Buying Hardware

The hardware list for this book contains a number of common components such as temperature sensors, breadboards, jumper wires, and resistors. Most of these items can be found in electronics stores that stock supplies for electronics enthusiasts. The list also includes a number of specialized components such as XBee modules, XBee adapters, XBee shields, Arduino boards, and Raspberry Pi boards.

Each chapter has a list of the components used at the end of the chapter. In some cases, you reuse the hardware from previous chapters. I include a separate list for these items. I have placed the component lists at the end of each chapter to encourage you to read the chapter before attempting the projects.

The lists include the name of each component and at least one link to an online vendor that stocks the component. In addition, I include the quantity needed for the chapter and an estimated cost. If you add up all the components needed and sum the estimated cost, the total may be a significant investment for some readers.

The following sections are for anyone looking to save a little on the cost of completing the projects in this book or wanting to build up their own inventory of sensor network hardware on a budget.

Buy Only What You Need When You Need It

One way to mitigate a significant initial investment in hardware is to pace your buying. If you follow my advice and work on one project at a time, you can purchase only the hardware needed for that project. This will allow you to spread the cost over however long you plan to work through the book.

However, if you are buying your hardware from an online retailer, you may want to balance ordering the hardware for one project at a time against the potentially higher total shipping cost for multiple orders.

As mentioned, the more common electronics like LEDs, breadboards, and so on, can be found in traditional brick-and-mortar stores, but the cost may be a little higher. Once again, the cost of shipping to your location may dictate whether it would be cheaper to buy the higher-priced items from a local electronics shop versus an online retailer.

Online Auctions

One possible way to save money is to buy your components at a discount on online auction sites. In many cases, the components are the very same ones listed. In other cases, the components may be from vendors that specialize in making less-expensive alternatives. I have had a lot of success in buying quality hardware from online auction sites (namely eBay).

If you are not in a hurry and have time to wait for auctions to close and the subsequent shipping times, you can sometimes find major components like Arduinos, shields, power supplies, and the like at a reduced price by bidding for them. For example, open source hardware manufacturers sometimes offer their products via auctions or at special pricing for quantities. I have found a number of Arduino clones and shields at nearly half the cost of the same boards found on other sites or in electronics stores.

Hey, Buddy, Can You Spare an Arduino?

Another possible way to save some money on the hardware is to borrow it from your friends! If you have friends who are electronics, Arduino, or Raspberry Pi enthusiasts, chances are they have many of the components you need. Just be sure you return the components in working order!1

A NOTE ABOUT NEWER ARDUINO BOARDS

The projects in this book are designed for a current, readily available version of the Arduino. The projects can be completed with the Duemilanove or Uno boards without modification. Although you can use the Leonardo (see specific notes in the chapters about the differences), you should consider the newer boards carefully before buying.

Some newer boards may require additional changes or extra steps to use. For example, the Due is perfectly suitable and an excellent choice for projects that require larger sketches; but you must use the newest beta version of the Arduino IDE, which may require slight changes to your sketch. There are a couple of other things unique to the Due, but I highlight these in the chapters. Finally, you can use the Yún, but you would be using only the Arduino side of the board so this may not be a cost-effective solution.

Downloading the Code

The code for the examples shown in this book is available on the Apress web site, www.apress.com. A link can be found on the book’s information page under the Source Code/Downloads tab. This tab is located underneath the Related Titles section of the page.

Reporting Errata

Should you find a mistake in this book, please report it through the Errata tab on the book’s page at www.apress.com. You will find any previously confirmed errata in the same place.

1And replace the components you implode, explode, or otherwise turn into silicon slag. Hey, it happens.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset