Book Image

Internet of Things with Python

By : Gaston C. Hillar
Book Image

Internet of Things with Python

By: Gaston C. Hillar

Overview of this book

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.
Table of Contents (19 chapters)
Internet of Things with Python
Credits
About the Author
Acknowledgments
About the Reviewer
www.PacktPub.com
Preface
Index

Understanding the Intel Galileo Gen 2 board and its components


We want to bring our ideas to life, easily. We want to be able to display a happy birthday message on a screen when we clap our hands. We want to collect huge amounts of data from the real world. We want to create wearables that keep track of all our activities during an entire day. We want to use the data to perform actions and interact with real-world elements. We want to use our mobile devices to control robots. We want to be able to determine whether the weather is hot or cold based on the data retrieved from a temperature sensor. We want to make decisions based on the values collected from a humidity sensor.

We want to measure how much of our favorite beverage is there in the cup and display the information on an LCD dot matrix display. We want to analyze all the data collected by things that are connected to the Internet. We want to become makers in the Internet of Things era by leveraging our existing Python programming skills.

We will use Python as the main programming language to control the different components connected to an Intel Galileo Gen 2 board, specifically Python 2.7.3. However, before we can become makers, it is necessary to understand some of this board's features.

After we unbox an Intel Galileo Gen 2, we will find the following elements:

  • The Intel Galileo Gen 2 board

  • A 12 VDC (Volts direct current), 1.5 A (Amperes) power supply

The following image shows the front view for an unboxed Intel Galileo Gen 2 board:

Let's have a look at the front view of the board for a few minutes. We will notice many familiar elements, such as an Ethernet jack, host USB port, and many labeled pins. In case we have previous experience with an Arduino UNO R3 board, we will easily realize that many elements are in the same locations as in that board. In case we have previous experience with embedded systems and electronics, we will easily realize that the board provides the necessary pins (SCL and SDA) to talk with the devices that support the I2C bus. In case we don't have any previous experience, we will learn what we can do with all these pins in the examples included in the forthcoming chapters.

The next image shows the graphical representation of the Intel Galileo Gen 2 board in the Fritzing open source and free software. As you might notice, the graphical representation includes only the important pieces of the board and all the things we can wire and connect, with the necessary labels to help recognize them easily. We will use the Fritzing diagrams to illustrate all the wirings that we must do in order to complete each sample project through the book.

Tip

You can download the latest version of Fritzing from http://fritzing.org/download/. Fritzing runs on Windows, Mac OS X and Linux. You will find the Fritzing sketches for all the examples included throughout the book in files with an FZZ extension (*.fzz) as a part of the code files that you can download for this book. The files are saved with Fritzing 0.92. Thus, you can open the sketches in Fritzing, check the breadboard view, and make any changes to it based on your needs.

The next image shows the electronic schematic representation of the Intel Galileo Gen 2 board, that is, the symbolic representation of the board to make it easy to understand the interconnections of the electronic circuits related to the board. The electronic schematic is also known as circuit diagram or electrical diagram. The symbol includes all the pins provided by the board shown as connectors. We can easily recognize the many labels that appear on the board as labels for each connector in the symbol. Fritzing allows us to work with both the breadboard and the electronic schematic representation.

Tip

When you open the Fritzing file for each sample included in the book, you will be able to easily switch from the breadboard view to the schematic view by clicking on either the Breadboard or the Schematic buttons located at the top of the main Fritzing window.

The next image shows the system block diagram for the Intel Galileo Gen 2 board. The diagram is a part of the content included in the Intel Galileo Gen 2 design document: http://www.intel.com/content/dam/www/public/us/en/documents/guides/galileo-g2-schematic.pdf.

The Intel Galileo Gen 2 board is an Arduino certified embedded computer that we will use to develop and prototype our IoT projects. The board is based on Intel architecture and uses an Intel Quark SoC X1000 system on a chip, known as SoC or application processor. The SoC is a single-core and single-threaded application processor that is compatible with the Intel Pentium 32-bit instruction set architecture (ISA). Its operating speed is up to 400 MHz. The following image shows the SoC, located approximately at the center of the board. The following page provides detailed information about the Intel Quark SoC X1000: http://ark.intel.com/products/79084/Intel-Quark-SoC-X1000-16K-Cache-400-MHz

On the right-hand side of the CPU, the board has two integrated circuits that provide 256 MB of DDR3 RAM (short for Random Access Memory) memory. The operating system and Python will be able to work with this RAM memory. As it happens in any computer, RAM memory loses its information after we turn off the board. Thus, we say that RAM is volatile, as the data stored in it is lost when the memory isn't powered. The following image shows the DDR3 memory chips.

In addition, the board provides access to the following onboard memories:

  • 512 KB embedded SRAM (short for Static Random Access Memory).

  • 8 MB Legacy SPI NOR Flash, non-volatile memory. Its goal is to store the board's firmware and sketches.

  • 11 KB EEPROM (short for Electrically Erasable Programmable Read-Only Memory). It is non-volatile and we can store data in it for our own purposes.