0% found this document useful (0 votes)
6 views

Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython 2nd Edition Charles Bell pdf download

The document is a promotional excerpt for the book 'Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython' by Charles Bell, which covers various aspects of sensor networks and programming. It includes links to download the book and other related titles on Raspberry Pi and Arduino. The book aims to educate readers on building sensor networks using XBee and Raspberry Pi technologies.

Uploaded by

lvcdhxc1693
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython 2nd Edition Charles Bell pdf download

The document is a promotional excerpt for the book 'Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython' by Charles Bell, which covers various aspects of sensor networks and programming. It includes links to download the book and other related titles on Raspberry Pi and Arduino. The book aims to educate readers on building sensor networks using XBee and Raspberry Pi technologies.

Uploaded by

lvcdhxc1693
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 59

Beginning Sensor Networks with XBee, Raspberry

Pi, and Arduino: Sensing the World with Python


and MicroPython 2nd Edition Charles Bell
download
https://textbookfull.com/product/beginning-sensor-networks-with-
xbee-raspberry-pi-and-arduino-sensing-the-world-with-python-and-
micropython-2nd-edition-charles-bell/

Download full version ebook from https://textbookfull.com


We believe these products will be a great fit for you. Click
the link to download now, or visit textbookfull.com
to discover even more!

Beginning Robotics with Raspberry Pi and Arduino: Using


Python and OpenCV 2nd Edition Jeff Cicolani

https://textbookfull.com/product/beginning-robotics-with-
raspberry-pi-and-arduino-using-python-and-opencv-2nd-edition-
jeff-cicolani/

Beginning Robotics with Raspberry Pi and Arduino: Using


Python and OpenCV 2nd Edition Jeff Cicolani

https://textbookfull.com/product/beginning-robotics-with-
raspberry-pi-and-arduino-using-python-and-opencv-2nd-edition-
jeff-cicolani-2/

Beginning Robotics with Raspberry Pi and Arduino: Using


Python and OpenCV Jeff Cicolani

https://textbookfull.com/product/beginning-robotics-with-
raspberry-pi-and-arduino-using-python-and-opencv-jeff-cicolani/

Biota Grow 2C gather 2C cook Loucas

https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-
loucas/
Raspberry Pi Home Automation with Arduino 2nd Edition
Andrew K. Dennis

https://textbookfull.com/product/raspberry-pi-home-automation-
with-arduino-2nd-edition-andrew-k-dennis/

Hacking Electronics: Learning Electronics with Arduino


and Raspberry Pi, 2nd Edition Simon Monk

https://textbookfull.com/product/hacking-electronics-learning-
electronics-with-arduino-and-raspberry-pi-2nd-edition-simon-monk/

Get started with MicroPython on Raspberry Pi Pico 1st


Edition Gareth Halfacree

https://textbookfull.com/product/get-started-with-micropython-on-
raspberry-pi-pico-1st-edition-gareth-halfacree/

Action movement light and sound with Arduino and


Raspberry Pi First Edition Monk

https://textbookfull.com/product/action-movement-light-and-sound-
with-arduino-and-raspberry-pi-first-edition-monk/

Internet Of things With Raspberry Pi And Arduino First


Edition. Edition Rajesh Singh

https://textbookfull.com/product/internet-of-things-with-
raspberry-pi-and-arduino-first-edition-edition-rajesh-singh/
TECHNOLOGY IN AC TION™

Beginning Sensor
Networks with
XBee, Raspberry Pi,
and Arduino
Sensing the World with Python
and MicroPython

Second Edition

Charles Bell
Beginning Sensor
Networks with XBee,
Raspberry Pi, and
Arduino
Sensing the World with Python
and MicroPython
Second Edition

Charles Bell
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
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.
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
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
Output to Screen������������������������������������������������������������������������������������������112
Variables and Data Types����������������������������������������������������������������������������������114
Variables������������������������������������������������������������������������������������������������������114
Types�����������������������������������������������������������������������������������������������������������116
Basic Data Structures���������������������������������������������������������������������������������������118
Lists�������������������������������������������������������������������������������������������������������������118
Tuples����������������������������������������������������������������������������������������������������������120
Dictionaries�������������������������������������������������������������������������������������������������121
Flow Control Statements�����������������������������������������������������������������������������������123
Conditional Statements�������������������������������������������������������������������������������123
Loops�����������������������������������������������������������������������������������������������������������125
Modularization: Modules, Functions, and Classes��������������������������������������������127
Including Modules���������������������������������������������������������������������������������������127
Functions�����������������������������������������������������������������������������������������������������128
Classes and Objects������������������������������������������������������������������������������������130
Object-Oriented Programming (OOP) Terminology��������������������������������������134
Summary����������������������������������������������������������������������������������������������������������141

vii
Table of Contents

Chapter 4: XBee-Based Sensor Nodes����������������������������������������������143


How to Host Sensors with XBee������������������������������������������������������������������������144
Building an XBee Environment Sensor��������������������������������������������������������������145
Hardware Setup�������������������������������������������������������������������������������������������146
XBee Hardware Option��������������������������������������������������������������������������������150
MicroPython Option�������������������������������������������������������������������������������������155
Example: Using XBee Modules to Gather Data��������������������������������������������������166
Hardware Setup�������������������������������������������������������������������������������������������168
Configuring the XBee Sensor Node�������������������������������������������������������������171
Programming the Sensor Node�������������������������������������������������������������������172
Testing the XBee Sensor Node��������������������������������������������������������������������186
Component Shopping List���������������������������������������������������������������������������������188
Summary����������������������������������������������������������������������������������������������������������191

Chapter 5: Raspberry Pi–Based Sensor Nodes���������������������������������193


What Is a Raspberry Pi?������������������������������������������������������������������������������������194
Noble Origins�����������������������������������������������������������������������������������������������196
Models���������������������������������������������������������������������������������������������������������198
A Tour of the Board��������������������������������������������������������������������������������������200
Required Accessories����������������������������������������������������������������������������������202
Recommended Accessories������������������������������������������������������������������������203
Raspberry Pi Tutorial�����������������������������������������������������������������������������������������207
Getting Started��������������������������������������������������������������������������������������������207
Installing a Boot Image��������������������������������������������������������������������������������208
Booting Up���������������������������������������������������������������������������������������������������213
GPIO Pin Mapping����������������������������������������������������������������������������������������217
Required Software���������������������������������������������������������������������������������������221
Project: Hardware “Hello, World!”����������������������������������������������������������������223

viii
Table of Contents

Hosting Sensors with Raspberry Pi�������������������������������������������������������������������230


Project: Building a Raspberry Temperature Sensor Node���������������������������������232
Hardware Setup�������������������������������������������������������������������������������������������232
Testing the Hardware����������������������������������������������������������������������������������234
Software Setup��������������������������������������������������������������������������������������������236
Testing the Sensor���������������������������������������������������������������������������������������242
For More Fun�����������������������������������������������������������������������������������������������243
Project: Building a Raspberry Barometric Pressure Sensor Node��������������������243
Hardware Setup�������������������������������������������������������������������������������������������245
Testing the Hardware����������������������������������������������������������������������������������245
Software Setup��������������������������������������������������������������������������������������������246
Testing the Sensor���������������������������������������������������������������������������������������251
For More Fun�����������������������������������������������������������������������������������������������251
Project: Creating a Raspberry Pi Data Collector for XBee Sensor Nodes����������252
XBee Sensor Node���������������������������������������������������������������������������������������252
Hardware�����������������������������������������������������������������������������������������������������254
Software������������������������������������������������������������������������������������������������������256
Testing the Final Project������������������������������������������������������������������������������264
For More Fun�����������������������������������������������������������������������������������������������265
Component Shopping List���������������������������������������������������������������������������������266
Summary����������������������������������������������������������������������������������������������������������268

