Book Image

Internet of Things Programming Projects

By : Colin Dow
Book Image

Internet of Things Programming Projects

By: Colin Dow

Overview of this book

The Internet of Things (IOT) has managed to attract the attention of researchers and tech enthusiasts, since it powerfully combines classical networks with instruments and devices. In Internet of Things Programming Projects, we unleash the power of Raspberry Pi and Python to create engaging projects. In the first part of the book, you’ll be introduced to the Raspberry Pi, learn how to set it up, and then jump right into Python programming. Then, you’ll dive into real-world computing by creating a“Hello World” app using flash LEDs. As you make your way through the chapters, you’ll go back to an age when analog needle meters ruled the world of data display. You’ll learn to retrieve weather data from a web service and display it on an analog needle meter, and build a home security system using the Raspberry Pi. The next project has a modern twist, where we employ the Raspberry Pi to send a signal to a web service that will send you a text when someone is at the door. In the final project, you take what you've learned from the previous two projects and create an IoT robot car that you can use to monitor what your pets are up to when you are away. By the end of this book, you will be well versed in almost every possible way to make your IoT projects stand out.
Table of Contents (21 chapters)

A quick overview of the Raspbian OS

The Raspbian desktop is similar to the desktops of other operating systems such as Windows and macOS. Clicking the top-left button drops down the application menu where you may access the various pre-installed programs. We may also shut down the Raspberry Pi from this menu:

The Chromium web browser

The second button from the left loads the Google Chromium web browser for the Raspberry Pi:

The Chromium browser is a lightweight browser that runs remarkably well on the Raspberry Pi:

The home folder

The two-folders button opens up a window showing the home folder:

The home folder is a great place to start when looking for files on your Raspberry Pi. In fact, when you take screenshots using either the scrot command or the Print Screen button, the file is automatically stored in this folder:

The Terminal

The third button from the left opens up the Terminal. The Terminal permits command-line access to Raspberry Pi's files and programs:

It is from the command line where you may update the Raspberry Pi using the sudo apt-get update and sudo apt-get dist-upgrade commands.

apt-get updates the packages list, and apt-get dist-upgrade updates the packages:

It's a good idea to run both of these commands right after installing Raspbian using the sudo command. The default user for Raspbian on the Raspberry Pi is pi, which is part of the Super Users group in Raspbian, and thus must use the sudo command (the default password for the pi user is raspberry):

Mastering the command line is a virtue that many a programmer aspires to acquire. Being able to rapidly type command after command looks so cool that even movie makers have picked up on it (when was the last time you saw the computer wiz in a movie clicking around the screen with a mouse?). To assist you in becoming this uber cool computer wiz, here are some basic Raspbian commands for you to master using the Terminal:

ls: Command to see the contents of the current directory
cd: Command to change directories. For example, use cd to move up a directory from where you currently are
pwd: Command to display the directory you are currently in
sudo: Allows the user to perform a task as the super user
shutdown: Command that allows the user to shut down the computer from the Terminal command line

Mathematica

The third and fourth buttons are for Mathematica, and a terminal to access the Wolfram language, respectively:

Mathematica spans all areas of technical computing and uses the Wolfram language as the programming language. The areas in which Mathematica is used include machine learning, image processing, neural networks and data science:

Mathematica, a proprietary software first released in 1988, can be used free for individuals on the Raspberry Pi through a partnership that was announced in late 2013.

Now let’s take a look at some of the programs that are accessed from the main drop-down menu.

Sonic Pi

Sonic Pi is a live coding environment for creating electronic music. It is accessed from the Programming menu option. Sonic Pi is a creative way to create music as the user programs loops, arpeggios, and soundscapes in real time by cutting and pasting code from one part of the app to another. Synthesizers in Sonic Pi may be configured on a deep level, providing a customized experience for the music coder:

Geared toward an EDM style of music, Sonic Pi may also be used to compose classical and jazz styles of music.

Scratch and Scratch 2.0

Scratch and Scratch 2.0 are visual programming environments designed for teaching programming to children. Using Scratch, the programmer creates their own animations with looping and conditional statements.

Games may be created within the program. The first version of Scratch was released in 2003 by the Lifelong Kindergarten group at the MIT media lab. Scratch 2.0 was released in 2013, and development is currently underway with Scratch 3.0:

Scratch and Scratch 2.0 may be accessed under the Programming menu option.

LibreOffice

LibreOffice is a free and open source office suite that forked over from OpenOffice in 2010. The LibreOffice suite consists of a word processor, a spreadsheet program, a presentation program, a vector graphics editor, a program for creating and editing mathematical formulae, and a database management program. The LibreOffice suite of programs may be accessed through the LibreOffice menu option: