You are previewing Building Wireless Sensor Networks Using Arduino.
O'Reilly logo
Building Wireless Sensor Networks Using Arduino

Book Description

Leverage the powerful Arduino and XBee platforms to monitor and control your surroundings

About This Book

  • Build your own low-power, wireless network using ready-made Arduino and XBee hardware

  • Create a complex project using the Arduino prototyping platform

  • A guide that explains the concepts and builds upon them with the help of examples to form projects

  • Who This Book Is For

    This book is targeted at embedded system developers and hobbyists who have some working knowledge of Arduino and who wish to extend their projects using wireless connectivity.

    What You Will Learn

  • Interact with XBee boards using the XCTU program on Windows, OS X, or Linux

  • Make your Arduino boards communicate wirelessly, using XBee modules in the advanced API mode

  • Centrally collect and store measured sensor data, in the cloud or your own database

  • Connect the coordinator Arduino to the Internet and send data to web services

  • Control your environment automatically, based on sensor input from your network

  • Interact with off-the-shelf ZigBee Home Automation devices

  • Make your devices battery-powered and let them sleep to get months or even years of battery life

  • In Detail

    Arduino has been established as the de facto standard microcontroller programming platform, being used for one-off do-it-yourself projects as well as prototypes for actual products. By providing a myriad of libraries, the Arduino community has made it very easy to interact with pretty much any piece of hardware out there. XBee offers a great range of low-power wireless solutions that are easy to work with, by taking all of the complexity of wireless (mesh) networking out of your hands and letting you focus on what to send without worrying about the how. Building wireless sensor networks is cost-effective as well as efficient as it will be done with Arduino support.

    The book starts with a brief introduction to various wireless protocols, concepts, and the XBee hardware that enables their use. Then the book expands to explain the Arduino boards to you, letting them read and send sensor data, collect that data centrally, and then even control your home from the Internet. Moving further more advanced topics such as interacting through the standard Zigbee Home Automation protocol, or making your application power-efficient are covered. By the end of the book, you will have all the tools needed to build complete, real-world solutions.

    Style and approach

    A hands-on guide, featuring a single home automation project that can be built as described or with endless variations. Every step is illustrated with complete examples and screenshots, allowing you to build the examples swiftly.

    Downloading the example code for this book. 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 code file.

    Table of Contents

    1. Building Wireless Sensor Networks Using Arduino
      1. Table of Contents
      2. Building Wireless Sensor Networks Using Arduino
      3. Credits
      4. About the Author
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. eBooks, discount offers, and more
          5. Questions
      8. 1. A World without Wires
        1. XBee radio hardware
          1. XBee product families
          2. Versions and variants
          3. Official XBee documentation
        2. Your first transmission
          1. Using the SparkFun XBee Explorer USB
        3. Getting and running XCTU
          1. Updating the firmware
            1. Failed firmware updates
          2. Configuration
          3. Talking to the XBee module
        4. Receiving data
          1. Uploading the sketch
          2. Connecting the XBee
          3. Receiving data
        5. Switching to API mode
          1. First module in API mode
            1. Sending data
          2. Second module in API mode
        6. Starting and joining a network
          1. Module addressing
          2. Network scanning and remote configuration
          3. The Commissioning button and LEDs
        7. Making your network secure
          1. Distributing the network key
          2. Trust center link key
            1. Trust center terminology differences
          3. Selecting encryption keys
          4. Setting up your secure network
          5. Disabling network joining
        8. Other XBee families
          1. Configuration values
        9. Summary
      9. 2. Collecting Sensor Data
        1. Hardware setup
          1. Serial on XBee
            1. Handshaking signals
            2. Voltage levels
          2. Serial on a computer
          3. Serial on Arduino
          4. XBee shields
            1. Other shields
        2. Software setup
          1. Example sketches
            1. Variable types
            2. PROGMEM and F() strings
            3. Pointers
          2. Serial port setup
          3. The xbee-arduino library
          4. Creating the sketch
        3. Sending and receiving data
          1. Sending data
            1. The ZBTxRequest objects
            2. Creating the sketch
            3. Blocking and polling
            4. Running the sketch
          2. Callbacks
            1. Callback types
            2. Callback limitations
          3. Receiving data
            1. The ZBRxResponse objects
            2. Creating the sketch
        4. Collecting sensor data
          1. Reading a DHT22 sensor
          2. Handling packets using binary.h
          3. Building and sending a packet
            1. Constructing a packet using binary.h
            2. Creating the sketch
          4. Receiving and parsing a packet
            1. Parsing a packet using binary.h
            2. Creating the sketch
        5. Troubleshooting
          1. Communication with the XBee module is not working
          2. Modules are not joining the network
          3. Modules cannot talk to each other
        6. Summary
      10. 3. Storing and Visualizing Your Data
        1. Storing your data in the cloud
          1. Introducing Beebotte
            1. Channels and resources
            2. Security
            3. Access protocols
          2. Sending your data to Beebotte
            1. Preparing Beebotte
            2. Connecting your Arduino to the Internet
            3. Writing the sketch
            4. Visualizing your data
            5. Accessing your data
        2. Keeping your data locally
          1. Sending data over the serial port
          2. Receiving data over the serial port
        3. Summary
      11. 4. Controlling the World
        1. Controlling your heating and/or cooling system
          1. Replacing the thermostat
          2. Controlling mains power
          3. Hairdryer – an alternative
        2. Control systems
        3. Adding setpoint control
          1. Subscribing to events
          2. Reading events
          3. Remembering sensor readings
          4. Thermostat controller
        4. Controlling a relay
        5. Controlling off-the-shelf ZigBee devices
          1. ZigBee profiles, endpoints, and clusters
          2. ZigBee public profiles
          3. Selecting a ZigBee device
          4. Talking to a ZigBee on/off device
            1. Joining the network
            2. Factory reset in case of problems
            3. Discovering services
            4. The ZBExplicitTxRequest objects
            5. Sending a message
            6. The ZBExplicitRxResponse objects
            7. Receiving messages
            8. Receiving on/off command responses
          5. More ZigBee features
        6. Summary
      12. 5. Standalone XBee Operation
        1. Creating a window sensor
          1. Connecting things
            1. Powering the module
            2. Connecting the window sensor
            3. I/O pin naming
          2. Configuring the XBee module
          3. Remotely sampling the pins
            1. Querying the pin state
            2. Automatically sending the sample data
            3. The configuration values
          4. Receiving the samples on the coordinator
            1. The ZBRxIoSampleResponse objects
            2. Receiving the I/O samples
        2. Creating a standalone relay
          1. Connecting things
          2. Configuring the XBee module
          3. Remotely toggling an output pin
        3. Summary
      13. 6. Battery Power and Sleeping
        1. Battery power
          1. Lithium-ion and lithium polymer batteries
          2. Regulators
        2. Saving power
          1. Power saving techniques
          2. Knowing what to optimize and when to stop
        3. XBee power-saving
          1. The XBee sleep modes
          2. Configuring the network
          3. The sleeping window sensor
            1. Battery power
            2. Power usage
        4. Arduino power-saving
          1. The XBee configuration
          2. Hardware
            1. Powering the Arduino
            2. Hardware connections
          3. Putting the Arduino to sleep
            1. Sleep modes
            2. Waking up
            3. Creating the sketch
            4. Power usage
        5. Summary
      14. Index