Chapter 6: Arduino-Based Sensor Nodes�����������������������������������������269


What Is an Arduino?������������������������������������������������������������������������������������������269
Arduino Models��������������������������������������������������������������������������������������������271
Arduino Clones��������������������������������������������������������������������������������������������279
So, Which Do I Buy?�������������������������������������������������������������������������������������286
Where to Buy�����������������������������������������������������������������������������������������������287

ix
Table of Contents

Arduino Tutorial�������������������������������������������������������������������������������������������������288
Learning Resources�������������������������������������������������������������������������������������289
The Arduino IDE�������������������������������������������������������������������������������������������290
Project: Hardware “Hello, World!”����������������������������������������������������������������294
Hosting Sensors with Arduino���������������������������������������������������������������������������300
Project: Building an Arduino Temperature Sensor���������������������������������������������302
Hardware Setup�������������������������������������������������������������������������������������������302
Software Setup��������������������������������������������������������������������������������������������304
Writing the Sketch���������������������������������������������������������������������������������������306
Test Execution���������������������������������������������������������������������������������������������310
Project: Using an Arduino As a Data Collector for XBee Sensor Nodes�������������312
XBee Sensor Node���������������������������������������������������������������������������������������312
Coordinator Node�����������������������������������������������������������������������������������������313
Arduino with XBee Shield����������������������������������������������������������������������������314
Testing the Final Project������������������������������������������������������������������������������326
For More Fun�����������������������������������������������������������������������������������������������328
Component Shopping List���������������������������������������������������������������������������������328
Summary����������������������������������������������������������������������������������������������������������331

Chapter 7: Methods for Storing Sensor Data������������������������������������333


Storage Methods�����������������������������������������������������������������������������������������������334
Local Storage Options for the Arduino��������������������������������������������������������������336
Nonvolatile Memory������������������������������������������������������������������������������������336
SD Card��������������������������������������������������������������������������������������������������������337
Project: Saving Data in Nonvolatile Memory�����������������������������������������������338
Project: Writing Data to an SD Card�������������������������������������������������������������356

x
Table of Contents

Local Storage Options for the Raspberry Pi������������������������������������������������������372


Project: Writing Data to Files�����������������������������������������������������������������������373
Remote Storage Options�����������������������������������������������������������������������������������375
Storing Data in the Cloud�����������������������������������������������������������������������������377
Project: Writing Data to ThingSpeak with an Arduino����������������������������������386
Project: Writing Data to ThingSpeak with a Raspberry Pi����������������������������398
Storing Sensor Data in a Database��������������������������������������������������������������409
Component Shopping List���������������������������������������������������������������������������������409
Summary����������������������������������������������������������������������������������������������������������412

Chapter 8: Turning Your Raspberry Pi into a Database Server���������413


What Is MySQL?������������������������������������������������������������������������������������������������414
Getting Started with MySQL������������������������������������������������������������������������������420
What’s a Relational Database Management System?���������������������������������420
How and Where MySQL Stores Data������������������������������������������������������������422
The MySQL Configuration File���������������������������������������������������������������������428
How to Start, Stop, and Restart MySQL�������������������������������������������������������429
Creating Users and Granting Access�����������������������������������������������������������430
Building a Raspberry Pi MySQL Server�������������������������������������������������������������432
Partitioning and Formatting the Drive���������������������������������������������������������433
Setting Up Automatic Drive Mounting���������������������������������������������������������437
Project: Installing MySQL Server on a Raspberry Pi������������������������������������441
Advanced Project: Using MySQL Replication to Back Up
Your Sensor Data�����������������������������������������������������������������������������������������462
Component Shopping List���������������������������������������������������������������������������������472
Summary����������������������������������������������������������������������������������������������������������472

xi
Table of Contents

Chapter 9: MySQL and Arduino: United at Last!�������������������������������475


Introducing Connector/Arduino�������������������������������������������������������������������������476
Hardware Requirements������������������������������������������������������������������������������477
What About Memory?����������������������������������������������������������������������������������480
Installing MySQL Connector/Arduino�����������������������������������������������������������481
Limitations���������������������������������������������������������������������������������������������������482
Building Connector/Arduino-Enabled Sketches������������������������������������������������485
Database Setup�������������������������������������������������������������������������������������������485
Setting Up the Arduino���������������������������������������������������������������������������������488
Starting a New Sketch���������������������������������������������������������������������������������489
Testing the Sketch���������������������������������������������������������������������������������������496
What About the Ethernet Shield 2?��������������������������������������������������������������501
What About the WiFi Shield?�����������������������������������������������������������������������502
What About the WiFi 101 Shield?����������������������������������������������������������������503
Troubleshooting Connector/Arduino������������������������������������������������������������������504
MySQL Server Configuration�����������������������������������������������������������������������506
MySQL User Account Problems�������������������������������������������������������������������508
Networking Configuration����������������������������������������������������������������������������511
Connector Installation����������������������������������������������������������������������������������513
Others����������������������������������������������������������������������������������������������������������514
None of These Solved My Problem—What Next?���������������������������������������515
A Tour of the MySQL Connector/ Arduino Code�������������������������������������������������516
Library Files�������������������������������������������������������������������������������������������������516
Field Structure���������������������������������������������������������������������������������������������517
Public Methods��������������������������������������������������������������������������������������������518
Example Uses����������������������������������������������������������������������������������������������522

xii
Table of Contents

Project: Building a MySQL Arduino Client����������������������������������������������������������527


Hardware Setup�������������������������������������������������������������������������������������������527
Software Setup��������������������������������������������������������������������������������������������529
Setting Up the Sensor Database������������������������������������������������������������������531
Writing the Code������������������������������������������������������������������������������������������531
Test Execution���������������������������������������������������������������������������������������������538
For More Fun�����������������������������������������������������������������������������������������������540
Project Example: Inserting Data from Variables������������������������������������������������541
Project Example: How to Perform SELECT Queries�������������������������������������������544
Displaying a Result Set in the Serial Monitor����������������������������������������������545
Writing Your Own Display Method���������������������������������������������������������������546
Example: Getting a Lookup Value from the Database����������������������������������551
Component Shopping List���������������������������������������������������������������������������������554
Summary����������������������������������������������������������������������������������������������������������555

Chapter 10: Building Your Network: Arduino Wireless


Aggregator + Wireless Sensor Node + Raspberry Pi Server������������557
Data-Aggregate Nodes��������������������������������������������������������������������������������������558
Local-Storage Data Aggregator�������������������������������������������������������������������560
Project: Data-Aggregate Node with Local Storage��������������������������������������561
Remote-Storage Data Aggregator���������������������������������������������������������������594
Project: Arduino Data-Aggregate Node with Database Storage������������������595
Project: Raspberry Pi Data-Aggregate Node with Database Storage����������617
Component Shopping List���������������������������������������������������������������������������������635
Summary����������������������������������������������������������������������������������������������������������638

