Beginning IoT Projects: Breadboard-less Electronic Projects
By Charles Bell
()
About this ebook
The book begins with a brief overview of IoT followed by primers for the two most popular platforms; Arduino and Raspberry Pi. There is also a short tutorial on programming each host; Arduino C-like sketches and Python scripts respectfully. Thus, the book also helps you get started with your choice of platform. Next, you’ll learn the basics for the Qwiic and Grove component systems.
The rest of the book presents a number of projects organized into easy-to-follow chapters that details the goal for the project, the components used, a walk-through of the code, and a challenge section that provides suggestions on how to improve or augment the project. Projects are presented for both the Arduino and Raspberry Pi where possible making each project as versatile as possible.
What You'll Learn
- Write Arduino sketches
- Create Python scripts for the Raspberry Pi
- Build IoT projects with Arduino and Raspberry Pi
- Use the Qwiic and Grove component systems
- Join the electronics and IoT hobby world with almost no experience
- Host projects data in the cloud using ThingSpeak
Who This Book Is For
Those interested in building or experimenting with IoT solutions but have little or no experience working with electronics. This includes those with little or no programming experience. A secondary target would include readers interested in teaching the basics of working with Arduino and Raspberry Pi to others.
Charles Bell
Dr. Charles A Bell is a Senior Software Engineer at Oracle. He iscurrently the lead developer for backup and a member of the MySQLBackup and Replication team. He lives in a small town in ruralVirginia with his loving wife. He received his Doctor of Philosophy inEngineering from Virginia Commonwealth University in 2005. Hisresearch interests include database systems, versioning systems,semantic web, and agile software development.
Read more from Charles Bell
Maintaining and Troubleshooting Your 3D Printer Rating: 0 out of 5 stars0 ratingsIntroducing MySQL Shell: Administration Made Easy with Python Rating: 0 out of 5 stars0 ratingsIntroducing the MySQL 8 Document Store Rating: 0 out of 5 stars0 ratingsWindows 10 for the Internet of Things: Controlling Internet-Connected Devices from Raspberry Pi Rating: 0 out of 5 stars0 ratingsBeginning Sensor Networks with XBee, Raspberry Pi, and Arduino: Sensing the World with Python and MicroPython Rating: 0 out of 5 stars0 ratingsIntroducing InnoDB Cluster: Learning the MySQL High Availability Stack Rating: 0 out of 5 stars0 ratings
Related to Beginning IoT Projects
Related ebooks
Raspberry Pi IoT Projects: Prototyping Experiments for Makers Rating: 0 out of 5 stars0 ratingsRaspberry Pi Blueprints Rating: 0 out of 5 stars0 ratingsRaspberry Pi Essentials Rating: 0 out of 5 stars0 ratingsRaspberry Pi Home Automation with Arduino - Second Edition Rating: 0 out of 5 stars0 ratingsProgramming Microcontrollers with Python: Experience the Power of Embedded Python Rating: 0 out of 5 stars0 ratingsArduino for Secret Agents Rating: 4 out of 5 stars4/5Learn Arduino Prototyping in 10 days Rating: 0 out of 5 stars0 ratingsArduino Home Automation Projects Rating: 3 out of 5 stars3/5Advanced Home Automation Using Raspberry Pi: Building Custom Hardware, Voice Assistants, and Wireless Nodes Rating: 0 out of 5 stars0 ratingsArduino Electronics Blueprints Rating: 4 out of 5 stars4/5Understanding Network Hacks: Attack and Defense with Python Rating: 0 out of 5 stars0 ratingsSmart Internet of Things Projects Rating: 4 out of 5 stars4/5The IoT Hacker's Handbook: A Practical Guide to Hacking the Internet of Things Rating: 0 out of 5 stars0 ratingsInternet of Things with Arduino Blueprints Rating: 0 out of 5 stars0 ratingsGetting Started with Electronic Projects Rating: 5 out of 5 stars5/5Building Wireless Sensor Networks Using Arduino Rating: 4 out of 5 stars4/5Arduino Applied: Comprehensive Projects for Everyday Electronics Rating: 0 out of 5 stars0 ratingsFundamentals of IoT: Get familiar with the building blocks of IoT (English Edition) Rating: 0 out of 5 stars0 ratingsBeagleBone for Secret Agents Rating: 5 out of 5 stars5/5Programming the BeagleBone Black: Getting Started with JavaScript and BoneScript Rating: 0 out of 5 stars0 ratingsBuilding Smart Homes with Raspberry Pi Zero Rating: 0 out of 5 stars0 ratingsRaspberry Pi LED Blueprints Rating: 0 out of 5 stars0 ratingsElectronics Projects with the ESP8266 and ESP32: Building Web Pages, Applications, and WiFi Enabled Devices Rating: 1 out of 5 stars1/5Home Automation with Raspberry Pi: Projects Using Google Home, Amazon Echo, and Other Intelligent Personal Assistants Rating: 0 out of 5 stars0 ratingsESP8266 Internet of Things Cookbook Rating: 5 out of 5 stars5/5Software Defined Radio A Complete Guide - 2021 Edition Rating: 0 out of 5 stars0 ratingsRaspberry Pi Projects for the Evil Genius Rating: 0 out of 5 stars0 ratingsProgramming the Raspberry Pi, Third Edition: Getting Started with Python Rating: 5 out of 5 stars5/5Raspberry Pi: 40 Outstanding Raspberry Pi Tips and Tricks for Absolute Beginners Rating: 0 out of 5 stars0 ratingsMicroPython A Complete Guide - 2020 Edition Rating: 0 out of 5 stars0 ratings
Hardware For You
iPhone 16 Pro Max User Manual: The Complete Step-By-Step Guide to Maximize your New iPhone 16 Pro Max and iOS 18 Rating: 0 out of 5 stars0 ratingsCompTIA A+ Complete Review Guide: Exam Core 1 220-1001 and Exam Core 2 220-1002 Rating: 5 out of 5 stars5/5macOS Sonoma For Dummies Rating: 0 out of 5 stars0 ratingsCompTIA A+ Complete Review Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 5 out of 5 stars5/5Exploring Arduino: Tools and Techniques for Engineering Wizardry Rating: 4 out of 5 stars4/5Chip War: The Fight for the World's Most Critical Technology Rating: 4 out of 5 stars4/5Electrical Engineering | Step by Step Rating: 0 out of 5 stars0 ratingsProgramming Arduino: Getting Started with Sketches Rating: 4 out of 5 stars4/5Apple Watch For Dummies Rating: 0 out of 5 stars0 ratingsiPhone For Dummies Rating: 0 out of 5 stars0 ratingsChromebook For Dummies Rating: 5 out of 5 stars5/5Amazon Web Services (AWS) Interview Questions and Answers Rating: 5 out of 5 stars5/5Unlock Any Roku Device: Watch Shows, TV, & Download Apps Rating: 0 out of 5 stars0 ratingsMastering Apple MacBook - MacBook Pro, MacBook Air, MacOS Ultimate User Guide Rating: 1 out of 5 stars1/5Raspberry Pi Electronics Projects for the Evil Genius Rating: 3 out of 5 stars3/5Build Your Own PC Do-It-Yourself For Dummies Rating: 4 out of 5 stars4/5Raspberry Pi Cookbook for Python Programmers Rating: 0 out of 5 stars0 ratingsTroubleshooting and Maintaining Your PC All-in-One For Dummies Rating: 5 out of 5 stars5/5Exploring Apple iPad: iPadOS 15 Edition: The Illustrated, Practical Guide to Using your iPad Rating: 0 out of 5 stars0 ratingsAfter Steve: How Apple Became a Trillion-Dollar Company and Lost Its Soul Rating: 4 out of 5 stars4/5CompTIA A+ Complete Study Guide: Core 1 Exam 220-1101 and Core 2 Exam 220-1102 Rating: 0 out of 5 stars0 ratingsArduino Electronics Blueprints Rating: 4 out of 5 stars4/5Upgrading and Fixing Computers Do-it-Yourself For Dummies Rating: 4 out of 5 stars4/5Linux All-in-One For Dummies Rating: 3 out of 5 stars3/5Dancing with Qubits: How quantum computing works and how it can change the world Rating: 5 out of 5 stars5/5MacBook For Dummies Rating: 4 out of 5 stars4/5Experts' Guide to iPad Note Taking with an Apple Pencil Rating: 3 out of 5 stars3/5
Reviews for Beginning IoT Projects
0 ratings0 reviews
Book preview
Beginning IoT Projects - Charles Bell
Part IGetting Started with IoT
Getting Started with IoT
This part begins with an overview of the Internet of Things and then introduces the hardware platforms we will use in the book to learn how to build IoT projects. Platforms include the Arduino and Raspberry Pi. The part also includes tutorials on how to write the software to run on the platforms using the Arduino language for writing sketches and Python for programming on the Raspberry Pi.
© Charles Bell 2021
C. BellBeginning IoT Projectshttps://doi.org/10.1007/978-1-4842-7234-3_1
1. Introduction to the Internet of Things
Charles Bell¹
(1)
Warsaw, VA, USA
Much has been written about the Internet of Things (IoT). Some sources are more about promoting IoT as their latest innovation (that costs more money); other sources seem to suggest IoT is something everyone needs or be left behind in the dust of antiquity.
Fortunately, books and similar media avoid the sales pitch to expand on the science and technology for implementing and managing the data for IoT, while other texts concentrate on the future or the inevitable evolution of our society as we become more connected to the world around us each and every day. However, you need not dive into such tomes or be able to recite rhetoric to get started with the IoT. In fact, through the efforts of many companies, you can explore the IoT without intensive training or expensive hardware and software.
However, most publications¹ assume the reader knows or wants to know how to connect discrete components together to build the hardware from scratch. That means if you’d like to learn more about building Internet of Things (IoT) solutions, but don’t have the time or will to learn all of the nuances of electronics and discrete components, you’ve been left with little recourse.² That is, until now.
In this book, we will explore how to build IoT solutions using a series of basic projects without the need to learn the difference between a diode and a resistor. In fact, we will be using two modular platforms that you can connect to your host board without the need to wire anything together!³ This is accomplished by using a special adapter board/shield for your device that permits you to connect to modules that include sensors, displays, switches, and more!
However, before we get into the details of devices, boards, modules, etc., let’s take a moment and learn what the Internet of Things is and what sort of solutions are classified as IoT projects.
What Is the Internet of Things?
So what is this IoT?⁴ I’ll begin by explaining what it isn’t. The IoT is not a new device or proprietary software or some new piece of hardware. It is not a new marketing scheme to sell you more of what you already have by renaming it and pronouncing it new.
⁵ While it is true that the IoT employs technology and techniques that already exist, the way they are employed, coupled with the ability to access the solution from anywhere in the world, makes the IoT an exciting concept to explore. Now let’s discuss what the IoT is.
The essence of the IoT is simply interconnected devices that generate and exchange data from observations, facts, and other data, making it available to anyone you’d like – only yourself or immediate family – or share it with the world. While there seem to be some marketing efforts attempting to make anything connected to the Internet an IoT solution or device (not unlike the shameless labeling of everything cloud
), IoT solutions are designed to make our knowledge of the world around us timelier and more relevant by making it possible to get data about anything from anywhere at any time.
As you can imagine, if we were to connect every device around us to the Internet and make sensory data available for those devices, it is clear there would be potential for the number of IoT devices to exceed the human population of the planet⁶ and for the data generated to rapidly exceed the capabilities of all but the most sophisticated database systems. These concepts are commonly known as addressability and big data, which are two of the most active and debated topics in IoT. But don’t worry about these terms – I mention them here for completeness and possibly to pique your interest. You can read more about these issues at your leisure.
However, the IoT is all about understanding the world around us. That is, we can leverage the data to make our world and our understanding of it better.
Before we proceed, let’s review some terms that can help us understand the context and subject better. The following are the major terms used in this book:
IoT solution: A complete project that implements the software and hardware to perform one or more tasks
IoT device: The hardware (and associated software) that connects to the Internet sending data to one or more IoT services
IoT service: A product or set of services in the cloud used to process IoT data
IoT vendor: Those businesses that provide services for IoT solutions
IoT data: Data generated from one or more IoT devices such as observations from one or more sensors
Knowledge: The conclusions one can draw from the data once it has been made available in the IoT services (cloud) for review
Now that we know what the IoT is and some terms we use to describe it, let’s dive further into what IoT means to us.
The Internet of Things and You
The best example of a sophisticated IoT device is the human body. It is a complex marvel of ingenious sensory apparatus that allow us to see, hear, taste, and even feel through touch anything we encounter or get near. Even our brains can store visual and auditory events recalling them at will. IoT solutions mimic many of these sensory capabilities and therefore can become an extension of our own abilities.
While that may sound a bit grandiose (and it is), IoT solutions can record observations in the form of data from one or more sensors. Sensors are devices that produce either analog or digital values. We can then use the data collected to draw conclusions about the subject matter. IoT devices can also retrieve information from one device and forward it to another, but let’s keep it simple and focus on devices that detect things about the world around us and what that knowledge could do for us.
For example, an IoT device could be connected to a sensor to detect when a mailbox is opened. In this case, the knowledge we gain from a simple switch opening or closing (depending on how it is implemented and interpreted) may be used to predict when incoming mail has arrived or when outgoing mail has been picked up. I use the term predict because the sensor (switch) only tells us the door was opened or closed, not that anything was placed in or removed from the mailbox itself – that would require additional sensors.
When working with IoT projects that include sensors, you should always think about what conclusions you can draw from the data. Sometimes, like the switch in the mailbox, it can be only a few things, which is most often the case. By defining what we can perceive (learn) from the sensor data, we can better understand what our IoT project and its data can do for us.
A more sophisticated example is using a series of sensors to record atmospheric data such as temperature, humidity, barometric pressure, wind speed, ambient light, rainfall, and so forth, to monitor the weather and perform analysis on the data to predict trends in weather. That is, we can predict within a reasonable certainty that precipitation is in the area and to some extent its severity.
Now, add the ability to see this data not only in real time (as it occurs) but also remotely from anywhere in the world, and the solution becomes more than a simple weather station. It becomes a way to observe the weather about one place from anywhere in the world.
This example may be a bit commonplace since you can tune into any number of television, web, and radio broadcasts to hear the weather from anywhere in the world. But consider the implications of building such a solution in your home. Now you can see data about the weather at your own home from anywhere!
In the same way, but perhaps on a smaller scale, we can build solutions to monitor plants to help us understand how often they need water and other nutrients. Or perhaps we can monitor our pets while we are away at work. Further, we can record data about wildlife in our area to better understand our effect on nature.
IoT Is More Than Just Connected to the Internet
So, if a device is connected to the Internet, does that make it an IoT solution? That depends on whom you ask. Some will say the answer is yes. However, others (like me) contend that the answer is no unless there is some benefit from doing so.
For example, if you could connect your toaster to the Internet, what would be the benefit of doing so? What knowledge would you gain? It would be pointless (or at least extremely eccentric) to get a text on your phone from your toaster stating that your toast is ready given that it only takes a couple of minutes to complete. In this case, the answer is no. However, if you have someone – such as a child or perhaps an older adult – whom you would like to monitor, it may be helpful to be able to check to see how often and when they use a device like a toaster so that you can check on them.⁷ That is, you can use the data to help you make decisions about their care and safety.
Allow me to illustrate with another example. I was fortunate to participate in a design workshop held on the Microsoft campus in the late 1990s. During our tour of the campus, we were introduced to the world’s first Internet-enabled refrigerator (also called a smart refrigerator).
There were sensors in the shelves to detect the weight of food. It was suggested that, with a little ingenuity, you could use the sensors to notify your grocer when your milk supply ran low, which would enable people to have their grocery shopping not only online but also automatic. This would have been great if you lived in a location where your grocer delivers, but not very helpful for those of us who live in rural areas.⁸ While it wasn’t touted an IoT device (the term was coined later), many felt the device illustrated what could be possible if devices were connected to the Internet.
Thus, being connected to the Internet doesn’t make something IoT. Rather, IoT solutions must be those things that provide some meaning – however small that benefit is to someone or some other device or service. More importantly, IoT solutions allow us to sense the world around us and learn from those observations. The real tricky part is in how the data is collected, stored, and presented. We will see all of these in practice through examples in later chapters.
IoT solutions can also take advantage of companies that provide services that can help enhance or provide features that you can use in your IoT solutions. These features are commonly called IoT services and range from storage and presentation to infrastructure services, such as hosting.
IoT Services
Sadly, there are companies that tout having IoT products and services that are nothing more than marketing hype – much like what some companies have done by prepending cloud
or appending for the cloud
to the name. Fortunately, there are some good products and services being built especially for IoT. These range from data storage and hosting to specialized hardware and sophisticated data analysis and visualization.
Indeed, businesses are adding IoT services to their product offerings, and it isn’t the usual suspects, such as the Internet giants. I have seen IoT solutions and services being offered by Cisco, AT&T, HP, and countless start-ups and smaller businesses.
You may be wondering what these services and products are and why someone would consider using them. That is, what is an IoT service, and why would you decide to buy it? The biggest concerns in the decision to buy a service are cost and time to market.
For example, if you want to use IoT in your organization but your developers do not have the resources or expertise and obtaining them will require more than the cost of the service, it may be more economical to purchase the service. However, you should also consider any additional software or hardware changes (sometimes called retooling) necessary in the decision. I once encountered a well-meaning and well-documented contracted service that permitted a product to go to market sooner than projected at a massive savings. Sadly, while the champions of that contract won awards for technical achievement, they failed to consider the fact that the systems had to be retooled to use the new service. More specifically, it took longer to adopt the new service than it would to write one from scratch. So instead of saving money, the organization spent nearly twice the original budget and was late to market. Clearly, you must consider all factors.
Similarly, if your time is short or you have hard deadlines to meet to make your solution production-ready, it may be quicker to purchase an IoT service rather than create or adapt your own. This may require spending a bit more, but in this case, the motivation is time and not (necessarily) cost. Of course, project planning is a balance of cost, time, and features.
So what are some of the IoT services available? The following lists a few that have emerged in the last few years. It is likely more will be offered as IoT solutions and services mature:
Enterprise IoT data hosting and presentation: Services that allow your users to develop enterprise IoT solutions from connecting to managing and customizing data presentation in a friendly form, such as graphs, charts, and so forth.
IoT data storage: Services that permit you to store your IoT data and get simple reports.
Networking: Services that provide networking and similar communication protocols or platforms for IoT. Most specialize in machine-to-machine (M2M) services.
IoT hardware platforms: Vendors that permit you to rapidly develop and prototype IoT devices using a hardware platform and a host of supported modules and tools for building devices ranging from a simple component to a complete device.
For the hobbyist or enthusiast, you may not need such sophistication. Rather, you may need only a place to store or display your data. In those cases, there are IoT vendors that provide such products (some free, from fee-based) using relatively simple-to-configure features. Two such examples include Microsoft Azure (https://portal.azure.com) and ThingSpeak for IoT Projects (https://thingspeak.com/). We will see ThingSpeak in action later on in book.
Now that you know more about what IoT is, let’s look at a few examples of IoT solutions to get a better idea of what IoT solutions can do and how they are employed.
A Brief Look at IoT Solutions
Recall an IoT solution is simply a set of devices designed to produce, consume, or present data about some event or series of events or observations. This can include devices that generate data, such as a sensor, devices that combine data to deduce something, devices or services designed to tabulate and store the data, and devices or systems designed to present the data. Any or all of these may be connected to the Internet.
IoT solutions may include one or all of these qualities, whether it is combined into a single device such as a web camera; used as a sensor package and monitoring unit, such as a weather station; or used as a complex system of dedicated sensors, aggregators, data storage, and presentation, such as a complete home automation system. Figure 1-1 shows a futuristic picture of all devices – everywhere – connected to the Internet through databases, data collectors or integrators, display services, or other devices.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig1_HTML.jpgFigure 1-1
The future of IoT – all devices, everywhere⁹
Let’s take a look at some example IoT solutions. The IoT solutions described in this section are a mix of solutions that should give you an idea of the ranges of sizes and complexities of IoT solutions. I also point out how some of these solutions leverage services from IoT vendors.
Sensor Networks
Sensor networks are one of the most common forms of IoT solutions. Simply stated, sensor networks allow you to observe the world around you and make sense of it. Sensor networks could take the form of a pond monitoring system that alerts you to water level, water purity (contamination), or water temperature or detects predators or even turns on features automatically, such as lighting or fish feeders.
If you, or someone you know, have spent any time in a medical facility, it’s likely that a sensor network was employed to monitor body functions, such as temperature, cardiac and respiratory rates, and even movement. Modern automobiles also contain sensor networks dedicated to monitoring the engine, climate, and, even in some cars, road conditions. For example, the lane warning feature uses sensors (typically a camera, microprocessor, and software) to detect when you drift too far toward lane or road demarcations.
Thus, sensor networks employ one or more sensors that take measurements (observations) about an event or state and communicate that data to another component or node in the network, which is then presented, in some form or another, for analysis. Let’s take a look at an example of an important medical IoT solution.
Medical Applications
Medical applications – including health monitoring and fitness – are gaining a lot of attention as consumer products. These solutions cover a wide range of capabilities, such as the fitness features built into the Apple Watch to fitness bands that keep track of your workout and even medical applications that help you control life-threatening conditions. For example, there are solutions that can help you manage diabetes.
Diabetes is a disease that affects millions of people worldwide (www.diabetes.org). There are several forms, the most serious being type 1 (www.diabetes.org/diabetes-basics/type-1/?loc=db-slabnav). Those afflicted with type 1 diabetes do not produce enough (or any) insulin due to genetic deficiencies, birth defects, or injuries to the pancreas. Insulin is a hormone that the body uses to extract a simple sugar called glucose, which is created from sugars and starches, from blood for use in cells.
Thus, type 1 diabetics must monitor their blood glucose to ensure that they are using their medications (primarily insulin) properly and balanced with a healthy lifestyle and diet. If their blood glucose levels become too low or too high, they can suffer from a host of symptoms. Worse, extremely low blood glucose levels are very dangerous and can be fatal.
One of the newest versions of a blood glucose tester consists of a small sensor that is inserted in the body along with a monitor that connects to the sensor via Bluetooth. You wear the monitor on your body (or keep it within 20 feet at all times). The solution is marketed by Dexcom (dexcom.com) and is called a continuous glucose monitor (CGM) that permits the patient to share their data to others via their phone. Thus, the patient pairs their CGM with their phone and then shares the data over the Internet to others. This could be loved ones, those that help with their care, or even medical professionals. Figure 1-2 shows an example of the Dexcom CGM app and sensor. The monitor is on the left, and the sensor and transmitter are on the right. The sensor is the size of a small syringe needle and remains inserted in the body for up to a week.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig2_HTML.jpgFigure 1-2
Dexcom continuous glucose monitor with sensor
WHAT ABOUT BLOOD GLUCOSE TESTERS (GLUCOMETERS)?
Until solutions like the Dexcom CGM came about, diabetics had to use a manual tester. Traditional blood glucose testers are single-use events that require the patient to prick their finger or arm and draw a small amount of blood onto a test strip. While this device has been used for many years, it is only recently that manufacturers have started making blood glucose testers with memory features and even connectivity to other devices, such as laptops or phones. The ultimate evolution of these devices is a solution like the Dexcom CGM, which is a medical IoT device that improves the quality of life for diabetics.
Dexcom also provides a free web-based reporting software called Clarity that is accessed from a special uploading application called the Clarity Uploader (see http://dexcom.com/clarity for more details)¹⁰ to allow patients to see the data collected and generate a host of reports they can use to see their glucose levels over time. Reports include averages, patterns, daily trends, and more. They can even share their data with their doctor. Figure 1-3 shows an example of Dexcom Clarity with typical data loaded.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig3_HTML.jpgFigure 1-3
Dexcom Clarity
A feature called Dexcom Share permits the patient to make their data available to others via an app on their phone. That is, the patient’s phone transmits data to the Dexcom cloud servers, which is then sent to anyone who has Dexcom Share iOS app and has been given permission to see the data. Figure 1-4 shows an example of the CGM report from the Dexcom Share iOS app, which allows you to check the blood glucose of a friend easily and quickly or loved one.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig4_HTML.jpgFigure 1-4
Dexcom Share app report
Not only does the app allow the visualization of the data, it can also relay alerts for low or high blood glucose levels, which has profound implications for patients who suffer from additional ailments or complications from diabetes. For example, if the patient’s blood glucose level drops while they are alone, incapacitated, or unable to get treatment, loved ones with the Dexcom Share app can respond by checking on the patient and potentially avoiding a critical diabetic event.
While this solution is a single sensor connected to the Internet via a proprietary application, it is an excellent example of a medical IoT device that can enhance the lives of not only the patient but everyone who cares for them.
Combined with the programmable alerts, you and your loved ones can help manage the effects of diabetes. If you have a loved one who suffers from diabetes, a CGM is worth every penny for peace of mind alone. This is the true power of IoT materialized in a potentially life-saving solution.
Automotive IoT Solutions
Another personal IoT solution is the use of Internet-connected automotive features. One of the oldest products is called OnStar (onstar.com), which is available on most late-model and new General Motors (GM) vehicles. While OnStar predates the IoT evolution, it is a satellite-based service that has several levels and many fee-based options. It incorporates the Internet to permit communication with vehicle owners. Indeed, the newest GM vehicles come with a WiFi access point built into the car! Better still, there are some basic features that are free to GM owners that, in my opinion, are very valuable.
The free, basic features include regular maintenance reports sent to you via email and the ability to use an app on your phone to remotely unlock, lock, and start the car – all the features on your key fob. This is a really cool feature if you have ever locked your keys in your car! Figure 1-5 shows an example of the remote key fob app on iOS. Of course, there are even more features available for a fee, including navigation, telephone, WiFi, and on-call support.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig5_HTML.jpgFigure 1-5
OnStar app key fob feature
The OnStar app works by connecting to the OnStar services in the cloud, requesting the feature (e.g., unlock) that is sent to the vehicle via the OnStar satellite network. So it is an excellent example of how IoT solutions use multiple communication protocols.
The feature I like most is the maintenance reports. You will receive an email with an overview of the maintenance status of your vehicle. The report includes such things as oil life, tire pressure, engine and transmission warnings, emissions, airbag, and more. Figure 1-6 shows an excerpt of a typical email that you receive.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig6_HTML.jpgFigure 1-6
OnStar maintenance report
Notice the information displayed. This is no mere idiot light! Actual data is transmitted to OnStar from your vehicle. For example, the odometer reading and tire pressure data are taken directly from the vehicle’s onboard data storage. That is, data from the sensors is read and interpreted and the report generated for you. This feature demonstrates how automatic compilation of data in an IoT solution can help us keep our vehicles in good mechanical condition with early warning of needed maintenance. This serves us best by helping us keep our vehicles in prime condition and thus in a state of high resell value.
I should note that GM is not the only automotive manufacturer offering such services. Many others are working on their own solutions, ranging from an OnStar-like feature set to solutions that focus on entertainment and connectivity.
Fleet Management
Another example of an IoT solution is a fleet management system .¹¹ While developed and deployed well before the coining of the phrase Internet of Things, fleet management systems allow businesses to monitor their cars, trucks, ships, and just about any mobile unit, to not only track their current location but also to use the location data (GPS coordinates taken over time) to plan more efficient routes, thereby reducing the cost of shipment.
Fleet management systems are not just for routing. Indeed, fleet management systems also allow businesses to monitor each unit to conduct diagnostics. For example, it is possible to know the amount of fuel in each truck; when its last maintenance was performed or, more importantly, when the next maintenance is due; and much more. The combination of vehicle geographic tracking and diagnostics is called telematics. Figure 1-7 shows a drawing of a fleet management system.
../images/501755_1_En_1_Chapter/501755_1_En_1_Fig7_HTML.jpgFigure 1-7
Fleet management example¹²
In Figure 1-7, you see the application of GPSs to track location as well as satellite communication to transmit additional data, such as diagnostics, payload states, and more. All these ultimately traverse the Internet, and the data becomes accessible by the business analysts.
You may think fleet management systems are only for large shipping companies, but with the proliferation of GPS modules and even the microcontroller market, anyone can create a fleet management system. That is, they do not cost millions of dollars to develop.
For example, if you owned a bicycle delivery company, you could easily incorporate GPS modules with either cellular or wireless connectivity on each delivery person to track their location, average travel time, and more. More specifically, you can use such a solution to minimize delivery times by allowing packages to be handed off from one delivery person to another, rather than having them return to the depot each time they complete a set of deliveries.
CAMERA DRONES AND THE IOT
One possible use of the IoT is making data that drones generate available over the Internet. Some people feel that drones are an invasion of privacy. I agree in situations where they are misused or established laws are violated. Fortunately, most drone owners obey local laws, regulations, and property owners’ wishes.¹³
However, there are many legitimate uses of drones, be they land, air, or sea based. For example, I can imagine home monitoring solutions where you can check on your home remotely by viewing data from fixed cameras, as well as data from mobile drones. I for one would love to see a solution that allowed me to program a predetermined sentry flight path to monitor my properties with a flying camera drone.
While some vendors have WiFi-enabled drones, there are not many consumer-grade options available that stream data in real time over the Internet. However, it is just a matter of time before we see solutions that include drones. Of course, the current controversy and the movement of the US government to register and track drones, along with increasing restrictions on their use, may limit the expansion of drones and IoT solutions that include drone-acquired data.
While typically not considered for most home IoT projects, a discussion of IoT solutions would be incomplete without spotlighting security.
IoT and Security
The recent rash of massive data breaches proves that basic security simply is not good enough. We have seen everything from outright theft to exploitation of the data stolen from very well-known businesses, like popular brick-and-mortar retailers, convenience stores, and even some government agencies!
IoT solutions are not immune to security threats. Indeed, as IoT solutions become more and more integrated into our lives, so too will our personal data. Thus, security must be taken extremely seriously and built into the solution from the start.
This includes solutions that we develop ourselves. More specifically, if you design a weather station for your own use, you should take reasonable steps to ensure that the data is protected from both accidental and deliberate exploitation. You may think weather data is not a high risk, but consider the case where you include GPS coordinates for your sensors (a reasonable feature) so that people can see where this weather is being observed. If someone could see that information and determine the solution uses an Internet connection, it is possible they could gain physical access to the Internet device and possibly use it to further penetrate and exploit your systems. Thus, security is not just about the data; it should encompass all aspects of the solution – from data to software, to hardware, and to physical access.
There are four areas where you may want to consider spending extra care ensuring that your IoT solution is protected with good security. As you will see, this includes several things you should consider for your existing infrastructure, computers, and even safe computing habits. By leveraging all these areas, you will be building a layered approach to security, often called a defense-in-depth method .
Security Begins at Home
Before introducing an IoT solution to your home network, you should consider taking precautions to ensure that the machines on your home network are protected. Some of the best practices for securing your home networking include the following:
Use passwords. This may seem like a simple thing, but always make sure that you use passwords on all your computers and devices. Also, adopt good password habits, such as requiring longer strings, mixed case, numbers, and symbols to ensure that the passwords are not easily guessed.¹⁴
Secure your WiFi. If you have a WiFi network, make sure that you add a password and use the latest security protocols, such as WPA2, or, even better, the built-in secure setup features of some wireless routers.
Use a firewall. You should also use a firewall to block all unused ports (TCP or UDP). For example, lock down all ports except those your solution uses, such as port 80 for HTML.
Restrict physical access. Lock your doors! Even if your network has a great password and your computers use espionage quality encrypted biometric access, these things are meaningless if someone can gain access to your networking hardware directly. For IoT solutions, this means any external components should be installed in tamper-proof enclosures or locked away so that they cannot be discovered. This also includes any network wiring.
Secure Your Devices
As I mentioned, your IoT devices also need to be secured. The following are some practices to consider:
Use passwords. Always add passwords to the user accounts you use on your IoT devices. This includes making sure that you rename any default passwords. For example, you may be tempted to consider an IoT device such as an Arduino, Raspberry Pi, or similar too small of a device to be a security concern, but if you consider that the Raspberry runs one of the most powerful operating systems available (forms of Linux), a Raspberry Pi could be a very powerful hacking tool if one were to gain access.
Keep your software up-to-date. You should try to use the latest versions of any software that you use. This includes the operating system as well as any firmware that you may be running. Newer versions often have improved security or fewer security vulnerabilities.
If your software offers security features, use them. If you have servers or services running on your devices and they offer features such as automatic lockout for missed passwords, turn them on. Not all software has these features, but if they are available, they can be a great way to defeat repeated attacks.
Use Encryption
This is one area that is often overlooked. You can further protect yourself and your data if you encrypt the data as it is stored and the communication mechanism as it is transmitted. If you encrypt your data, it cannot be easily deciphered, even if someone were to gain physical access to the storage device. Use the same care with your encryption keys and passcodes as you do your computer passwords.
Security Doesn’t End at the Cloud
There are many considerations for connecting IoT devices to cloud services. Indeed, Microsoft has made it very easy to use cloud services with your IoT solutions. However, there are two important considerations for security and your IoT data:
Do you need the cloud? The first thing you should consider is whether you need to put any of your data in the cloud. It is often the case that cloud services make it very easy to store and view your data, but is it really necessary to do so? For example, you may be eager to view logistical data for where your dog spends his time while you are at work, but who else would really care to view this data? In this case, storing the data in the cloud to make it available to everyone is not necessary.
Do not relax! Many people seem to let their guard down when working with cloud services. For whatever reason, they consider the cloud more secure. The fact is it is not! In fact, you must apply the very same security best practices when working in the cloud that you do for your own network, computers, and security policies. Indeed, if anything, you need to be even more vigilant because cloud services are not in your control with respect to protecting against physical access (however remote and unlikely) nor are you guaranteed your data isn’t on the same devices as tens, hundreds, or even thousands of other users’ data.
Now that you have an idea of how you should include security in your projects, let’s look at how Windows 10 has evolved into a modern platform that not only supports the usual productivity and gaming tasks but also helps us build IoT solutions.
Summary
The Internet of Things is an exciting new world for us all. Those of us young at heart but old enough to remember The Jetsons TV series recall seeing a taste of what is possible in the land of make believe. Self-aware robotic maids with personalities (attitude), talking toasters, flying cars that spring from briefcases, and robotic everything – television fantasy of decades ago is now coming true. We have wristwatches that double as phones and video players. We can unlock our cars from around the world, find out if our dog has gone outside, and even answer the door from across the city. All of this is possible and working today with the advent of the IoT.
In this chapter, we discovered what the IoT is and saw some examples of well-known IoT solutions.
In the next chapter, we will learn about the hardware platform that has become ubiquitous with learning hardware – the Arduino. We will discover more about the Arduino hardware and how to get started programming our first Arduino project as a building block for a simple IoT project.
Footnotes
1
Including my own books!
2
Well, there are IoT kits out there that you can use to build specific, simple projects, but not much in the way of help for those that want to take on new projects without spending a lot of time learning enough about electronics to implement the project.
3
We will discuss advanced uses of the modular components and some simple wiring connections, but nothing that requires prior knowledge of electronics.
4
https://en.wikipedia.org/wiki/Internet_of_Things
5
For example, everything seems to be cloud this, cloud that when in reality nothing was changed.
6
We aren’t so far away from that now. Think about how many iWatches there are out there – yes, they’re IoT devices too!
7
Toasters and toaster ovens have appeared in the top five most dangerous appliances in the home. Scary.
8
However, given the COVID-19 stay-at-home orders in many places, this idea may have come back into practicality.
9
https://pixabay.com/en/network-iot-internet-of-things-782707/
10
Dexcom also provides a mobile version of Clarity for iOS or Android.
11
https://en.wikipedia.org/wiki/Fleet_management
12
Éric Chassaing – via CC BY-SA 3.0 (http://creativecommons.org/licenses/by-sa/3.0/).
13
Drones are increasingly under scrutiny, and the rules change often. If you have a drone and operate in the United States, be sure to check the following website for the latest rules: https://registermyuas.faa.gov/
14
You also need to balance complexity of passwords with your ability to remember them. If you have to write it down, you’ve just defeated your own security!
© Charles Bell 2021
C. BellBeginning IoT Projectshttps://doi.org/10.1007/978-1-4842-7234-3_2
2. Introducing the Arduino
Charles Bell¹
(1)
Warsaw, VA, USA
Since this is a beginner’s book, you are likely just getting started working with hardware and IoT solutions, and you may not have encountered the world that is Arduino and microcontrollers. Arduino boards are small boards with components that support general-purpose input/output (GPIO) pins with a limited processor (called a microcontroller, not a CPU) and memory that permits you to write small programs to control the hardware. In essence, it is a hardware development platform.
There are many such boards and the Arduino is perhaps the most popular with a community that spans the globe providing a vast assortment of sample libraries, code, blogs, books, and documentation. This makes the Arduino one of the most popular choices for hardware development. Some may say it is even more popular than the Raspberry Pi.
In this chapter, you explore the Arduino platform with the goal of using the Arduino to build IoT devices. You see a list of the current Arduino boards along with a short tutorial on the Arduino development environment and explore sample projects to help get you started working with the Arduino.
What Is an Arduino?
The Arduino is an open source hardware prototyping platform supported by an open source software environment. It was first introduced in 2005 and was designed with the goal of making the hardware and software easy to use and available to the widest audience possible. Thus, you do not have to be an electronics expert to use the Arduino. Yay!
The original target audience included artists and hobbyists who needed a microcontroller to make their designs and creations more interesting. However, given its ease of use and versatility, the Arduino has quickly become the choice for a wider audience and a wider variety of projects.
This means you can use the Arduino for all manner of projects from reacting to environmental conditions to controlling complex robotic functions. The Arduino has also made learning electronics easier through practical applications.
Another aspect that has helped the rapid adoption of the Arduino platform is the growing community of contributors to a wealth of information made available through the official Arduino website (http://arduino.cc/en/). When you visit the website, you find an excellent getting started
tutorial as well as a list of helpful project ideas and a full reference guide to the C/C++ language for writing the code to control the Arduino (called a sketch).
Note
Don’t worry. The C++ programming concept (from the view of the main sketch, it resembles C, but includes many C++ concepts and features) is very easy to learn and does not require any training beyond the tutorial in this chapter.
Arduino also provides an integrated development environment called the Arduino IDE. The IDE runs on your computer (called the host), where you can write and compile sketches and then upload them to the Arduino via USB connections. The IDE is available for Linux, Mac, and Windows. It is designed around a text editor especially designed for writing code and a set of limited functions designed to support compilation and loading of sketches.
Sketches are written in a special format consisting of only two required methods – one that executes when the Arduino is reset or powered on and another that executes continuously. Thus, your initialization code goes in setup(), and your code to control the Arduino goes in loop(). The language is C-like (without all of the baggage typical in C compilers), and you may define your own variables and functions. For a complete guide to writing sketches, see http://arduino.cc/en/Tutorial/Sketch.
You can expand the functionality of sketches and provide for reuse by writing libraries that encapsulate certain features such as networking, using memory cards, connecting to databases, doing mathematics, and the like.
The Arduino supports a number of analog and digital pins that you can use to connect to various devices and components and interact with them. The mainstream boards have specific pin layouts, or headers, that allow the use of stackable expansion boards called shields. Shields let you add additional hardware capabilities such as Ethernet, Bluetooth, and XBee support to your Arduino. The physical layout of the Arduino and the shield allow you to stack shields. Thus, you can have an Ethernet shield as well as an XBee shield, because each uses different I/O pins. You learn the use of the pins and shields as you explore the application of Arduino to sensor networks.
The next sections examine the various Arduino boards and briefly describe their capabilities. I list the boards by when they became available, starting with the most recent models. Many more boards and variants are available, and a few new ones are likely to be out by the time this book is printed, but these are the ones that are typically used in beginning projects.
Arduino Hardware
There are a growing number of Arduino boards. Some are configured for special applications, while others are designed with different processors and memory configurations. There are boards that are considered official Arduino boards because they are branded and endorsed by Arduino.cc. Since the Arduino is open source, anyone can build and even sell Arduino-compatible boards (often called an Arduino clone). In this section, you examine some of the more popular Arduino branded boards.
The basic layout of an Arduino board consists of at least one USB connection, a power connector, a reset switch, LEDs for power and serial communication, and a standard spaced set of headers for attaching shields (boards that can be mounted adding hardware capabilities in a modular fashion).
The official boards sport a distinctive blue-colored PCB with white lettering. With the exception of one model, all the official boards can be mounted in a chassis (they have holes in the PCB for mounting screws). The exception is an Arduino designed for mounting on a breadboard.
Uno
The Uno board is the standard Arduino board that most new to the Arduino will choose. It features an ATmega328P processor; 14 digital I/O pins, of which 6 can be used as pulse width modulation (PWM)¹ output; and 6 analog input pins. The Uno board has 32KB of flash memory and 2KB of SRAM.
The Uno is available either as a surface-mount device (SMD) or a standard IC socket. The IC socket version allows you to exchange processors, should you desire to use an external IC programmer to build custom solutions. Details and a full datasheet are available at https://store.arduino.cc/usa/arduino-uno-rev3. It has a standard USB type B connector and supports all shields. Figure 2-1 shows the Arduino Uno board.
../images/501755_1_En_2_Chapter/501755_1_En_2_Fig1_HTML.jpgFigure 2-1
Arduino Uno Rev3 (courtesy of Arduino.cc)
There is also a version of this board that has a built-in WiFi chip making it ideal for IoT projects or situations where using a WiFi shield is problematic (lack of space, conflicts with other shields, etc.). While it is named the same, it differs from the standard Uno in several ways. Aside from the WiFi chip, it has a different processor and one less PWM pin. You can read more about the Uno WiFi board at https://store.arduino.cc/usa/arduino-uno-wifi-rev2. Figure 2-2 shows the Arduino Uno WiFi board.
../images/501755_1_En_2_Chapter/501755_1_En_2_Fig2_HTML.jpgFigure 2-2
Arduino Uno WiFi Rev2 (courtesy of Arduino.cc)
Leonardo
The Leonardo board represents another of the standard boards in the Arduino platform. It is a little different in that, while it supports the standard header layout, it also has a USB controller that allows the board to appear as a USB device (e.g., mouse or keyboard) to the host computer. The board uses a newer ATmega32U4 processor with 20 digital I/O pins, of which 12 can be used as analog pins and 7 can be used as pulse width modulation (PWM) output. It has 32KB of flash memory and 2.5KB of SRAM.
The Leonardo has more digital pins than the Uno, but continues to support most shields. The USB connection uses a smaller USB connector. The board is also available with and without headers. Figure 2-3 depicts an official Leonardo board. Details and a full datasheet can be found at https://store.arduino.cc/usa/leonardo.
../images/501755_1_En_2_Chapter/501755_1_En_2_Fig3_HTML.jpgFigure 2-3
Arduino Leonardo (courtesy of Arduino.cc)
Due
The Arduino Due is a larger, faster board based on the Atmel SAM3X8E ARM Cortex-M3 processor. The processor is a 32-bit processor, and the board supports a massive 54 digital I/O ports, of which 14 can be used for PWM output; 12 analog inputs; and 4 UART chips (serial ports), as well as 2 digital-to-analog (DA) and 2 two-wire interface (TWI) pins. The new processor offers several advantages:
32-bit registers
DMA controller (allows CPU-independent memory tasks)
512KB flash memory
96KB SRAM
84MHz clock
The Due has the larger form factor (called the mega footprint) but still supports the use of standard shields as well as mega format shields. The new board has one distinct limitation: unlike other boards that can accept up to 5V on the I/O pins, the Due is limited to 3.3V on the I/O pins. Details and a full datasheet can be found at https://store.arduino.cc/usa/due.
The Arduino Due is intended to be used for projects that require more processing power, more memory, and more I/O pins.