Task 3: Controlling the Buggy through a Device
For the device, you can use a common Android smartphone due to their good availability and
compatibility. To begin you need to download the VNC viewer. Then, by using a computer you
will be able to write the command on sudo “hostname -I”. It will generate an IP address that you
can insert on your phone. Now everything is much simpler and mobile as now you are able to
control the buggy from your phone.
Task 4: Adding Extra Sensors and Peripherals
Till now we have given mobility and control over the robot buggy. Now we can add more sen-
sors and devices to our robot buggy to make it more productive. We can add a camera and
microphone on the buggy to use it as a surveillance bot. By attaching an LCD display we can
display a message on the robot buggy, this could be really helpful to greet guests in an event. If
we install temperature, humidity, air pressure sensor the robot buggy then we can also use it
to forecast the weather. The use of motion sensor could greatly help the bot to detect obstacles
and motion in its path.
Project Idea
Detecting Santa
Do you wish to catch Santa on spot? Well, we have devised a solution with Pi that takes help
from an infrared sensor which sets o the alarm as soon as Santa sneakily enters your room!
This case study can prove to be useful for educational purposes, especially if you wish to get
familiar with the usage of sensors with Pi.
Requirements
On the software side, you require the latest Raspbian having support for Scratch 2 (GPIO sup-
port is a must). In case your version of Raspbian is an older one, you can just open the terminal
and go ahead with the following commands for the installation of Scratch 2.
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install scratch 2
For hardware, you need a Raspberry Pi 3 (2 would suce too). The sensor in our project is
a PIR (passive infrared) motion sensor. To get the required sounds, you would require a speaker.
Moreover, 3 separate female-to-female jumper leads are essential. Lastly, you must know how
to carry a small screw driver for all the hand-work.
Sensors
We have used a PIR motion sensor because it can instantly detect the moving of a warm body
(human animals). These sensors are often used by security companies for alarm systems to
thwart burglaries and robberies.
So how does this sensor work? It senses temperature: when it detects a temperature com-
ing from an organism or object to be exceeding absolute zero, it instantly generates radiation
(infrared in nature). This wavelength is not visible for the naked eye but electronic components
of the PIR sensor are quick to identify them.
Before using a PIN sensor, it is important to tune it accordingly. In our example, we have
turned potentiometers in anti-clockwise direction.
340 Internet of Things
Internet_of_Things_CH13_pp327-348.indd 340 9/3/2019 10:17:04 AM
To connect the PIR sensor with your Pi, make use of the female-to-female jumper cables
and establish a connection with all the sensor pins to their respective suitable Pi pins. The 5V
pin from the Pi must be connected to the VCC pin on the sensor. The ground pin from the Pi
must be connected to the “GND” pin on the sensor. We have established a connection between
the Pi and the sensor in such a way that the GPIO 4 pin is connected with the OUT pin.
Checking the Sensor
Before proceeding, you have to make sure that your Pi can take reliably take input from the PIR
sensor. Open Scratch 2 on Pi and then customize it to enable the Pi GPIO extension. To confirm
if your sensor is detecting motion, you have to first identify if your GPIO pin is low or high. If
you find it high, then this means that it detected motion.
Task
Write a script in Scratch in which you have sprite confirming the motion by saying True or False.
Sprite
In Scratch, we have a cat sprite. Remove it by right-click Delete. Now you have to generate
and build your own sprite resembling a Santa!
Task
Use the Scratch interface to create your sprite.
Algorithm
To get our program to work, we need an algorithm which can infuse the required functionality
in our Pi.
1. Wait for the flag to be clicked.
2. Use a forever loop to use an if-else statement.
3. Use if-else statement when GPIO 4 has a “high” value.
a. If (high).
b. Sprite appears and fills the screen according to its size.
c. Produces noise.
d. Starts to wait till the sound ends.
e. Applies a reduction in the size of the sprite.
6. 5- In case the condition fails, the sprite must be hidden.
Task
Implement this algorithm in Scratch. (Hint: to add sounds, go to the Sounds tab)
Placement
With the implementation of the algorithm, you just need to place your Raspberry Pi in your
room. Make sure that the sensor points toward the door and link Pi with a speaker. Whoever
would now attempt to come from that door could be detected right at the moment!
Adding Further Functionality
Now that you have your own Santa Detector, you must try adding more features into your device.
Change the sprite from Santa to a thief’s.
Add a lightning component which signals a beam of light when the alarm is triggered.
Use a screen to display a message (like “YOU GOT CAUGHT!”) when the sensor detects
motion.
Chapter 13 Hands-On Examples of IoT Experiments 341
Internet_of_Things_CH13_pp327-348.indd 341 9/3/2019 10:17:04 AM
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.21.76.0