xiii
Table of Contents

Chapter 11: Putting It All Together���������������������������������������������������639


Sensor Networks Best Practices�����������������������������������������������������������������������639
Considerations for Data-Aggregate Nodes��������������������������������������������������639
Considerations for Sensor Network Databases�������������������������������������������645
Other Considerations�����������������������������������������������������������������������������������653
Choosing Sensor Nodes������������������������������������������������������������������������������������659
Wired or Wireless?���������������������������������������������������������������������������������������660
Arduino or Raspberry Pi?�����������������������������������������������������������������������������661
Alternative Hosts�����������������������������������������������������������������������������������������666
Project: Home Temperature-Monitoring Network���������������������������������������������673
Planning Considerations������������������������������������������������������������������������������674
Planning the Nodes�������������������������������������������������������������������������������������675
Cost Considerations�������������������������������������������������������������������������������������676
What About Implementation?����������������������������������������������������������������������679
Conclusion���������������������������������������������������������������������������������������������������679
For More Fun�����������������������������������������������������������������������������������������������680
Optional Component Shopping List�������������������������������������������������������������������680
Summary����������������������������������������������������������������������������������������������������������681

Appendix�������������������������������������������������������������������������������������������683
Consolidated Shopping Lists�����������������������������������������������������������������������������683
Alternative Connection Systems�����������������������������������������������������������������������691
Grove�����������������������������������������������������������������������������������������������������������������691
Qwiic�����������������������������������������������������������������������������������������������������������������695
STEMMA QT������������������������������������������������������������������������������������������������������700
Summary����������������������������������������������������������������������������������������������������������701

Index�������������������������������������������������������������������������������������������������703

xiv
About the Author
Charles Bell conducts research in emerging
technologies. He is a principal software
developer of the Oracle MySQL Development
team. He lives in a small town in rural Virginia
with his loving wife. He received his Doctor
of Philosophy in Engineering from Virginia
Commonwealth University in 2005.
Dr. Bell is an expert in the database field
and has extensive knowledge and experience in
software development and systems engineering.
His research interests include microcontrollers, three-dimensional printing,
database systems, software engineering, and sensor networks. He spends his
limited free time as a practicing maker focusing on microcontroller projects
and refinement of three-dimensional printers.

xv
About the Technical Reviewer
Sai Yamanoor is an embedded systems engineer working for an industrial
gases company in Buffalo, NY. His interests, deeply rooted in DIY and
open source hardware, include developing gadgets that aid behavior
modification. He has published two books with his brother, and in his
spare time, he likes to contribute to build things that improve quality of
life. You can find his project portfolio at http://saiyamanoor.com.

xvii
Acknowledgments
I would like to thank all of the many talented and energetic professionals
at Apress. I appreciate the understanding and patience of my managing
editor, Natalie Pao; coordinating editor, Jessica Vakili; and development
editor, James Markham. Each was instrumental in the success of this
project. I appreciate their encouragement and guidance as well as patience
in dealing with my many questions. I would also like to thank the small
army of publishing professionals at Apress for making me look so good in
print. Thank you all very much!
I’d like to especially thank the technical reviewer, Sai Yamanoor, for
his patience, insight, and impressive attention to detail. Most importantly,
I want to thank my wife, Annette, for her unending patience and
understanding during the many hours I spent hunched over my laptop or
conducting science experiments on the dining table.

xix
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!
Better still, this edition has been updated to include updated tools
and software, project examples, as well as the latest use and programming
of the XBee 3 modules. Yes, we’re writing code to control them in
MicroPython. There’s an entire chapter dedicated to MicroPython as well
as extended coverage of the XBee platform.

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.

xxi
Introduction

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 Arduino, Raspberry Pi, sensors, and
MySQL, I could not find a single reference that showed how to put all of
these together. The second edition kicks it up yet another notch with more
coverage of these topics with the latest versions of the tools and libraries
available.

About the Projects


There are 11 chapters, 9 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.

xxii
Introduction

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 you 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 Raspberry Pi (Chapter 5)
and Arduino (Chapter 6) 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.

xxiii
Introduction

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 previous 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 vs. 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).

xxiv
Introduction

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 as well as the most recently retired boards. The
projects can be completed with the Uno or Mega 2560 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.

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

xxv
Introduction

D
 ownloading the Code
The code for the examples shown in this book is available on the Apress
website, 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.

R
 eporting 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.

xxvi
CHAPTER 1

Introduction
to Sensor Networks
Sensor networks are no longer expensive industrial constructs. You can
build a simple sensor network from easily procured, low-cost hardware.
All you need are some simple sensors and a microcontroller or computer
with input/output capabilities. Yes, your Arduino and Raspberry Pi are
ideal platforms for building sensor networks. If you’ve worked with either
platform and have ever wanted to monitor your garden pond, track
movement in your home or office, monitor the temperature in your house,
monitor the environment, or even build a low-cost security system, you’re
halfway there!
As inviting and easy as that sounds, don’t start warming up the
soldering iron just yet. There are a lot of things you need to know about
sensor networks. It’s not quite as simple as plugging things together and
turning them on. If you want to build a reliable and informative sensor
network, you need to know how such networks are constructed.
In addition, you may have heard of something called the Internet of
Things (IoT). This phrase refers to the use of devices that can communicate
over a network (local or Internet). IoT devices are therefore network-aware
devices that can send data to other resources, thereby virtualizing the
effects of the devices on users and their experience. Sensor networks play
a prominent role in the IoT. What you will learn in this book will provide a
firm foundation for building IoT solutions using sensor networks.

© Charles Bell 2020 1


C. Bell, Beginning Sensor Networks with XBee, Raspberry Pi, and Arduino,
https://doi.org/10.1007/978-1-4842-5796-8_1
Chapter 1 Introduction to Sensor Networks

If you want to know more about IoT in general, several books have
been written on the topic, including the following. If you’re interested in
learning more about the IoT and how sensor networks are used, check out
some of these titles:
• Building Internet of Things with the Arduino by
Charalampos Doukas (CreateSpace Independent
Publishing Platform, 2012)

• Architecting the Internet of Things by Dieter Uckelmann,


Mark Harrison, and Florian Michahelles (Springer,
2011)

• Getting Started with the Internet of Things: Connecting


Sensors and Microcontrollers to the Cloud by Cuno
Pfister (O’Reilly, 2011)

In this chapter, we will explore sensor networks through a brief


description of what they are and how they are constructed. We will also
examine the components that make up a sensor network including an
overview of sensors, the types of sensors available, and the things that they
can sense.

Anatomy of a Sensor Network


Sensor networks are everywhere. They’re normally thought of as
complicated monitoring systems for manufacturing and medical
applications. However, they aren’t always complicated, and they’re all
around you.
In this section, we will examine the building blocks of a sensor network
and how they’re connected (logically). First, let’s look at some examples of
sensor networks to visualize the components.

2
Chapter 1 Introduction to Sensor Networks

Examples of Sensor Networks


