
TECHNOLOGY IN ACTION™ Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino Sensing the World with Python and MicroPython — Second Edition — Charles Bell www.allitebooks.com Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino Sensing the World with Python and MicroPython Second Edition Charles Bell www.allitebooks.com Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython Charles Bell Warsaw, VA, USA ISBN-13 (pbk): 978-1-4842-5795-1 ISBN-13 (electronic): 978-1-4842-5796-8 https://doi.org/10.1007/978-1-4842-5796-8 Copyright © 2020 by Charles Bell This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed. Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. While the advice and information in this book are believed to be true and accurate at the date of publication, neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or omissions that may be made. The publisher makes no warranty, express or implied, with respect to the material contained herein. Managing Director, Apress Media LLC: Welmoed Spahr Acquisitions Editor: Natalie Pao Development Editor: James Markham Coordinating Editor: Jessica Vakili Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail [email protected], or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation. For information on translations, please e-mail [email protected], or visit http://www. apress.com/rights-permissions. Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales. Any source code or other supplementary material referenced by the author in this book is available to readers on GitHub via the book’s product page, located at www.apress.com/ 978-1-4842-5795-1. For more detailed information, please visit http://www.apress.com/ source-code. Printed on acid-free paper www.allitebooks.com I dedicate this book to the countless healthcare professionals, first responders, and many unsung heroes of this difficult time we face in the world during the COVID-19 crisis. It is my hope this book and others like it help the millions of people pass the time during the crisis learning more about science and technology. www.allitebooks.com Table of Contents About the Author ................................................................................xv About the Technical Reviewer ..........................................................xvii Acknowledgments .............................................................................xix Introduction .......................................................................................xxi Chapter 1: Introduction to Sensor Networks ........................................1 Anatomy of a Sensor Network ..............................................................................2 Examples of Sensor Networks .........................................................................3 The Topology of a Sensor Network ................................................................12 Communication Media ........................................................................................14 Wired Networks .............................................................................................14 Wireless Networks .........................................................................................15 Hybrid Networks ............................................................................................15 Types of Sensor Nodes ........................................................................................16 Basic Sensor Nodes .......................................................................................16 Data Nodes ....................................................................................................16 Aggregator Nodes ..........................................................................................17 Sensors ...............................................................................................................18 How Sensors Measure ...................................................................................20 Storing Sensor Data ......................................................................................26 Examples of Sensors .....................................................................................27 Summary ............................................................................................................34 v www.allitebooks.com TABLE OF CONtENtS Chapter 2: Tiny Talking Modules: An Introduction to XBee Wireless Modules ......................................................................35 What Is an XBee? ................................................................................................36 XBee Primer ........................................................................................................37 Choosing XBee Modules ................................................................................38 Interacting with an XBee-ZB Module .............................................................42 Pin Layout ......................................................................................................46 Configuring Modules .....................................................................................48 Introducing MicroPython .....................................................................................67 An XBee Wireless Chat Room ..............................................................................72 Loading the Firmware for the Modules .........................................................72 Capturing Serial Numbers .............................................................................77 Configuring the Coordinator ..........................................................................79 Configuring the Router ..................................................................................80 Let the Chat Begin .........................................................................................80 For More Fun .................................................................................................82 Building an XBee-ZB Mesh Network ...................................................................84 Loading the Firmware for the Modules .........................................................85 Configuring the XBee Modules ......................................................................85 Forming Test Messages .................................................................................86 Testing the Network ......................................................................................90 For More Fun .................................................................................................95 Component Shopping List ...................................................................................95 Troubleshooting Tips and Common Issues ..........................................................97 Things to Check .............................................................................................98 Common Issues .............................................................................................99 Summary ..........................................................................................................101 vi TABLE OF CONtENtS Chapter 3: Programming in MicroPython .........................................103 MicroPython Features and Limitations .............................................................105 MicroPython Features .................................................................................105 MicroPython Limitations ..............................................................................106 Basic Concepts .................................................................................................107 Code Blocks .................................................................................................108 Comments ...................................................................................................110 Arithmetic ....................................................................................................111
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages732 Page
-
File Size-