You are previewing Internet of Things with Python.
O'Reilly logo
Internet of Things with Python

Book Description

Interact with the world and rapidly prototype IoT applications using Python

About This Book

  • Rapidly prototype even complex IoT applications with Python and put them to practical use

  • Enhance your IoT skills with the most up-to-date applicability in the field of wearable tech, smart environments, and home automation

  • Interact with hardware, sensors, and actuators and control your DIY IoT projects through Python

  • Who This Book Is For

    The book is ideal for Python developers who want to explore the tools in the Python ecosystem in order to build their own IoT applications and work on IoT-related projects. It is also a very useful resource for developers with experience in other programming languages that want to easily prototype IoT applications with the Intel Galileo Gen 2 board.

    What You Will Learn

  • Prototype and develop IoT solutions from scratch with Python as the programming language

  • Develop IoT projects with Intel Galileo Gen 2 board along with Python

  • Work with the different components included in the boards using Python and the MRAA library

  • Interact with sensors, actuators, and shields

  • Work with UART and local storage

  • Interact with any electronic device that supports the I2C bus

  • Allow mobile devices to interact with the board

  • Work with real-time IoT and cloud services

  • Understand Big Data and IoT analytics

  • In Detail

    Internet of Things (IoT) is revolutionizing the way devices/things interact with each other. And when you have IoT with Python on your side, you'll be able to build interactive objects and design them.

    This book lets you stay at the forefront of cutting-edge research on IoT. We'll open up the possibilities using tools that enable you to interact with the world, such as Intel Galileo Gen 2, sensors, and other hardware. You will learn how to read, write, and convert digital values to generate analog output by programming Pulse Width Modulation (PWM) in Python. You will get familiar with the complex communication system included in the board, so you can interact with any shield, actuator, or sensor.

    Later on, you will not only see how to work with data received from the sensors, but also perform actions by sending them to a specific shield. You'll be able to connect your IoT device to the entire world, by integrating WiFi, Bluetooth, and Internet settings. With everything ready, you will see how to work in real time on your IoT device using the MQTT protocol in python.

    By the end of the book, you will be able to develop IoT prototypes with Python, libraries, and tools.

    Style and approach

    This book takes a tutorial-like approach with mission critical chapters. The initial chapters are introductions that set the premise for useful examples covered in later chapters.

    Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the code file.

    Table of Contents

    1. Internet of Things with Python
      1. Table of Contents
      2. Internet of Things with Python
      3. Credits
      4. About the Author
      5. Acknowledgments
      6. About the Reviewer
      7. www.PacktPub.com
        1. eBooks, discount offers, and more
          1. Why subscribe?
      8. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Downloading the color images of this book
          3. Errata
          4. Piracy
          5. Questions
      9. 1. Understanding and Setting up the Base IoT Hardware
        1. Understanding the Intel Galileo Gen 2 board and its components
        2. Recognizing the Input/Output and the Arduino 1.0 pinout
        3. Recognizing additional expansion and connectivity capabilities
        4. Understanding the buttons and the LEDs
        5. Checking and upgrading the board's firmware
        6. Test your knowledge
        7. Summary
      10. 2. Working with Python on Intel Galileo Gen 2
        1. Setting up the board to work with Python as the programming language
        2. Retrieving the board's assigned IP address
        3. Connecting to the board's operating system
        4. Installing and upgrading the necessary libraries to interact with the board
        5. Installing pip and additional libraries
        6. Invoking the Python interpreter
        7. Test your knowledge
        8. Summary
      11. 3. Interacting with Digital Outputs with Python
        1. Turning on and off an onboard component
        2. Prototyping with breadboards
        3. Working with schematics to wire digital outputs
        4. Counting from 1 to 9 with LEDs, Python code and the mraa library
        5. Taking advantage of object-oriented code to control digital outputs
        6. Improving our object-oriented code to provide new features
        7. Isolating the pin numbers to improve wirings
        8. Controlling digital outputs with the wiring-x86 library
        9. Test your knowledge
        10. Summary
      12. 4. Working with a RESTful API and Pulse Width Modulation
        1. Printing numbers in LEDs with a RESTful API
        2. Composing and sending HTTP requests
        3. Wiring pins with PWM capabilities
        4. Using PWM to generate analog values
        5. Generating analog values via HTTP requests
        6. Preparing the RESTful API for Web application requirements
        7. Using PWM plus a RESTful API to set colors for an RGB LED
        8. Controlling PWM with the wiring-x86 library
        9. Test your knowledge
        10. Summary
      13. 5. Working with Digital Inputs, Polling and Interrupts
        1. Understanding pushbuttons and pullup resistors
        2. Wiring digital input pins with pushbuttons
        3. Reading pushbutton statuses with digital inputs and the mraa library
        4. Reading pushbutton statuses and running a RESTful API
        5. Reading digital inputs with the wiring-x86 library
        6. Using interrupts to detect pressed pushbuttons
        7. Test your knowledge
        8. Summary
      14. 6. Working with Analog Inputs and Local Storage
        1. Understanding the analog inputs
        2. Wiring an analog input pin with a voltage source
        3. Measuring voltage with analog inputs and the mraa library
        4. Wiring a photoresistor to an analog input pin
        5. Determining the darkness level with analog inputs and the mraa library
        6. Firing actions when the environment light changes
        7. Controlling analog inputs with the wiring-x86 library
        8. Logging to files in the local storage
        9. Working with USB attached storage
        10. Test your knowledge
        11. Summary
      15. 7. Retrieving Data from the Real World with Sensors
        1. Understanding sensors and their connection types
        2. Working with accelerometers
        3. Wiring an analog accelerometer to the analog input pins
        4. Measuring three axis acceleration with an analog accelerometer
        5. Wiring a digital accelerometer to the I2C bus
        6. Measuring three axis acceleration with a digital accelerometer
        7. Using the I2C bus to control a digital accelerometer with the mraa library
        8. Wiring an analog temperature sensor
        9. Measuring ambient temperature with an analog sensor
        10. Wiring a digital temperature and humidity sensor to the I2C bus
        11. Measuring temperature and humidity with a digital sensor
        12. Test your knowledge
        13. Summary
      16. 8. Displaying Information and Performing Actions
        1. Understanding LCD displays and their connection types
        2. Wiring an LCD RGB backlight to the I2C bus
        3. Displaying text on an LCD display
        4. Wiring an OLED dot matrix to the I2C bus
        5. Displaying text on an OLED display
        6. Wiring a servo motor
        7. Positioning a shaft to indicate a value with a servo motor
        8. Test your knowledge
        9. Summary
      17. 9. Working with the Cloud
        1. Publishing data to the cloud with dweepy
        2. Building a web-based dashboard with Freeboard
        3. Sending and receiving data in real-time through Internet with PubNub
        4. Publishing messages with commands through the PubNub cloud
        5. Working with bi-directional communications
        6. Publishing messages to the cloud with a Python PubNub client
        7. Using MQTT with Mosquitto and Eclipse Paho
        8. Publishing messages to a Mosquitto broker with a Python client
        9. Test your knowledge
        10. Summary
      18. 10. Analyzing Huge Amounts of Data with Cloud-based IoT Analytics
        1. Understanding the relationship between Internet of Things and Big Data
        2. Understanding the Intel IoT Analytics structure
        3. Setting up devices in Intel IoT Analytics
        4. Setting up components in Intel IoT Analytics
        5. Collecting sensor data with Intel IoT Analytics
        6. Analyzing sensor data with Intel IoT Analytics
        7. Triggering alerts with rules in Intel IoT Analytics
        8. Test your knowledge
        9. Summary
      19. A. Exercise Answers
        1. Chapter 1, Understanding and Setting up the Base IoT Hardware
        2. Chapter 2, Working with Python on Intel Galileo Gen 2
        3. Chapter 3, Interacting with Digital Outputs with Python
        4. Chapter 4, Working with a RESTful API and Pulse Width Modulation
        5. Chapter 5, Working with Digital Inputs, Polling and Interrupts
        6. Chapter 6, Working with Analog Inputs and Local Storage
        7. Chapter 7, Retrieving Data from the Real World with Sensors
        8. Chapter 8, Displaying Information and Performing Actions
        9. Chapter 9, Working with the Cloud
        10. Chapter 10, Analyzing Huge Amounts of Data with Cloud-based IoT Analytics
      20. Index