Although some of these examples may not be as familiar to you as others,
it’s a good idea as you read through these examples to try and imagine the
components of the application. Visualize the sensors themselves—where
they’re placed and what data they may be reading and sending to another
part of the network for processing and recording.

A
 utomotive
Almost every modern automobile has a network of sophisticated sensors
that monitor the performance of the engine and its subsystems. Some
cars have additional sensors for monitoring external air temperature, tire
pressure, and even proximity to objects and other vehicles. Newer vehicles
have a host of safety mechanisms including lane departure, obstacle
avoidance, auto braking, and more.1
If you take a late-model car in for service and get a chance to look in
the garage area, you may notice several machines that resemble computer
terminals, tablet computers, or in some cases an iPad. These systems
are diagnostic machines designed to connect to your car and read all the
data the sensors and computer have stored. Some manufacturers use the
industry standard interface called onboard diagnostics (OBD).2 There are
several versions of this interface and its protocols; most dealerships have
equipment that supports all the latest protocols.

1
I nterestingly, I have heard a few motorists who despise some of these features
because their driving habits place the vehicle more to one side of the road
or another, which triggers the lane departure warning. Similarly, those that
habitually cross the center line when driving on curving roads tend to turn off
the departure warning. Clearly one of these is an understandable annoyance,
whereas the other is exactly why the feature is needed.
2
http://en.wikipedia.org/wiki/On-board_diagnostics

3
Exploring the Variety of Random
Documents with Different Content
she must have had French blood in her veins, to breed such eyes,
and such a tongue, for the beautiful speech which came out of that
ugly (it was that) face, and the glitter and depth too of the eyes, like
live coals—perfectly honest the while, both lips and eyes—these
seemed to me to be attributes of the highest French, or rather Gallic,
not of the highest English, woman. In any case, she was a triumph
of mind over matter, of spirit over flesh, which gave the lie to all
materialism, and puts Professor Bain out of court—at least out of
court with those who use fair induction about the men and women
whom they meet and know.”—About 1851.
James Payn’s “I seem to see the dear little old lady now, looking like
Literary a venerable fairy, with bright sparkling eyes, a clear,
Recollections.
incisive voice, and a laugh that carried you away with
it. I never saw a woman with such an enjoyment of—I was about to
say a joke, but the word is too coarse for her—of a pleasantry. She
was the warmest of friends, and with all her love of fun never
alluded to their weaknesses.... I well remember our first interview. I
expected to find the authoress of Our Village in a most picturesque
residence, overgrown with honeysuckle and roses, and set in an old-
fashioned garden. Her little cottage at Swallowfield, near Reading,
did not answer this picture at all. It was a cottage, but not a pretty
one, placed where three roads met, with only a piece of green
before it. But if the dwelling disappointed me, the owner did not. I
was ushered upstairs (for at that time, crippled by rheumatism, she
was unable to leave her room) into a small apartment, lined with
books from floor to ceiling, and fragrant with flowers; its tenant rose
from her arm-chair with difficulty, but with a sunny smile and a
charming manner bade me welcome. My father had been an old
friend of hers, and she spoke of my home and belongings as only a
woman can speak of such things. Then we plunged, in medias res,
into men and books.”—1852.
LADY MARY WORTLEY MONTAGU
1690-1762

Horace “I went last night to visit her. I give you my word of


Walpole’s honour, and you who know her will believe me without
Letters.
it, the following is a faithful description: I found her in
a little miserable bedchamber of a ready furnished house, with two
tallow candles and a bureau covered with pots and pans. On her
head, in full of all accounts, she had an old black-laced hood
wrapped entirely round so as to conceal all hair, or want of hair; no
handkerchief, but instead of it a kind of horseman’s riding-coat,
calling itself a pet-en-l’air, made of a dark green brocade, with
coloured and silver flowers, and lined with furs; bodice laced; a full
dimity petticoat, sprigged; velvet muffetees on her arms; gray
stockings and slippers. Her face less changed in twenty years than I
would have imagined. I told her so, and she was not so tolerable
twenty years ago that she should have taken it for flattery, but she
did, and literally gave me a box on the ears. She is very lively, all her
senses perfect, her language as imperfect as ever, her avarice
greater.”
Horace “Did I tell you that Lady Mary Wortley is here? She
Walpole’s laughs at my Lady Walpole, scolds my Lady Pomfret,
Letters.
and is laughed at by the whole town. Her dress, her
avarice, and her impudence must amaze any one that never heard
her name. She wears a foul mob, that does not cover her greasy
black locks, that hang loose, never combed or curled; an old
mazarine blue wrapper, that gapes open and discovers a canvas
petticoat. Her face swelled violently on one side with the remains of
a ——, partly covered with a plaister, and partly with white paint,
which for cheapness she has bought so coarse that you would not
use it to wash a chimney.—In three words I will give you her picture
as we drew it in the ‘Sortes Virgilianae’—
‘Insanam vatem aspicies.’
I give you my honour we did not choose it; but Gray, Mr. Coke, Sir
Francis Dashwood, and I, and several others, drew it fairly amongst
a thousand for different people, most of which did not hit as you
may imagine.”—1740.
THOMAS MOORE
1779-1852

Leigh Hunt’s “Moore’s forehead was bony and full of character, with
Autobiograph ‘bumps’ of wit, large and radiant enough to transport a
y.
phrenologist. Sterne had such another. His eyes were
as dark and fine as you would wish to see under a set of vine-
leaves; his mouth generous and good-humoured, with dimples; and
his manner was as bright as his talk, full of the wish to please and
be pleased. He sang, and played with great taste on the pianoforte,
as might be supposed from his musical compositions. His voice,
which was a little hoarse in speaking (at least I used to think so),
softened into a breath, like that of a flute, when singing. In speaking
he was emphatic in rolling the letter r, perhaps out of a despair of
being able to get rid of the national peculiarity.”
S. C. Hall’s “His eyes sparkle like a champagne bubble; there is a
Memories of kind of wintry red, of the tinge of an October leaf, that
Great Men.
seems enamelled on his cheek; his lips are delicately
cut, slight, and changeable as an aspen; the slightly-turned nose
confirms the fun of the expression; and altogether it is a face that
sparkles, beams, and radiates—
‘The light that surrounds him is all from within.’”
1835.
S. C. Hall’s“I recall him at this moment—his small form and
Retrospect ofintellectual face rich in expression, and that expression
a Long Life.
the sweetest, the most gentle, and the kindliest. He
had still in age the same bright and clear eye, the same gracious
smile, the same suave and winning manner I had noticed as the
attributes of what might in comparison be styled his youth (I have
stated I knew him as long ago as 1821); a forehead not remarkably
broad or high, but singularly impressive, firm, and full, with the
organs of music and gaiety large, and those of benevolence and
veneration greatly preponderating; the nose, as observed in all his
portraits, was somewhat upturned. Standing or sitting, his head was
invariably upraised, owing, perhaps, mainly to his shortness of
stature. He had so much bodily activity as to give him the attribute
of restlessness, and no doubt that usual accompaniment of genius
was eminently a characteristic of his. His hair was, at the time I
speak of, thin and very gray, and he wore his hat with the jaunty air
that has been often remarked as a peculiarity of the Irish. In dress,
although far from slovenly, he was by no means precise. He had but
little voice, yet he sang with a depth of sweetness that charmed all
hearers; it was true melody, and told upon the heart as well as the
ear. No doubt much of this charm was derived from association, for
it was only his own melodies he sang.”—1845.
HANNAH MORE
1745-1833

