CS801 Iot Lab Manual
CS801 Iot Lab Manual
Department of
Computer Science & Engineering
Sem-VIII
Submitted By
Students Name : _____________
Students Roll No. : _ _ _ _ _ _ _ _ _ _ _ _ _
Submitted To
Faculty Incharge
Prof. Kamaljeet Singh Kalsi
Session : 2021-22
1
Index
Page Sign
S. No List of Experiments
No.
1 Familiarisation with Arduino, Node MCU & Raspberry Pi
2 IoT Sensor Types.
3 Connect & Monitor IoT devices in Cisco Packet Tracer.
4 Adding IoT devices to a Smart Home in Cisco Packet
Tracer.
5 Familiarisation with Node Red and perform necessary
software installation on Raspbian OS.
6 Home Automation with Node-RED and Raspberry Pi:
Control Lights & Read DHT11 Data.
7 Surveillance camera system with Node-Red using
Raspberry Pi.
8 Car Plate recognition system with Node-Red using
Raspberry Pi.
Smart irrigation system with sms & email alert,
9 visualize data on cloud with with Node-Red using
Raspberry Pi.
10 Smart Mirror with Node-Red using Raspberry Pi.
2
Experiment 1
Arduino :
Arduino is an 8-bit microcontroller development board with a USB programming interface to connect
to a computer and additional connection sockets to external electronics like sensors, motors speakers,
diodes etc.
It has got both input and output pins, the input pins can be either be digital (0 – 13) or analogue (A0 –
A5), while the output pins are only digital (0 – 13) .
Arduino board design is open source and it also has an open source integrated development
environment which has a cross-compiler, a debugger and a serial monitor to control the inputs and
outputs.
Arduino can either be powered through the USB connection from the computer, from a 9V battery, or
from a power supply .
3
Raspberry Pi :
It can work and be connected like any computer to a mouse, keyboard, and screen perform computing
functions.
Raspberry Pi B+ board has 32-bit processor, four USB ports, HDMI port, Ethernet port, Audio port,
CSI camera connector, and micro SD card slot.
It also has 40 general-purpose input/output. Raspberry Pi comes in different models, Model 2 lacks an
embedded Wi-Fi but a Wi-Fi adapter can be used via the USB port to get internet connectivity.
New models of Raspberry Pi 3 have integrated Wi-Fi module in its board making it easier to configure
internet connectivity.
4
Node MCU (ESP8266) :
ESP8266 - Node MCU This is an open source development board with a firmware that runs on
ESP8266 module.
The ESP8266 WiFi board is a SOC with integrated TCP/IP protocol stack that can give any secondary
microcontroller access to a WiFi network
. The ESP8266 board is capable of either hosting an application or offloading all Wi-Fi networking
functions from another application processor and therefore this is more suitable to be used as a sensing
5
node that is capable to sense the data from various wirelessly connected IoT sensor nodes and send
data to the central server like.
6
Experiment 2
Broadly speaking, sensors are devices that detect and respond to changes in an
environment. Inputs can come from a variety of sources such as light, temperature, motion
and pressure. Sensors output valuable information and if they are connected to a network,
they can share data with other connected devices and management systems.
1. Temperature Sensors
Temperature sensors measure the amount of heat energy in a source, allowing them to detect
temperature changes and convert these changes to data. Machinery used
in manufacturing often requires environmental and device temperatures to be at specific
levels. Similarly, within agriculture, soil temperature is a key factor for crop growth.
2. Humidity Sensors
These types of sensors measure the amount of water vapor in the atmosphere of air or other
gases. Humidity sensors are commonly found in heating, vents and air conditioning (HVAC)
systems in both industrial and residential domains. They can be found in many other areas
including hospitals, and meteorology stations to report and predict weather.
7
3. Pressure Sensors
A pressure sensor senses changes in gases and liquids. When the pressure changes, the
sensor detects these changes, and communicates them to connected systems. Common use
cases include leak testing which can be a result of decay. Pressure sensors are also useful in
the manufacturing of water systems as it is easy to detect fluctuations or drops in pressure.
4. Proximity Sensors
Proximity sensors are used for non-contact detection of objects near the sensor. These types
of sensors often emit electromagnetic fields or beams of radiation such as infrared.
Proximity sensors have some interesting use cases. In retail, a proximity sensor can detect
the motion between a customer and a product in which he or she is interested. The user can
be notified of any discounts or special offers of products located near the sensor. Proximity
sensors are also used in the parking lots of malls, stadiums and airports to indicate parking
availability. They can also be used on the assembly lines of chemical, food and many other
types of industries.
5. Level Sensors
Level sensors are used to detect the level of substances including liquids, powders and
granular materials. Many industries including oil manufacturing, water treatment and
beverage and food manufacturing factories use level sensors. Waste management systems
provide a common use case as level sensors can detect the level of waste in a garbage can or
dumpster.
8
6. Accelerometers
Accelerometers detect an object’s acceleration i.e. the rate of change of the object’s velocity
with respect to time. Accelerometers can also detect changes to gravity. Use cases for
accelerometers include smart pedometers and monitoring driving fleets. They can also be
used as anti-theft protection alerting the system if an object that should be stationary is
moved.
7. Gyroscope
Gyroscope sensors measure the angular rate or velocity, often defined as a measurement of
speed and rotation around an axis. Use cases include automotive, such as car navigation and
electronic stability control (anti-skid) systems. Additional use cases include motion sensing
for video games, and camera-shake detection systems.
8. Gas Sensors
These types of sensors monitor and detect changes in air quality, including the presence of
toxic, combustible or hazardous gasses. Industries using gas sensors include mining, oil and
gas, chemical research andmanufacturing. A common consumer use case is the familiar
carbon dioxide detectors used in many homes.
9. Infrared Sensors
Optical sensors convert rays of light into electrical signals. There are many applications and
use cases for optical sensors. In the auto industry, vehicles use optical sensors to recognize
signs, obstacles, and other things that a driver would notice when driving or parking.
Optical sensors play a big role in the development of driverless cars. Optical sensors are
very common in smart phones. For example, ambient light sensors can extend battery life.
Optical sensors are also used in the biomedical field including breath analysis and heart-rate
monitors.
9
Experiment 3
Objectives
Part 1: Add Home Gateway to the Network
Part 2: Connect IoT Devices to the Wireless Network
Part 3: Add End User Device to the Network
Background / Scenario
In this activity you will add a Home Gateway and several IoTdevices to an existing home network and
monitor those devices through the Home Gateway.
10
Click the Copper Straight-Through connector icon in the Device-Type Selection box, then
click the Home Gateway to add one end of the cable to the gateway. Next, click the Cable
Modem icon to connect the other end of the cable to the Internet port.
After a few seconds both ends of the cable should have green lights indicating that the link is
up.
11
Step 2: Add devices to the home wireless network
b. Add a wireless adapter to the Fan device.
Click the Faniconin the workspace to open the Config tab and then click the Advanced
button in the bottom right corner of the window. Notice that the tabs at the top of the
configuration window change. There are now more tabs.
Click the I/O Config tab and change the Network Adapter type to the PT-IOT-NM-1W
wireless adapter.
e. Connect the Door and the Lamp to the wireless network following the same steps used for
the fan.
13
c. Access the home gateway IoT server from the tablet.
Click the Desktop tab and then click the Web Browser icon to open a Web browser.
Type192.168.25.1 (the address of the home gateway) in the URL box and click Go.
At the Home Gateway Login page, enter admin as the username and admin as the
password and click the Submit button to connect to the Home Gateway server.
Note that no devices appear in the Home Gateway IoT Server - Devices list.
14
Step 3: Configure IoT devices to register with the Home Gateway server
d. Register the ceiling fan to the home gateway server.
Click the Fan icon in the workspace, click the Config tab, and then click Settings in the left
pane. At the IoT Server options list, click the Home Gateway button.
e. Verify that the devices are now registered with the Home Gateway server.
Click the Tablet icon in the workspace and open the Web Browser. Connect to the Home
Gateway by typing 192.168.25.1 in the URL box and then click Go. Enter admin as the
username and password and click Submit.
After a few seconds all three devices should be listed in the Home GatewayIoT Server -
Devices list.
15
Experiment : 4
Objectives
Part 1: Explore the Existing Smart Home Network
Part 2: Add Wired IoT Devices to the Smart Home Network
Part 3: Add Wireless IoT Devices to the Smart Home Network
Background / Scenario
In this activity you will open a Packet Tracer file with an existing home network, explore the devices
on the network and then add additional wired and wireless IoT devices.
16
Across the bottom of the Packet Tracer window, the Device-Specific Selection box displays the
many different Smart Home IoT devices available.
Move the mouse pointer over each device and notice that the descriptive name of the device is
displayed at the bottom of the Device-Specific Selection box. Take a moment to look at each
device type.
In the Logical workspace is a pre-built smart home network that consists of many wired and
wireless IoT devices, and network infrastructure devices.
When you place your curser over a device, such as the Smart Fan, an informational window
opens containing basic network information about that device.
17
To turn on or activate a device, simply hold down the Alt key on the keyboard and then left-click
the device. Try this on each of the smart devices to observe what they do.
The smart home network also consists of infrastructure devices such as a home gateway.
Click the Home Gateway icon to open the Home Gateway window.
The Physical tab is selected by default and shows a picture of the Home Gateway.
Next, click the Configtab and then in the left pane click LAN to view the LAN Settings of the
Home Gateway.
Write down the IP Address of the home network for future reference. ___________________
18
Click Wireless in the left pane to view the wireless settings of the Home Gateway.
Write down the SSID of the home network _______________ and the WPA2-PSK Pass Phrase
______________ for future reference.
Next, click the Tablet device icon to open the Tablet window.
19
In the Tablet window, select the Desktop tab and then click the Web Browser icon.
In the Web Browser window, type the IP address of the Home Gateway 192.168.25.1 into the
URL box and click Go. In the Home Gateway Login screen, type admin for both the username
and the password and click Submit.
20
After you have connected to the Home Gateway web interface, a list of all the connected IoT
devices appears.
21
When you click a device in the list, the status and settings of that device is displayed.
22
Step 2: Configure the sprinkler for network connectivity
c. Click the Lawn Sprinkler device icon in the workspace to open the device window. Notice that
right now the name of the Lawn Sprinkler is a generic IoT0.
The device window will open to the Specification tab which gives information about the device
which can be edited.
23
d. Click the Config tab to edit the device configuration settings.
In the Config tab, make the following changes to Settings:
Set the Display Name to Sprinkler1 (notice the window name changes to Sprinkler1)
Set the IoT Server to Home Gateway
24
Click FastEthernet0 and change the IP Configuration to DHCP.
25
e. Verify that the sprinker is on the network.
Log into the Home Gateway from the Tablet.
The device Sprinkler 1 should now appear in the IoT Server – Devices list.
26
Close the Tablet window.
Step 3: Experiment by adding other types of IoT devices to the smart home network. Add
Wireless IoT Devices to the Smart Home Network
27
g. Add wireless module to the Wind Detector.
Click the Wind Detector icon in the workspace to open the IoT device window. In the bottom right
corner of the IoT device window, click the Advanced button. Notice more tabs become visible at
the top of the window. Click the I/O Config tab.
Change the Network Adapter drop down list to PT-IOT-NM-1W, which is a wireless adapter.
28
Next click Wireless0 in the left pane. Change the Authentication type to WPA2-PSK and in the
PSK Pass Phrase box type mySecretKey. These are the wireless settings from the Home
Gateway that you recorded in Part 1.
A wireless connection should be formed between the Wind Detector and the Home Gateway.
29
i. Verify the Wind Detector is on the network.
Log into the Home Gateway from the Tablet.
The device Wind Detector should now appear in the IoT Server – Devices list.
30
Experiment : 5
Aim : Familiarisation with Node Red and perform necessary software installation on Raspbian OS.
Node-RED is a programming tool for wiring together hardware devices, APIs and online services in
new and interesting ways.
It provides a browser-based editor that makes it easy to wire together flows using the wide range of
nodes in the palette that can be deployed to its runtime in a single-click.
JavaScript functions can be created within the editor using a rich text editor.
A built-in library allows you to save useful functions, templates or flows for re-use.
Built on Node.js
The light-weight runtime is built on Node.js, taking full advantage of its event-driven, non-
blocking model. This makes it ideal to run at the edge of the network on low-cost hardware
such as the Raspberry Pi as well as in the cloud.
With over 225,000 modules in Node's package repository, it is easy to extend the range of
palette nodes to add new capabilities.
Node-RED is built on Node.js, taking full advantage of its event-driven, non-blocking model. This
makes it ideal to run at the edge of the network on low-cost hardware such as the Raspberry Pi
as well as in the cloud.
31
Running on Raspberry Pi
Running the following command will download and run the script. If you want to review the
contents of the script first, you can view it here.
remove the pre-packaged version of Node-RED and Node.js if they are present
install the current Node.js LTS release using the NodeSource. If it detects Node.js is
already installed from NodeSource, it will ensure it is at least Node 8, but otherwise
leave it alone
install the latest version of Node-RED using npm
optionally install a collection of useful Pi-specific nodes
setup Node-RED to run as a service and provide a set of commands to work with the
service
Node-RED has also been packaged for the Raspbian repositories and appears in their list of
'Recommended Software'. This allows it to be installed using apt-get install nodered and
includes the Raspbian-packaged version of Node.js, but does not include npm.
While using these packages is convenient at first, we strongly recommend using our install
script above instead.
Running locally
Due to the limited memory of the Raspberry Pi, you will need to start Node-RED with an
additional argument to tell the underlying Node.js process to free up unused memory sooner
than it would otherwise.
32
To do this, you should use the alternative node-red-pi command and pass in the max-old-space-
size argument.
node-red-pi --max-old-space-size=256
Running as a service
The install script for the Pi also sets it up to run as a service. This means it can run in the
background and be enabled to automatically start on boot.
node-red-start - this starts the Node-RED service and displays its log output.
Pressing Ctrl-C or closing the window does not stop the service; it keeps running in the
background
node-red-stop - this stops the Node-RED service
node-red-restart - this stops and restarts the Node-RED service
node-red-log - this displays the log output of the service
You can also start the Node-RED service on the Raspbian Desktop by selecting the Menu ->
Programming -> Node-RED menu option.
Autostart on boot
If you want Node-RED to run when the Pi is turned on, or re-booted, you can enable the service
to autostart by running the command:
If you are using the browser on the Pi desktop, you can open the
address: http://localhost:1880.
When browsing from another machine you should use the hostname or IP-address of the
Pi: http://<hostname>:1880. You can find the IP address by running hostname -I on the Pi.
http://192.168.1.1:1880
33
Experiment : 6
Aim :Home Automation with Node-RED & Raspberry Pi, Control Lights & Read DHT11 Data.
Node-RED is a visual tool for non-programmers to work with the IoT, it can be used to build
applications faster and reduce the “go-to-market” time for IoT products. It can also be used to
easily interface hardware devices, APIs, and other online services together in new and interesting
ways.
Node-RED can directly access data from microcontroller boards like Arduino, Raspberry Pi
using the predefined port number or pin number.
In this lab, we are going to build a Home Automation System that can control lights and can
monitor temperature and humidity graphically on gauge created on the Dashboard.
Components Required for Home Automation using Node-Red
Raspberry Pi
Relay Module
DHT11 Sensor
AC Bulb
LED
Breadboard
Jumper Wires
Install Node-RED on Raspberry Pi
Node-RED comes pre-installed on the Raspbian Stretch OS. In case you don’t have Node-RED
installed on your Pi, you can use the command given below to install Node.js, npm, and Node-
RED onto a Raspberry Pi. This command can also be used to upgrade an existing installation.
34
The command will do the following things:
When the installation completes, you should see the Node-RED icon under the programming
apps list.
Starting Node-RED on Raspberry Pi
Node-RED can be either launched via Pi’s Desktop Interface or via Raspberry Pi terminal
window.
From the Pi’s Desktop Interface: Select Menu -> Programming -> Node-RED
35
Remotely from your Computer’s Terminal: Run node-red-start in a new Raspberry Pi terminal
window. To launch from the Pi’s Desktop Interface, click on Menu > Programming > Node-
RED.
To launch it from the Raspberry Pi Terminal window, navigate to Terminal and enter the
command given below:
node-red-start
36
37
After this, you will be greeted with the following screen.
38
Before we start building the Node-Red flows, we need to install the palette for the Dashboard
and DHT11 sensor in node-red. For that, click the menu icon in the top right corner, and then
click on “Manage Palette”
Go to the Install tab, and then search and install ‘node-red-dashboard’ and 'node-red-contrib-
dht-sensor’ nodes.
39
40
Then create a tab called ‘Home Automation’ and inside this tab, create two groups: Office and
DHT, as shown below.
Now, go to the Dashboard tab and drag the Switch node into the flow section.
41
Now, double-click on the Switch node to edit it. Rename the Switch node as LED. Add Name of
Group “Home Automation” for grouping the node.
42
Then go to the Raspberry Pi tab and drag the ‘rpigpio out’ node into the flow section.
43
Then double-click on the node, select the GPIO18 pin, and select ‘Digital Output’ as the output
type.
44
Follow the same procedure for adding another switch.
45
Now in the next step, add nodes to read DHT11 sensor data. For that, go to the Common node
palette and drag the inject node to the flow. Double click on the inject node and then set the
interval to every 1 second.
Then go to the Raspberry Pi tab and drag the rpi-dht22 node to the flow.
Double click on the rpi-dht22 node and then select the DHT11 as sensor module and 4 in a pin
number.
46
Now, in the next step, go to the Function tab and drag two functions nodes to the flow as shown
below.
47
Double click on the function, rename it to Temperature, and then add a line to get only
temperature data. Do the same for the second function node to get humidity data.
Now, in the next step, go to the Dashboard tab and drag two gauge nodes to the flow as shown
below.
48
Double click on nodes to configure them. You can specify the following, as seen in the picture
here:
The final flow will look like this:
49
With this done, we are now ready to deploy the project. Click the Deploy button in the top right
corner.
Now, to see how the Node RED dashboard looks, go to http://your-pi-ip-address/ui.
50
51
The LED is connected to the GPIO18 pin while the input pin of the relay is connected to the
GPIO24 pin of Raspberry Pi. The data pin of DHT 11 is connected to GPIO4.
With this done, go to Node-RED Dashboard to control the LED and Bulb.
52
This is how you can turn on lights and monitor sensors on Raspberry Pi using Node-RED.
53
Experiment : 7
Raspberry Pi Board
Raspberry Pi Camera V2 Module
MicroSD Card – 16GB Class10
Raspberry Pi Power Supply (5V 2.5A)
With the Pi shutdown, connect the camera to the Pi CSI port as shown in the following
figure. Make sure the camera is connected in the right orientation with the ribbon blue
letters facing up.
To use the Raspberry Pi Camera module, you need to enable the camera software in
your Raspberry Pi. In the Desktop environment, go to the Raspberry Pi
54
Configuration window under the Preferences menu, open the Interfaces tab and
enable the Camera as shown in figure below.
55
Installing the Raspberry Pi Camera node
To install the Raspberry Pi Camera node on Node-RED, enter the following command:
You need to chose a directory where the photos will be temporarily saved. For that you
need to edit the settings.js file. Try one of the following commands because your
Node-RED directory installation may be different.
pi@raspberry:~ $ sudonano /root/.node-red/settings.js
or
Then, scroll down the file, find the httpStatic setting, uncomment and type your desired
directory to store the Raspberry Pi Camera photo. Take a look at the figure below.
httpStatic: '/home/pi/Pictures/',
56
When you’re done, exit and save the changes.
Start Node-RED
http://Your_RPi_IP_address:1880
You should replace Your_RPi_IP_address with your Raspberry Pi IP address. If you
don’t know your Raspberry Pi IP address, in the Terminal enter:
pi@raspberry:~ $ hostname -I
Node-RED Dashboard
You need to create a tab and a group on Node-RED to add your dashboard widgets.
Follow the next instruction to create a tab and a group (see figure below):
On top right corner of the Node-RED window you have a tab called dashboard.
Select that tab (1). To add a tab to the user interface click on the +tab button (2).
Once created, you can edit the tab by clicking on the edit button (3).
57
You can edit the tab’s name and change its icon:
Before creating the flow, make sure you have the camerapitakephoto node, as show in
the figure below. If you don’t have the node, check that you’ve followed the instructions
above in the Installing the Raspberry Pi Camera node section.
58
First, drag 3 nodes into the flow: template, camerapitakephoto and debug.
Template node
Then, edit the template node, as shown in the figure below – copy and paste the
template code below the figure.
59
<script>
60
functionupdateF() {
document.getElementById("photo").src = newUrl;
</script>
<ui-icon icon="camera"></ui-icon>
Take a photo<br>
</md-button>
<div style="margin-bottom:40px;">
</div>
This JavaScript code automatically updates the Node-RED page when a new photo is
taken.
CamerapiTakephoto node
Finally, edit the camerapitakephoto node with the following properties:
61
Note 1: don’t forget to add the right File Path to your node including the last
forward slash – /home/pi/Pictures/
Note 2: every time you open the camerapitakephoto node, it will change the
file default path to yes. So, make sure you select the right properties, every
time you open the node.
Note 3: when you take a new photo, it will be saved on your chosen directory with the
name photo1.JPEG. Every time you take a new photo, Node-RED overwrites the
existing photo because they have the same name.
Node-RED UI
Your Node-RED application is ready. To access the UI, you can use any browser in
your local network when you type:
http://Your_RPi_IP_address:1880 /ui
63
Troubleshooting
1) If your image is not being displayed on the Node-RED UI, you can go the following
URL and see if your httpStatic path was set properly:
http://Your_RPi_IP_address:1880/photo1.JPEG
64
2) If the Pi Camera is not taking photos, double-check that the camera ribbon is well
connected to your Pi’s CSI port. Also confirm that it’s enabled in your Pi’s raspi-config
menu.
3) Open the camerapitakephoto node and ensure that it has the right file path.
65
66
Experiment : 8
Aim :Car Plate recognition system with Node-Red using Raspberry Pi.
In this lab you are going to learn how to build a car recognition system using a Raspberry Pi and
Node-RED. For this lab we will be using a software called OpenALPR (Automatic License Place
Recognition) that has an API you can use to identify car plates and car models based on an
image.
Overview
67
In this example, we use a PIR motion sensor to detect that the car arrives home. There are other
sensors that may be more suitable to detect a car, for example:
Hall effect sensor: senses changes in magnetic field when the car is near;
Ultrasonic sensor: detects distance to an object;
Active infrared detectors: detects the presence of an object by detecting the reflection of
infrared light.
When the sensor detects motion, the Raspberry Pi camera takes a photo. After that, the Pi sends a
request to OpenALPR with the car photo to be identified. Then, the OpenALPR API returns the
car details like: plate number, model, color, and the confidence of the results.
After identifying a car, we’ll do some verifications, and if we found an authorized car, we’ll
trigger an event (that can be open the garage, for example). The following image contains a
flowchart showing the process.
Here’s what happens: after the car has been identified by OpenALPR, we’ll check if the license
plate and the car model match. If they match, we’ll check if the car is in the list of authorized
vehicles. If it is, we’ll trigger an event. For example: open the garage. After that, we wait a
determined period of time until the car enters the garage. Then, you need to add several
verifications to check if the car has already entered the garage. If yes, you can close the garage.
68
Raspberry Pi Board
Raspberry Pi Camera V2 Module
MicroSD Card – 16GB Class10
Raspberry Pi Power Supply (5V 2.5A)
Mini PIR Motion Sensor or PIR Motion Sensor
LED
Resistor (220 or 330 ohms should work)
Breadboard
Jumper wires
With the Pi shutdown, connect the camera to the Pi CSI port as shown in the following figure.
Make sure the camera is connected in the right orientation with the ribbon blue letters facing up
(you need to enable the camera in your Raspbian OS).
69
You should also have Node-RED installed in your Pi and the node-red-contrib-camerapi node
Installed:
Schematics
Assemble the circuit to test this project. Follow these next schematic diagram:
70
After having your Raspberry Pi prepared and Node-RED software configured, you can continue
with this project.
OpenALPR
OpenALPR is an open source Automatic License Plate Recognition library written in C++ with
bindings in C#, Java, Node.js, Go, and Python. They also have the OpenALPR Cloud API which
is a web service running in the cloud that analyzes images of vehicles and responds with license
71
plate, model, color and much more. OpenALPR Cloud API has a free service that allows up to
2000 free recognitions per month.
Note: instead of using their Cloud API that is limited to only 2000 recognitions per month, you
can install their Open Source software and use their Python integration to write Python scripts to
analyse unlimited images. That way you don’t need to use their cloud service and you aren’t
restricted to 2000 requests per month.
Supported countries
Creating a free account
To get started with OpenALPR Cloud API, you can create a free account. After completing your
account creation, you should have access to the following page:
Open the Cloud API tab to access your Secret Key. You need it to make requests to the API.
72
In my case, the secret key is: sk_8081041caedd50a———
Save your secret key in a safe place, because you’ll need it in just a moment.
First, you should start by identifying your car using the Pi Camera and the OpenALPR service.
So, start with the provided sample flow that takes a photo and makes a request to the OpeALPR
Cloud API to identify your car.
Next, in the Node-RED window, at the top right corner, select the menu, and go
to Import > Clipboard.
73
Then, paste the code provided and click Import. The next nodes should show up in your flow:
Edit the node to have the same settings as shown in the next figure:
74
Important: sometimes the previous node might overwrite the default setting. Make sure you
double-check that it has the right settings. Then, click the deploy button.
75
Then, change the Command field to include your Secret Key and country code:
76
Testing the flow
After deploying the flow, let’s test the car identification process. Move your car to a place that
you can take a photo with your Raspberry Pi:
Point the camera to the car and tap the square next to the timestamp node to trigger the flow.
77
Click the arrow next to the results: array[1] to expand the object. You should see a plate object
with your car plate. Save the car plate in the format retrieved by the API. In my case it’s
“61CP–“. You’ll need it later to identify your car:
78
Expand the vehicle object > make_model > 0: object and you should see the name of your car
and how the API identified the car model. In our case it identified the car as a Toyota Yaris with
77,2% confidence. We should save the exact string “toyota_yaris” retrieved by the API, because
we need it for the next flow. Save your car model in the format retrieved by the API.
79
80
Experiment : 9
Agriculture is the largest industry in the world; however it also poses one of the biggest threats
to the environment.
According to the World Wildlife Foundation (WWF), agriculture wastes 60% or 1,500 trillion
litres, of the 2,500 trillion litres of water it uses each year- which is 70% of the world‟s
accessible water.
- reduce water consumption help farmers get the most out of their crops.
- With the help of our system we can check or adjust irrigation at anytime - from home, work
station or away.
- Receive alerts.
To develop a smart irrigation system in order to reduce the time & consumption of water used
to irrigate the gardens/Farmfield’s
Intelligent irrigation scheduling system with its unique Soil-Moisture Model for optimal water
use.
Easy-to-use Smartphone and Web Apps to support crop irrigation decisions with real-time
data.
The Smart Agriculture system fulfils the following performance objectives, to ensure its
widespread uptake by growers and irrigators:
81
- Intelligent irrigation scheduling system with its unique Soil-Moisture Model for optimal water
use.
- The system is cost effective to ensure its widespread uptake by farmers, Lower operating costs.
Solution :
- The sensors that measure soil water content , environmental parameters and send readings
across a IoT gateway (Raspberry Pi 3) which sends all of this data to a central web service .
- Central web service which uses an intelligent software application to automatically analyse
the data and act upon it by selectively activating irrigation nodes only in the areas required.
- This data is fed into an intelligent software package that uses intelligent agents in order to
act upon the information they are receiving from the sensors. The outputs and irrigation
recommendations are presented to the user on a Smartphone App or Web Browser.
Architecture
In this lab we are using raspberry pi as gateway, The gateway is a key component of every IoT
solution. An IoT gateway device bridges the communication gap between IoT devices, sensors,
equipment, systems and the cloud.
82
Raspberry Pi 3 :
83
Irrigation performed at a given date and time through web or mobile application.
Automated irrigation with a fixed duration, when soil moisture, humidity sensors value get
low at the programmed threshold level.
Step 1: Start.
Step 3: The soil moisture sensor checks the soil moisture level & temperature and humidity
checks the temperature and humid values constantly & feeds to the raspberry pi
Step 4: Raspberry pi compare the sensor input and the threshold value
Step 5: If the sensors input value is less than given threshold values, plants get watered(for
30 minutes) or else it continues to read the sensor values
84
Step 5: The DHT11 sensor constantly senses the temperature and humidity of the field and
updates the data in the web server.
Step 6: The USB camera installed with the Raspberry Pi gives the complete surveillance of
the field and this can be monitored in the internal network system.
85
86
87
Experiment : 10
1. Aim : Smart Mirror with Node-Red using Raspberry Pi.
MagicMirror is an open source modular smart mirror platform. With a growing list of installable modules,
the MagicMirrorallows you to convert your hallway or bathroom mirror into your personal assistant.
Requirements :
Hardware
Installation :
2. Clone the repository and check out the master branch: git clone
https://github.com/MichMich/MagicMirror
3. Enter the repository: cd MagicMirror/
4. Install the application: npm install
5. Make a copy of the config sample file: cpconfig/config.js.sampleconfig/config.js
6. Start the application: npm run start
For Server Only use: npm run server .
Enable VNC
Install x11vnc:
sudo apt-get install x11vnc
Set VNC password:
x11vnc -storepasswd
Create an auto-start file:
cd ~/.config
mkdirautostart
cdautostart
nano x11vnc.desktop
Modules
89
90