Table of contents : Table of Contents About the Author About the Technical Reviewer Part I: Getting Started with IoT Chapter 1: Introduction to the Internet of Things What Is the Internet of Things? The Internet of Things and You IoT Is More Than Just Connected to the Internet IoT Services A Brief Look at IoT Solutions Sensor Networks Medical Applications Automotive IoT Solutions Fleet Management IoT and Security Security Begins at Home Secure Your Devices Use Encryption Security Doesn’t End at the Cloud Summary Chapter 2: Introducing the Arduino What Is an Arduino? Arduino Hardware Uno Leonardo Due Micro Nano MKR Series Boards Arduino Clones Arduino Pro Mini Fio Seeeduino Metro from Adafruit Espressif Boards Internet Shields So Which Do I Buy? Where to Buy Online Retailers Retail Stores (USA) Arduino Tutorial Learning Resources The Arduino IDE Modifying the Arduino IDE Customize the Environment Manage the Hardware Libraries Manage the Software Libraries Example Sketch: Blink Example Sketch: Scan Networks Using the Uno WiFi Rev2 Using the MKR1000 Summary Chapter 3: Arduino Programming Getting Started Working with Sketches in the Arduino IDE Basic Sketch Layout setup() loop() Arduino Language Basics The Basics Comments Including Libraries Curly Braces Functions Variables and Types Arithmetic Flow Control Statements Conditionals Loops Basic Data Structures Pointers Practical Example TemperatureConverter.ino SerialMonitorReader.h SerialMonitorReader.cpp Compiling Your Sketches Warnings Errors Example Sketches Writing Your First Sketch Keep It Simple Debugging and Testing Debugging Testing Getting Help Isolate and Reproduce Research Potential Solutions Ask the Right Question Summary Chapter 4: Introducing the Raspberry Pi What Is a Raspberry Pi? Raspberry Pi Origins Raspberry Pi Boards A Tour of the Board Required Accessories Recommended Accessories Where to Buy Setting Up the Raspberry Pi Choosing a Boot Image (Operating System) Creating the Boot Image Booting the Board Care and Feeding of the SD Card Getting Started with Raspberry Pi OS Getting Help File and Directory Commands List Directories and Files Change Directory Copy Move Create Directories Delete Directories Create (Empty) Files Delete Files System Commands Show (Print) Working Directory Command History Archive Files Administrative Commands Run as Super User Change File/Directory Permissions Change Owner Install/Remove Software Shutdown Useful Utilities Summary Chapter 5: Python Programming for the Raspberry Pi Getting Started Python Primer The Basics Variables Including Modules Comments Arithmetic Flow Control Statements Conditionals Loops Functions Basic Data Structures Lists Tuples Dictionaries Classes and Objects Example Scripts Example 1: Using Loops Write the Code Execute the Code Example 2: Using Complex Data and Files Write the Code Execute the Code Example 3: Temperature Conversion Write the Code Execute the Code Example 4: Using Classes Write the Code Execute the Code Summary Part II: The Qwiic and STEMMA QT Component Systems Chapter 6: Introducing Qwiic and STEMMA QT Overview What Is I2C? The Qwiic Component System Capabilities How Does It Work? Limitations The STEMMA QT Component System Capabilities How Does It Work? Limitations Components Available The Qwiic Component System Development Boards Host Adapters Modules Cabling and Connectors The STEMMA QT Component System Controllers Modules Cabling and Connectors Where to Buy Qwiic and STEMMA QT Components Using the Components in Your Projects Loading Qwiic and STEMMA QT Libraries for the Arduino Loading Qwiic and STEMMA QT Libraries for the Raspberry Pi Integrating Additional Components Assembling the Hardware Adapting Software Libraries Summary Chapter 7: Keep Your Distance! Project Overview What Will We Learn? Hardware Required About the Hardware Sensor A Note About I2C Addresses Arduino Board Assemble the Qwiic Modules Connecting to the Arduino Using a Shield Using a Special Cable Mounting Modules Detecting I2C Devices on the Arduino Connecting to the Raspberry Pi Using a Hat Using a Special Cable Detecting I2C Devices on the Raspberry Pi Write the Code Arduino Install Software Libraries Write the Sketch Compile the Sketch Raspberry Pi Install Software Libraries Write the Code Execute the Project Sketch on the Arduino Execute the Sketch Something Isn’t Working… Now What? Python Code on the Raspberry Pi Execute the Python Code Something Isn’t Working… Now What? Going Further Mounting the Project in a Case Alternative Project Ideas Summary Chapter 8: How’s the Weather? Project Overview What Will We Learn? Hardware Required About the Hardware Sensor OLED Assemble the Qwiic Modules Researching the Hardware Read the Documentation! Install the Software Libraries Explore the Sample Code Write Your Own Code Write the Code Arduino Install Software Libraries Write the Sketch Compile the Sketch Raspberry Pi Locating Alternative Software Libraries Install Software Libraries Write the Code Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 9: Digital Gardener Project Overview What Will We Learn? Hardware Required About the Hardware Qwiic Soil Moisture Sensor Qwiic I2C Mux Soil Moisture Sensor (with Screw Terminals) Qwiic 12 Bit ADC LCD Assemble the Qwiic Modules Calibrating the Sensors Write the Code Arduino Install Software Libraries Write the Sketch Class Header File Main Sketch Class Code File Compile the Sketch Raspberry Pi Install Software Libraries Write the Code Soil Moisture Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 10: Balancing Act Project Overview What Will We Learn? Hardware Required About the Hardware Sensor OLED Assemble the Qwiic Modules Using an Enclosure Calibrating the Sensor Write the Code Arduino Install Software Libraries Write the Sketch Class Header File Main Sketch Class Code File Compile the Sketch Raspberry Pi Install a Software Library Write the Code Bubble Level Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 11: Digital Compass Project Overview What Will We Learn? What Is a Magnetometer? Mathematical Problems Calculating a Heading Intentional Error Compass Calculations Limitations Hardware Required About the Hardware Sensor OLED Assemble the Qwiic Modules Using an Enclosure Calibrating the Sensor Write the Code Arduino Install Software Libraries Write the Sketch Class Header File Main Sketch Class Code File Compile the Sketch Raspberry Pi Install a Software Library Write the Code Compass Face Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Part III: The Grove Component System Chapter 12: Introducing Grove Overview The Grove Component System Capabilities How Does It Work? I2C Digital Analog UART Limitations Components Available Host Adapters Modules Cabling and Connectors Developer Kits Where to Buy Grove Components Using the Components in your Projects Loading Grove Libraries for the Arduino Loading Grove Libraries for the Raspberry Pi Summary Chapter 13: Example: Knock-Knock! Project Overview What Will We Learn? Hardware Required About the Hardware Sound Sensor Grove LED Grove Button Grove Base Shield V2.0 for the Arduino GrovePi+ for the Raspberry Pi Connect the Grove Modules Write the Code Arduino Write the Sketch Class Header File Main Sketch Class Code File Compile the Sketch Raspberry Pi Install Software Libraries Configure the Raspberry Pi 4 or 400 GrovePi/GrovePi+ Troubleshooting Tips Write the Code Secret Knock Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 14: Mood Lighting Project Overview What Will We Learn? Hardware Required About the Hardware Grove Light Sensor Grove Chainable RGB LED Grove LCD RGB Backlight Grove Qwiic Hub Qwiic TMP102 Connect the Grove Modules Write the Code Arduino Install Software Libraries Write the Sketch Class Header File: Moods Class Header File: MoodLamp Main Sketch Class Code File: Moods Class Code File: MoodLamp Compile the Sketch Raspberry Pi Install a Software Library Write the Code Moods Class MoodLamp Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 15: Monitoring Your Environment Project Overview What Will We Learn? Hardware Required About the Hardware Grove OLED 0.96 Grove Buzzer Grove I2C High Accuracy Temperature Sensor (MCP9808) Grove Temperature and Barometer Sensor (BMP280) Grove Air Quality Sensor Grove Dust Sensor Connect the Grove Modules Using an Enclosure Write the Code Arduino Install Software Libraries Write the Sketch Class Header File Main Sketch Class Code File Compile the Sketch Raspberry Pi Install Software Libraries Write the Code AirMonitor Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Chapter 16: Simon Says Project Overview What Will We Learn? Hardware Required About the Hardware Grove Dual Button Grove Buzzer Qwiic LED Buttons Connect the Grove Modules Connections for Arduino Connections for Raspberry Pi Using an Enclosure Write the Code Arduino Install Software Libraries Write the Sketch Class Header File: Buzzer Class Header File: Simon Main Sketch Class Code File: Buzzer Class Code File: Simon Compile the Sketch Raspberry Pi Install a Software Library Write the Code Buzzer Class Simon Class Main Script (Python) Execute the Project Sketch on the Arduino Execute the Sketch Python Code on the Raspberry Pi Execute the Python Code Going Further Summary Part IV: Going Further: IoT and the Cloud Chapter 17: Introducing IoT for the Cloud Overview What Is the Cloud? What Is Cloud Computing Then? How Does the Cloud Help IoT? IoT Cloud Systems IoT Cloud Services Available Data Storage Data Transformation (Queries) Visualization Tools Routing and Messaging Cloud Services Example: IFTTT Getting Started Networking: Connecting Your Board to the Internet Arduino Raspberry Pi Basic Operation Using IFTTT Example Projects Example 1: Secret Knock Alert IFTTT Setup Arduino Python Example 2: Weather Alert IFTTT Setup Arduino Python Summary Chapter 18: Using ThingSpeak Getting Started Create an Account in ThingSpeak Create a Channel How to Add ThingSpeak to Your Projects Using ThingSpeak with the Arduino Configuring the Arduino IDE Write the Sketch Testing the Sketch Using ThingSpeak with the Raspberry Pi Configuring the Raspberry Pi Write the Code Testing the Script Example IoT Projects Example 1: IoT Weather Station Create the ThingSpeak Channel Prepare the Project Files Update the Project Code Arduino Raspberry Pi Execute and Visualize the Data Example 2: IoT Digital Gardener Create the ThingSpeak Channel Prepare the Project Files Update the Project Code Arduino Raspberry Pi Execute and Visualize the Data Example 3: IoT Environment Monitor Create the ThingSpeak Channel Prepare the Project Files Update the Project Code Arduino Raspberry Pi Execute and Visualize the Data Summary Appendix General Hardware List Consolidated Hardware Lists Qwiic Component System Grove Component System Index