Memoir of “I was much struck by the air of affectionate kindness


Mrs. Hannah with which the old lady welcomed me to Barley Wood
More.
—there was something of courtliness about it, at the
same time the courtliness of the vieille cour, which one reads of, but
so seldom sees. Her dress was of light green Venetian silk; a yellow,
richly embroidered crape shawl enveloped her shoulders; and a
pretty net cap, tied under her chin with white satin riband,
completed the costume. Her figure is singularly petite; but to have
any idea of the expression of her countenance, you must imagine
the small withered face of a woman in her seventy-seventh year;
and, imagine also (shaded, but not obscured, by long and perfectly
white eyelashes) eyes dark, brilliant, flashing, and penetrating,
sparkling from object to object, with all the fire and energy of youth,
and smiling welcome on all around.”—1820.
S. C. Hall’s “Her form was small and slight: her features wrinkled
Memories of with age; but the burden of eighty years had not
Great Men.
impaired her gracious smile, nor lessened the fire of
her eyes, the clearest, the brightest, and the most searching I have
ever seen—they were singularly dark—positively black they seemed
as they looked forth among carefully-trained tresses of her own
white hair; and absolutely sparkled while she spoke of those of
whom she was the venerated link between the present and the long
past. Her manner on entering the room, while conversing, and at our
departure, was positively sprightly; she tripped about from console
to console, from window to window, to show us some gift that bore
a name immortal, some cherished reminder of other days—almost of
another world, certainly of another age; for they were memories of
those whose deaths were registered before the present century had
birth.... She was clad, I well remember, in a dress of rich pea-green
silk. It was an odd whim, and contrasted somewhat oddly with her
patriarchal age and venerable countenance, yet was in harmony with
the youth of her step, and her unceasing vivacity as she laughed and
chatted, chatted and laughed, her voice strong and clear as that of a
girl, and her animation as full of life and vigour as it might have
been in her spring-time.”—1825.
A. M. Hall’s “Her brow was full and well sustained, rather than
Pilgrimages what would be called fine: from the manner in which
to English
Shrines.
her hair was dressed, its formation was distinctly
visible; and though her eyes were half-closed, her
countenance was more tranquil, more sweet, more holy—for it had a
holy expression—than when those deep intense eyes were looking
you through and through. Small, and shrunk, and aged as she was,
she conveyed to us no idea of feebleness. She looked, even then, a
woman whose character, combining sufficient thought and wisdom,
as well as dignity and spirit, could analyse and exhibit, in language
suited to the intellect of the people of England, the evils and dangers
of revolutionary principles. Her voice had a pleasant tone, and her
manner was quite devoid of affectation or dictation; she spoke as
one expecting a reply, and by no means like an oracle. And those
bright immortal eyes of hers—not wearied by looking at the world
for more than eighty years, but clear and far-seeing then—laughing,
too, when she spoke cheerfully, not as authors are believed to speak

‘In measured pompous tones,’—
but like a dear matronly dame, who had especial care and
tenderness towards young women. It is impossible to remember
how it occurred, but in reference to some observation I had made
she turned briskly round and exclaimed, ‘Controversy hardens the
heart, and sours the temper: never dispute with your husband,
young lady; tell him what you think, and leave it to time to fructify.’”
SIR THOMAS MORE
1480-1535

More’s “He was of a meane stature, well proportioned, his


Life of Sir complexion tending to the phlegmaticke, his colour
Thomas
More.
white and pale, his hayre neither black nor yellow, but
betweene both; his eies gray, his countenance amiable
and chearefull, his voyce neither bigg nor shrill, but speaking
plainely and distinctly; it was not very tunable, though he delighted
much in musike, his bodie reasonably healthfull, only that towards
his latter ende by using much writing, he complained much of the
ache of his breaste. In his youth he drunke much water, wine he
only tasted of, when he pledged others; he loved salte meates,
especially powdered beefe, milke, cheese, eggs and fruite, and
usually he eate of corse browne bread, which it may be he rather
used to punish his taste, than from anie love he had thereto. For he
was singularly wise to deceave the world with mortifications, only
contenting himselfe with the knowledge which God had of his
actions: et pater ejus, qui erat in abscondito reddidit ei.”
Campbell’s “Holbein’s portrait of More has made his features
Lives of the familiar to all Englishmen. According to his great-
Lord
Chancellors.
grandson, he was of ‘a middle stature, well
* proportioned, of a pale complexion; his hair of a
chestnut colour, his eyes gray, his countenance mild
and cheerful; his voice not very musical, but clear and distinct; his
constitution, which was good originally, was never impaired by his
way of living, otherwise than by too much study. His diet was simple
and abstemious, never drinking any wine but when he pledged those
who drank to him, and rather mortifying than indulging his appetite
in what he ate.’
Life of Sir “He is rather below than above the middle size; his
Thomas countenance of an agreeable and friendly cheerfulness,
More.
*
with somewhat of an habitual inclination to smile; and
appears more adapted to pleasantry than to gravity or
dignity, though perfectly remote from vulgarity or silliness.”
CAROLINE NORTON
1808-1877

Kemble’s “When I first knew Caroline Sheridan she had not long
Records of been married to the Hon. George Norton. She was
a Girlhood.
splendidly handsome, of an un-English character of
beauty, her rather large and heavy head and features recalling the
grandest Grecian and Italian models, to the latter of whom her rich
colouring and blue-black braids of hair gave her an additional
resemblance. Though neither as perfectly lovely as the Duchess of
Somerset, nor as perfectly charming as Lady Dufferin, she produced
a far more striking impression than either of them, by the
combination of the poetical genius with which she alone, of the
three, was gifted, with the brilliant power of repartee which they
(especially Lady Dufferin) possessed in common with her, united to
the exceptional beauty with which they were all three endowed. Mrs.
Norton was exceedingly epigrammatic in her talk, and comically
dramatic in her manner of relating things.... She was no musician,
but had a deep, sweet contralto voice, precisely the same in which
she always spoke, and which, combined with her always lowered
eyelids (‘downy eyelids’ with sweeping silken fringes), gave such
incomparably comic effect to her sharp retorts and ludicrous
stories.... I admired her extremely.—1827.
“The next time ... was at an evening party at my sister’s house,
where her appearance struck me more than it had ever done. Her
dress had something to do with this effect, no doubt. She had a rich
gold-coloured silk on, shaded and softened all over with black lace
draperies, and her splendid head, neck, and arms, were adorned
with magnificently simple Etruscan ornaments, which she had
brought from Rome, whence she had just returned, and where the
fashion of that famous antique jewellery had lately been revived.
She was still ‘une beauté triomphante à faire voir aux
ambassadeurs.’”
A personal “The most beautiful of ‘the beautiful Sheridans,’
friend. Caroline Norton will also live in the memory of her
friends as one of the most fascinating of women. Her
voice was exceedingly sweet and musical, her movements
wonderfully graceful, and, with the solitary exception of Theodore
Hook, whose rough, coarse wit spared no one, her queenly bearing
won her general adulation and deference. Her face was a pure oval,
her head was crowned by heavy braids of the darkest hair, while the
warmth and light which suffused her expressive countenance gave
her a somewhat un-English appearance. Her eyes were dark; black
curly lashes swept over the warmly-tinted cheek; the lips were of
geranium red; the teeth, dazzlingly white. Altogether she was a vivid
piece of colouring, and as she was always very beautifully dressed, it
did not require her literary reputation to make her at all times
sought after and admired.”
S. C. Hall’s“It seems but yesterday—it is not so very long ago
Retrospect ofcertainly—that I saw for the last time the Hon. Mrs.
a long Life.
Norton. Her radiant beauty was then faded, but her
stately form had been little impaired by years, and she had retained
much of the grace that made her early womanhood so surpassingly
attractive. She combined, in a singular degree, feminine delicacy
with masculine vigour; though essentially womanly, she seemed to
have the force of character of man. Remarkably handsome she
perhaps excited admiration rather than affection. I can easily
imagine greater love to be given to a far plainer woman. She had, in
more than full measure, the traditional beauty of her family, and no
doubt inherited with it some of the waywardness that is associated
with the name of Sheridan.”
THOMAS OTWAY
1651-1685

Gentleman’s “You’ll be glad to know any trifling circumstance


Magazine, concerning Otway. His person was of the middle size,
1745.
about five feet seven inches in height, inclinable to
fatness. He had a thoughtful speaking eye, and that was all. He gave
himself up early to drinking, and, like the unhappy wits of that age,
passed his days between rioting and fasting, ranting jollity and
abject penitence, carousing one week with Lord Pl——th, and then
starving a month in low company at an ale-house on Tower Hill.”
Sir Walter “Otway, heavy, squalid, unhappy; yet tender
Scott’s countenance, but not so squalid as one we formerly
Memoir
of Mrs.
saw; full-speaking, black eyes; it seems as if dissolute
Radcliffe. habits had overcome all his finer feelings, and left him
* little of mind, except a sense of sorrow.” On a picture.
SAMUEL PEPYS
1632-1703

The Cornhill “Pepys spent part of a certain winter Sunday, when he


Magazine, had taken physic, composing ‘a song in praise of a
1874.
*
liberal genius (such as I take my own to be) to all
studies and pleasures.’ The song was successful, but
the diary is, in a sense, the very song that he was seeking; and his
portrait by Hales, so admirably reproduced in Mynors Bright’s
edition, is a confirmation of the diary. Hales, it would appear, had
known his business, and though he put his sitter to a deal of trouble,
almost breaking his neck ‘to have the portrait full of shadows,’ and
draping him in an Indian gown hired expressly for the purpose, he
was preoccupied about no merely picturesque effects, but to portray
the essence of the man. Whether we read the picture by the diary,
or the diary by the picture, we shall at least agree, that Hales was
among the numbers of those who can ‘surprise the manners in a
face.’ Here we have a mouth pouting, moist with desires; eyes
greedy, protuberant, and yet apt for weeping too; a nose great alike
in character and dimensions, and altogether a most fleshly, melting
countenance. The face is attractive by its promise of reciprocity. I
have used the word greedy, but the reader must not suppose that
he can change it for that closely kindred one of hungry, for there is
here no aspiration, no waiting for better things, but an animal joy in
all that comes. It could never be the face of an artist; it is the face
of a viveur—kindly, pleased, and pleasing, protected from excess and
upheld in contentment by the shifting versatility of his desires. For a
single desire is more rightly to be called a lust; but there is health in
a variety, where one may balance and control another.”
ALEXANDER POPE
1688-1744

The “Dick Distich ... we have elected president, not only as


Guardian, he is the shortest of us all, but because he has
1713.
entertained so just a sense of his stature as to go
generally in black, that he may appear yet less. Nay, to that
perfection is he arrived, that he stoops as he walks. The figure of
the man is odd enough; he is a lively little creature, with long arms
and legs: a spider is no ill emblem of him. He has been taken at a
distance for a small windmill.”—1713.
Johnson’s “The person of Pope is well known not to have been
Life formed on the nicest model. He has, in his account of
of Pope.
the Little Club, compared himself to a spider, and, by
another, is described as protuberant behind and before. He is said to
have been beautiful in his infancy; but he was of a constitution
originally feeble and weak; and, as bodies of a tender frame are
easily distorted, his deformity was, probably, in part the effect of his
application. His stature was so low, that to bring him on a level with
common tables it was necessary to raise his seat. But his face was
not displeasing, and his eyes were animated and vivid.... His dress of
ceremony was black, with a tie-wig and a little sword.... He
sometimes condescended to be jocular with servants or inferiors; but
by no merriment, either of others or of his own, was he ever seen
excited to laughter.”
Tyer’s “Pope, as Lord Clarendon says of (the ever
Historicalmemorable) Hales of Eaton, was one of the least men
rhapsody on
Mr.
in the kingdom; who adds of Chillingworth, that he
Pope. was of a stature little superior to him, and that it was
an age in which there were many great and wonderful
men of that size.... He inherited his deformity from his father, who
turns out at last, from the information of Mrs. Racket his relation, to
have been a linen-draper in the Strand.
‘My friend, this shape which you and I will admire,
Came not from Ammon’s son, but from my sire,’
as he expresses himself in his first epistle to Arbuthnot. He was
protuberant behind and before, in the words of his last biographer.
But he carried a mind in his face, as a reverend person once
expressed himself of a singular countenance. He had a brilliant eye,
which pervaded everything at a glance.”
BRYAN WALLER PROCTER
1787-1874

Froude’s “I have also seen and scraped acquaintance with


Life of Procter—Barry Cornwall. He is a slender, rough-faced,
Carlyle.
palish, gentle, languid-looking man, of three or four
and thirty. There is a dreamy mildness in his eye; he is kind and
good in his manners and, I understand, in his conduct. He is a poet
by the ear and the fancy, but his heart and intellect are not
strong.”—1824.
S. C. Hall’s“A decidedly rather pretty little fellow, Procter, bodily
Retrospect ofand spiritually: manners prepossessing, slightly
a long Life.
London-elegant, not unpleasant; clear judgment in
him, though of narrow field; a sound, honourable morality, and airy
friendly ways; of slight, neat figure, vigorous for his size; fine
genially rugged little face, fine head; something curiously dreamy in
the eyes of him, lids drooping at the outer ends into a cordially
meditative and drooping expression; would break out suddenly now
and then into opera attitude and a Là ci darem là mano for a
moment; had something of real fun, though in London style.”
Fields’s “The poet’s figure was short and full, and his voice had
Yesterdays a low, veiled tone habitually in it, which made it
with Authors.
sometimes difficult to hear distinctly what he was
saying. When he spoke in conversation, he liked to be very near his
listener, and thus stand, as it were, on confidential grounds with
him. His turn of thought was apt to be cheerful among his friends,
and he entered readily into a vein of wit and nimble expression.
Verbal facility seemed natural to him, and his epithets, evidently
unprepared, were always perfect. He disliked cant and hard ways of
judging character. He praised easily. He impressed every one who
came near him as a born gentleman, chivalrous and generous in a
high degree.”
THOMAS DE QUINCEY
1786-1859

