Raspbian OS Programming With The Raspberry Pi: Iot Projects With Wolfram, Mathematica, and Scratch Black
Raspbian OS Programming With The Raspberry Pi: Iot Projects With Wolfram, Mathematica, and Scratch Black
com
https://textbookfull.com/product/raspbian-os-programming-
with-the-raspberry-pi-iot-projects-with-wolfram-mathematica-
and-scratch-black/
OR CLICK HERE
DOWLOAD EBOOK
https://textbookfull.com/product/biota-grow-2c-gather-2c-cook-loucas/
textbookfull.com
https://textbookfull.com/product/hands-on-start-to-wolfram-
mathematica-and-programming-with-the-wolfram-language-cliff-hastings/
textbookfull.com
https://textbookfull.com/product/raspberry-pi-iot-projects-
prototyping-experiments-for-makers-2nd-edition-john-c-shovic/
textbookfull.com
TECHNOLOGY IN AC TION™
Raspbian OS
Programming with
the Raspberry Pi
IoT Projects with Wolfram,
Mathematica, and Scratch
—
Agus Kurniawan
Raspbian OS
Programming with the
Raspberry Pi
IoT Projects with Wolfram,
Mathematica, and Scratch
Agus Kurniawan
Raspbian OS Programming with the Raspberry Pi: IoT Projects with
Wolfram, Mathematica, and Scratch
Agus Kurniawan
Depok, Indonesia
iii
Table of Contents
iv
Table of Contents
v
Table of Contents
vi
Table of Contents
Index�������������������������������������������������������������������������������������������������177
vii
About the Author
Agus Kurniawan is a lecturer, researcher, IT consultant, and an author. He
has 17 years of experience in various software and hardware development
projects, delivering materials in training and workshops, and technical
writing. He has been awarded the Microsoft Most Valuable Professional
(MVP) award 14 years in a row.
His topic interests are software engineering, embedded system,
networking, and security system. He has been working as lecturer and
researcher at the Faculty of Computer Science, Universitas Indonesia.
Currently, he is pursuing a PhD in computer science at the Freie
Universität Berlin, Germany. He can be reached on his blog at
http://blog.aguskurniawan.net and Twitter at @agusk2010.
ix
About the Technical Reviewer
Massimo Nardone has more than 22 years of experiences in security, web/
mobile development, cloud, and IT architecture. His true IT passions are
security and Android.
He has been programming and teaching how to program with Android,
Perl, PHP, Java, VB, Python, C/C++, and MySQL for more than 20 years.
He holds a Master of Science degree in Computing Science from the
University of Salerno, Italy.
He has worked as a Project Manager, Software Engineer, Research
Engineer, Chief Security Architect, Information Security Manager, PCI/
SCADA Auditor, and Senior Lead IT Security/Cloud/SCADA Architect for
many years.
Technical skills include: Security, Android, Cloud, Java, MySQL,
Drupal, Cobol, Perl, web and mobile development, MongoDB, D3, Joomla,
Couchbase, C/C++, WebGL, Python, Pro Rails, Django CMS, Jekyll,
Scratch, etc.
He currently works as Chief Information Security Office (CISO) for
Cargotec Oyj.
xi
Acknowledgments
We would like to thank Apress for all their help in making this book
possible. Specifically, we would like to thank Aaron Black, our acquisitions
editor, and Jessica Vakili, our coordinating editor, for helping us complete
the Raspbian book.
Special thanks to our development editor, James Markham, and
technical reviewers, Chaim Krause and Massimo Nardone, for all of their
suggestions during the editorial review process that helped make this a
great book.
We would also like to thank the Raspberry Pi and Raspbian
communities anywhere in the world for contributing and making learning
Raspberry Pi with Raspbian easy.
Last but not least, a thank you to my wife, Ela and my children, Thariq
and Zahra, for their great support while I completed this book.
xiii
Introduction
Raspberry Pi is a mini computer that you can operate as a normal
computer. The Raspberry Pi board is one of recommended development
boards with IoT platforms. There are many features on the Raspbian OS
and Raspberry Pi boards that you can use to build IoT programs in various
scenarios. Raspberry Pi is designed to enable you to scale its capabilities
through GPIO pins that are suitable for your business and research needs.
Raspbian OS Programming with the Raspberry Pi is a quick reference
to build programs on top of the Raspbian OS on a Raspberry Pi board.
You’ll start by learning Raspbian shells to develop programs. You will go
through a step-by-step guide with project samples to learn the ins and outs
of the Raspbian OS development. You will also learn about the Wolfram
language, Mathematica, and Scratch.
xv
Introduction
xvi
CHAPTER 1
Introduction
to Raspberry Pi
Raspberry Pi is a development board that can be applied to build IoT
applications. Various sensors and actuator devices can be attached to the
board. In this chapter, we explore Raspberry Pi and cover its models.
We also learn how to set up the board for the first time.
The following list of topics is covered in this chapter:
2
Chapter 1 Introduction to Raspberry Pi
1.2 R
eviewing the Raspberry Pi Board
Models
There are several Raspberry Pi models that we can use to perform specific
purposes. The latest model as I am writing this book is Raspberry Pi 3
Model B+. This board consists of Broadcom BCM2837B0, Cortex-A53
(ARMv8) 64-bit SoC @ 1.4GHz, with 1GB LPDDR2 SDRAM. The board
also provides Ethernet, WiFi, and Bluetooth 4.2 (BLE). You can see the
Raspberry Pi 3 Model B+ board in Figure 1-1. For further information
about Raspberry Pi 3 Model B+, see https://www.raspberrypi.org/
products/raspberry-pi-3-model-b-plus/.
If you have concerns about hardware size, Raspberry Pi Foundation
has an even smaller version, which is half the size of a credit card. It is
called the Raspberry Pi Zero. There are two models—Raspberry Pi Zero and
Raspberry Pi Zero Wireless. The first model was released in November 2015.
The last model that has a WiFi module was released in February 2017. Both
models run Broadcom BCM2835 MCU with 512MB RAM. You can see the
Raspberry Pi Zero Wireless board form in Figure 1-2.
3
Chapter 1 Introduction to Raspberry Pi
You also can see and compare several Raspberry Pi models based on
processor, RAM, and network module availability in Table 1-1.
4
Chapter 1 Introduction to Raspberry Pi
Technically, all the Raspberry Pi models that are shown in Table 1-1
are designed for personal makers and hobbyists. There are limited GPIO
pins on each Raspberry Pi model. If you need more GPIO pins on the
board, you can extend it using GPIO extender modules. The Raspberry Pi
Foundation also released the Raspberry Pi model for industry purposes. It
is called the Raspberry Pi Compute Module. Currently, the latest model is
Raspberry Pi Compute Module V3.
Raspberry Pi Compute Module V3 board hosts 120 GPIO pins, an
HDMI port, a USB port, two camera ports, and two display ports. You
can see the board form in Figure 1-3. For further information about the
Raspberry Pi Compute Module V3, visit the official website at http://
socialcompare.com/en/comparison/raspberrypi-models-comparison.
5
Chapter 1 Introduction to Raspberry Pi
If you have experience using Debian and Ubuntu Linux, you should be
familiar with Raspbian OS since this OS is built based on Debian Linux and
optimized on a Raspberry Pi board with ARMv6 CPU.
This book uses Raspbian OS for testing and evaluation. You can
download the Raspbian image file at https://www.raspberrypi.org/
downloads. Currently, Raspbian provides desktop and lite versions. You
can see the download image in Figure 1-4. The Raspbian desktop version is
running Raspbian OS with an installed desktop runtime. The Raspbian lite
version is designed for light usage. It means you will obtain the Terminal
runtime.
6
Chapter 1 Introduction to Raspberry Pi
1.4 S
etting Up Raspbian OS on Raspberry
Pi Boards
The Raspberry Pi models don’t have internal storage unless you’re using
the Raspberry Pi Compute Module. You should attach external storage,
such as an SD card or a microSD card. The new Raspberry Pi board model
uses microSD for external storage.
I recommended that you use a microSD card that’s 16GB. You can
install some libraries, frameworks, and tools for your personal and
business needs. In this section, I’m going to show you how to set up
Raspbian OS on a Raspberry Pi 3 board.
First, download the Raspbian OS image. You can download it at
https://www.raspberrypi.org/downloads. For demo purposes, I chose
the Raspbian Stretch with desktop, as shown in Figure 1-4. To flash the
Raspbian image into the microSD card, you can use Etcher. It’s free and
available for Windows, Mac, and Linux. You can see the Etcher application
in Figure 1-5. Download it from https://etcher.io, based on your
platform, and then install it.
7
Chapter 1 Introduction to Raspberry Pi
The Etcher application is easy to use. You can just select your Raspbian
image and target the drive of the microSD card on your computer. Some
computers don’t have microSD card readers, so you need an SDcard
reader. Then put your microSD card into the reader.
After completing the flashing Raspbian step, you can plug your
keyboard, mouse, and monitor into the Raspberry Pi board.
Details about Raspbian installation on the Raspberry Pi board can be
found in the official guideline manual at https://www.raspberrypi.org/
documentation/installation/installing-images/README.md.
8
Chapter 1 Introduction to Raspberry Pi
Wait several minutes to ensure Raspbian has started. You should get
your Raspbian IP address from your router. Now open the SSH
client application. For Windows, you can use the PuTTY application at
https://www.putty.org. For Linux and Mac, you can use the Terminal.
For instance, the Raspbian IP address is 192.168.1.21 and the username is
pi. Then type this command.
$ ssh [email protected]
9
Chapter 1 Introduction to Raspberry Pi
You should be able to access the Raspbian Terminal remotely. You can
see an example of remote SSH in Figure 1-7.
$ sudo raspi-config
10
Chapter 1 Introduction to Raspberry Pi
From the main menu (see Figure 1-8), you can select the Advanced
Options menu. Then, you should see the form that is shown in Figure 1-9.
Select the Expand Filesystem option. After that, you will obtain
confirmation. If you’re done, Raspbian will expand your disk.
11
Chapter 1 Introduction to Raspberry Pi
12
Chapter 1 Introduction to Raspberry Pi
After you select one of the WiFi SSIDs, you probably will be asked for
the SSID pin. Fill in the SSID pin and then your Raspbian will connect to
the network.
13
Chapter 1 Introduction to Raspberry Pi
14
Chapter 1 Introduction to Raspberry Pi
If you click on the Raspberry Pi logo on the top-left, you should see a
main menu, as shown in Figure 1-12. You can see a list of applications and
the managing systems.
For instance, open a browser from the Internet menu. You can surf the
Internet as you do in a normal browser. Raspbian installed Chromium as
its default browser application. You can see this browser in Figure 1-13.
15
Chapter 1 Introduction to Raspberry Pi
16
Exploring the Variety of Random
Documents with Different Content
Vppe, adj. up, risen, 149/8.
Ware, v. to spend, 123/23. See Gloss. B. 15 (E. D. S.), p. 72; Gloss. B. 2, p. 42.
Warke, s. work, 6/9, 21/26; warkes, pl. prol. 22, 143/11.
Warrybredes, s. pl. worms just under the skin, 63/1. “Wary-breeds, or Warnel-
worms, worms on the backs of cattle within their skin;” Bailey’s Dict. vol. i. ed.
1735. Cf. “Warbot, a worme, escarbot;” Palsgrave.
Whyted, pp. (= thwited), cut, whittled down into shape, 5/25. Cf. whittle =
thwittle, a knife; from thwite, to cut.
Wolde, pt. s. and pl. ought to (lit. would), 3/31; should, ought, 15/35; must,
15/45; should, 21/20, 122/36, 140/6.
Wonders, adv. wondrously, prol. 24. (This afterwards became an adj., and was
turned into the Mod. E. wondrous.) See below.
Wrapped, pp. (probably) warped, drawn out into a warp, 146/43. Spelt warped in
ed. 1598.
Wrethynge-temes, s. pl. part of the harness for oxen, 5/4. To wrethe is to twist; a
team is ‘an ox-chain, passing from yoke to yoke;’ E. D. S. Gloss. B. 2, p. 40.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside
the United States, check the laws of your country in addition to
the terms of this agreement before downloading, copying,
displaying, performing, distributing or creating derivative works
based on this work or any other Project Gutenberg™ work. The
Foundation makes no representations concerning the copyright
status of any work in any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if
you provide access to or distribute copies of a Project
Gutenberg™ work in a format other than “Plain Vanilla ASCII” or
other format used in the official version posted on the official
Project Gutenberg™ website (www.gutenberg.org), you must,
at no additional cost, fee or expense to the user, provide a copy,
a means of exporting a copy, or a means of obtaining a copy
upon request, of the work in its original “Plain Vanilla ASCII” or
other form. Any alternate format must include the full Project
Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
textbookfull.com