Masson’s “In addition to the general impression of his


de Quincey. diminutiveness and fragility, one was struck with the
peculiar beauty of his head and forehead, rising
disproportionately high over his small, wrinkly visage and gentle,
deep-set eyes. His talk was in the form of really harmonious and
considerate colloquy, and not at all in that of monologue.... That
evening passed, and though I saw him once or twice again, it is the
last sight I remember best. It must have been, I think, in 1846, on a
summer afternoon. A friend, a stranger in Edinburgh, was walking
with me in one of the pleasant, quiet, country lanes near Edinburgh.
Meeting us, and the sole living thing in the lane beside ourselves,
came a small figure, not untidily dressed, but with his hat pushed far
up in front of his forehead, and hanging on his hindhead, so that the
back rim must have been resting on his coat-collar. At a little
distance I recognised it to be De Quincey; but, not considering
myself entitled to interrupt his meditations, I only whispered the
information to my friend, that he might not miss what the look at
such a celebrity was worth. So we passed him, giving him the wall.
Not unnaturally, however, after we passed, we turned round for the
pleasure of a back view of the wee, intellectual wizard. Whether my
whisper and our glance had alarmed him, as a ticket-of-leave man
might be rendered uneasy in his solitary walk by the scrutiny of two
passing strangers, or whether he had some recollection of me
(which was likely enough, as he seemed to forget nothing), I do not
know, but we found that he, too, had stopped, and was looking
round at us. Apparently scared at being caught doing so, he
immediately wheeled round again, and hurried his face towards a
side-turning in the lane, into which he disappeared, his hat still
hanging on the back of his head. That was my last sight of De
Quincey.”—1846.
Page’s “Pale he was, with a head of wonderful size, which
de Quincey. served to make more apparent the inferior dimensions
of his body, and a face which lived the sculptured past
in every lineament from brow to chin. One seeing him would surely
be tempted to ask who he was that took off his hat with such grave
politeness, remaining uncovered if a lady were passing almost until
she was out of sight, and would get for an answer likely enough,
‘Oh, that is little De Quincey, who hears strange sounds and eats
opium. Did you ever see such a little man?’ Little he was, indeed, like
Dickens and Jeffrey, the latter of whom had so little flesh that it was
said that his intellect was indecently exposed.”
James Payn’s “In the ensuing summer, after the publication of
Literary another volume of poems, I visited Edinburgh, and
Recollections.
called upon De Quincey, to whom I had a letter of
introduction from Miss Mitford. He was at that time residing at
Lasswade, a few miles from the town, and I went thither by coach.
He lived a secluded life, and even at that date had become to the
world a name rather than a real personage; but it was a great name.
Considerable alarm agitated my youthful heart as I drew near the
house: I felt like Burns on the occasion when he was first about ‘to
dinner wi’ a Lord.’... My apprehensions, however, proved to be utterly
groundless, for a more gracious and genial personage I never met.
Picture to yourself a very diminutive man, carelessly—very carelessly
—dressed; a face lined, careworn, and so expressionless that it
reminded one of ‘that chill changeless brow, where cold
Obstruction’s apathy appals the gazing mourners heart’—a face like
death in life. The instant he began to speak, however, it lit up as
though by electric light; this came from his marvellous eyes, brighter
and more intelligent (though by fits) than I have ever seen in any
other mortal. They seemed to me to glow with eloquence. He spoke
of my introducer, of Cambridge, of the Lake Country, and of English
poets. Each theme was interesting to me, but made infinitely more
so by some apt personal reminiscence. As for the last-named
subject, it was like talking of the Olympian gods to one not only
cradled in their creed, but who had mingled with them, himself half
an immortal.”
ANN RADCLIFFE
1764-1823

Kavanagh’s “Ann Ward’s education was plain and somewhat formal.


English She was shy; she showed no extraordinary genius, and
Women
of Letters.
the times were not propitious to the development of
* female intellect. The young girl’s person was probably
more admired than her mind. She was short, but
exquisitely proportioned; she had a lovely complexion, fine eyes and
eyebrows, and a beautiful mouth. She had a sweet voice too, and
sang with feeling and taste.”
Scott’s “This admirable writer, whom I remember from about
Memoir the time of her twentieth year, was, in her youth, of a
of Ann
Radcliffe.
figure exquisitely proportioned, while she resembled
her father and his brother and sister in being low of
stature. Her complexion was beautiful, as was her whole
countenance, especially her eye, eyebrows, and mouth.”
Memoir of “Mrs. Radcliffe, though a giant in intellect, was low in
Mrs. stature, and of a slender form, but exquisitely
Ann Radcliffe.
proportioned: her countenance was beautiful and
expressive.”
SIR WALTER RALEIGH
1552-1618

The “In appearance what manner of man was Raleigh


Nineteenth when in Ireland? There was much change, of course,
Century,
1881.
from the dashing captain of eight and twenty, when he
* was putting the unarmed men to the sword and
hanging the women in Dingle Bay, to the admiral of
sixty-five who, between the Tower and the scaffold, visited his old
haunts in the county of Cork for the last time in the three summer
months of 1617.
“But all accounts agree in giving him a commanding presence, a
handsome and well-compacted figure, a forehead rather too high;
the lower part of his face, though partly hidden by the moustache
and peaked beard, showing rare resolution. His portrait, a life-sized
head, painted when he was Major of Youghal, was recently
presented to the owner of his house, where it had been years ago,
by the senior member for the county of Waterford; and another
original picture of him when in Ireland is in the possession of the
Rev. Pierce W. Drew of Youghal. Both these Irish pictures show the
same lofty brow and firm lips. There is an old and much-prized
engraving by Vander Werff of Amsterdam that seems to combine all
his characteristic features—the extraordinarily high forehead, the
moustache and peaked beard, ill-concealing a too determined
mouth. The likeness is most striking.”
Aubrey’s “He was a tall, handsome, and bold man; but his næve
Lives of was, that he was damnably proud.... In the great
Eminent
Persons.
parlour at Downton, at Mr. Ralegh’s, is a good piece
* (an originall) of Sir W. in a white sattin doublet, all
embroidered with rich pearles, and a mighty rich
chaine of great pearles about his neck. The old servants have told
me that the pearles were neer as big as the painted ones. He had a
most remarkable aspect, an exceedingly high forehead, long-faced,
and sourlie-bidded, a kind of pigge-eie.... He spake broad
Devonshire to his dye-ing day. His voice was small, as likewise were
my schoolfellowes, his gr. nephews.”
Publications “In all the pictures we have of him, there is almost
of nothing to suggest the typical Englishman. Burly and
the Prince
Society.
robust. About six feet in height, he is rather thin than
* corpulent, and in the vivacity of expression and the
nervous cast of his features he resembles rather the
modern New-Englander than the old-time Englishman. He was
nineteen years younger than Elizabeth, and had, as Naunton
describes him, ‘a good presence in a handsome and well-compacted
person.’ Fuller has already told us that at the time of his entrance at
the court his clothes made a ‘considerable part of his estate.’ He
seems to have had an innate love for the luxury and splendour of
dress. He lived at a period when gentlemen as well as ladies
indulged in all the glory of gay colours. Edwards, describing some of
the more noted pictures of him, says: ‘In another full-length, which
long remained in the possession of his descendants, he is apparelled
in a white satin pinked vest, close sleeved to the wrists with a brown
doublet finely flowered and embroidered with pearls, and a sword,
also brown and similarly decorated. Over the right hip is seen the
jewelled pommel of his dagger. He wears his hat, in which is a black
feather with a ruby and pearl drop. His trunk hose and fringed
garters appear to be of white satin. His buff-coloured shoes are tied
with white ribbons.’”
CHARLES READE
1814-1884

Coleman’s “On arriving at Bolton Row I was shown into a large


Personal room littered over with books, MSS. agenda,
Reminiscence
s.
newspapers of every description from the Times and
the New York Herald down to the Police News. Before
me stood a stately and imposing man of fifty or fifty-one, over six
feet high, a massive chest, herculean limbs, a bearded and leonine
face, giving traces of a manly beauty which ripened into majesty as
he grew older. Large brown eyes which could at times become
exceedingly fierce, a fine head, quite bald on the top but covered at
the sides with soft brown hair, a head strangely disproportioned to
the bulk of the body; in fact I could never understand how so large a
brain could be confined in so small a skull. On the desk before him
lay a huge sheet of drab paper on which he had been writing—it was
about the size of two sheets of ordinary foolscap; in his hand one of
Gillott’s double-barrelled pens. (Before I left the room he told me he
sent Gillott his books, and Gillott sent him his pens.)
“His voice, though very pleasant, was very penetrating. He was
rather deaf, but I don’t think quite so deaf as he pretended to be.
This deafness gave him an advantage in conversation; it afforded
him time to take stock of the situation, and either to seek refuge in
silence or to request his interlocutor to propound his proposal
afresh. At first he was very cold, but at last, carried away by the
ardour of my admiration for his works, he thawed, and in half an
hour he was eager, excited, delighted and delightful.”—1856.
The “The man in truth justified Lavater, for his
Contemporar physiognomy was noble, and his body the perfection of
y
symmetry and grace. Nature gave him a forehead as
high as Shakespeare’s, but broader; the mild, pensive
Review, ox-eye so dear to the old Greek æsthetes; a marble
1884.
skin, a mouth that was sarcasm itself. His personal
attractiveness was phenomenal. In any roomful of people, however
illustrious, he became involuntarily—for he was as little self-asserting
off his paper as he was dogmatic on it—the centre. Living immersed
in Bohemianism, and in the society of a large-hearted, yet not very
cultured woman, he never parted company with his Ipsden breeding,
and his natural bearing was that of one born to command.”
Eclectic “In personal appearance Mr. Reade is tall, erect, of a
Magazine, commanding presence, with a full, expressive brown
1880.
eye and a noble brow. His manner is singularly
dignified without being arrogant, and in society he sustains an
enviable reputation as a conversationalist.”
SAMUEL RICHARDSON
1689-1761

Barbauld’s “Richardson was, in person, below the middle stature,


Life of and inclined to corpulency; of a round, rather than oval
Richardson.
*
face, with a fair, ruddy complexion. His features, says
one who speaks from recollection, bore the stamp of
good nature, and were characteristic of his placid and amiable
disposition. He was slow in speech, and, to strangers at least, spoke
with reserve and deliberation; but in his manners was affable,
courteous, and engaging, and when surrounded with the social circle
he loved to draw around him, his eye sparkled with pleasure, and
often expressed that particular spirit of archness which we see in
some of his characters, and which gave, at times, a vivacity to his
conversation not expected from his general taciturnity and quiet
manners.”
Richardson’s “Short, rather plump, about five feet five inches, fair
Corresponde wig, one hand generally in his bosom, the other a cane
nce.
in it, which he leans upon under the skirts of his coat,
that it may imperceptibly serve him as a support when attacked by
sudden tremors or dizziness; of a light brown complexion; teeth not
yet failing him. Looking directly foreright as passengers would
imagine, but observing all that stirs on either hand of him, without
moving his short neck; a regular even pace, stealing away ground
rather than seeming to rid it; a gray eye, too often overclouded by
mistiness from the head, by chance lively, very lively, if he sees any
he loves; if he approaches a lady, his eye is never fixed first on her
face, but on her feet, and rears it up by degrees, seeming to set her
down as so and so.”—1749.
Stephen’s “He looks like a plump white mouse in a wig, with an
Richardson. air at once vivacious and timid, a quick excitable
* nature, taking refuge in the outside of a smug, portly
tradesman. Two coloured engravings in Mrs. Barbauld’s
volumes give us Richardson amidst his surroundings.... One
introduces us to Richardson at home. Half a dozen ladies and
gentlemen are sitting by the open window in his bare parlour looking
out into the garden. There is only one spindle-legged table, and a
set of uncompromising wooden chairs, just enough to accommodate
the party.... Miss Highmore, whose hoop can scarcely be squeezed
into her straight-backed chair, is quietly sketching the memorable
scene. We are truly grateful to her, for there sits the little idol of the
party in his usual morning dress, a nondescript brown dressing-gown
with a cap on his head of the same materials. His plump little frame
fills the chair, and he is apparently raising one foot for an emphatic
stamp, as he reads a passage of Sir Charles Grandison. We can see
that as he concludes he will be applauded with deferential gasps of
heartfelt admiration.”
SAMUEL ROGERS
1763-1855

S. C Hall’s “His countenance was the theme of continual jokes. It


Memories of was ‘ugly,’ if not repulsive. The expression was in no
Great Men.
way, nor under any circumstances, good; he had a
drooping eye and a thick underlip; his forehead was broad, his head
large—out of proportion indeed to his form; but it was without the
organs of benevolence and veneration, although preponderating in
that of ideality. His features were ‘cadaverous.’ Lord Dudley once
asked him why, now that he could afford it, he did not set up his
hearse; and it is said that Sydney Smith gave him mortal offence by
recommending him, ‘when he sat for his portrait, to be drawn saying
his prayers, with his face hidden by his hands.’”
Jerdan’s Men“His personal appearance was extraordinary, or rather
I his countenance was unique. His skull and facial
have known.
expression bore so striking a likeness to the skeleton
pictures which we sometimes see of Death, that the facetious
Sydney Smith (at one of the dressed evening parties ...) entitled him
the ‘Death dandy.’ And it was told (probably with truth), that the
same satirical wag inscribed upon the capital portrait in his
breakfast-room, ‘Painted in his lifetime.’”
Mackay’s “My first look at the poet, then in his seventy-eighth
Forty Years’ year, was an agreeable surprise, and a protest in my
Recollections.
mind against the malignant injustice which had been
done him. As a young man he might have been uncomely, if not as
ugly as his revilers had painted him, but as an old man there was an
intellectual charm in his countenance, and a fascination in his
manner which more than atoned for any deficiency of personal
beauty.”—1840.
Welcome to our website – the ideal destination for book lovers and
knowledge seekers. With a mission to inspire endlessly, we offer a
vast collection of books, ranging from classic literary works to
specialized publications, self-development books, and children's
literature. Each book is a new journey of discovery, expanding
knowledge and enriching the soul of the reade

Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.

Let us accompany you on the journey of exploring knowledge and


personal growth!

textbookfull.com

You might also like