0% found this document useful (0 votes)
57 views84 pages

Mc4312-Iot Lab Manual

Iot2

Uploaded by

hemnathchandrena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views84 pages

Mc4312-Iot Lab Manual

Iot2

Uploaded by

hemnathchandrena
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 84

MC4312 Internet of Things Lab

SRI MUTHUKUMARAN INSTITUTE OF TECHNOLOGY


DEPARTMENT OF
MASTER OF COMPUTER APPLICATIONS

MC5315 INTERNET OF THINGS LABORATORY

LAB MANUAL

III Semester – MCA

(2021 Regulation)

Prepared by

S.KEERTHANA.,M.E
AP/EEE
G.SANDRA KARUNYA.,M.E
AP/CSE

Dept of MCA, SMITPage 1


MC4312 Internet of Things Lab

MC4312 INTERNET OF THINGS LABORATORY


OBJECTIVES:
● To learn tools relevant to embedded system and IoT development.
● To write simple assembly programs that uses various features of the processor.
● To design and develop IoT application Arduino/Raspberry pi for real world scenario.

EXPERIMENTS:
PART I:
1. Implement assembly and Interfacing Programs Using Embedded C.
2. Embedded Application Development
(i) Using Arduino and Raspberry Pi
(ii) Using Bluemix platform
3. IoT Application Development
(i) Using sensors and actuators (temperature sensor, light sensor, infraredsensor)
(ii) Interfacing sensors with Arduino/Raspberry Pi/other equivalent boards
(iii) Reading data from sensors
4. Explore different communication methods with IoT devices.
5. Collecting and processing data from IoT systems in the cloud using XivelyPaaS.
6. Develop IoT applications using Django Framework and Firebase/ Bluemix platform.

OUTCOMES:
On completion of the course, the students will be able to:
1. Write and implement simple assembly programs that use various features of the processor.
2. Test and experiment different sensors for application development Arduino/Raspberry Pi/
Equivalent boards.
3. Develop IOT applications with different platform and frameworks.

Dept of MCA, SMITPage 2


MC4312 Internet of Things Lab

STUDY OF RASPBERRY-PI, BEAGLE BOARD, ARDUINO

Aim:

To Study of Raspberry-Pi, Beagle board, Arduino and other micro controller (History
& Elevation)
Theory:
A Raspberry Pi is a credit card-sized computer originally designed for education,
inspired by the 1981 BBC Micro. Creator Eben Upton's goal was to create a low-cost device
that would improve programming skills and hardware understanding at the pre-university
level. But thanks to its small size and accessible price, it was quickly adopted by tinkerers,
makers, and electronics enthusiasts for projects that require more than a basic microcontroller
(such as Arduino devices).
The Raspberry Pi is slower than a modern laptop or desktop but is still a complete
Linux computer and can provide all the expected abilities that implies, at a low-power
consumption level.
In February 2012, the UK based company Raspberry Pi Foundation has launched a very low-
cost and credit card sized programming computer named as Raspberry Pi 1. It had a basic
design, which plugs into a TV or computer monitor, and uses a standard keyboard and a
mouse. It was capable of doing each thing that a desktop computer can do by using
programming languages like Scratch and Python, like browsing the web, making excel sheets
and word documents, playing HD videos or games, etc.

Is the Raspberry Pi open hardware?

The Raspberry Pi is open hardware, with the exception of the primary chip on the
Raspberry Pi, the Broadcomm SoC (System on a Chip), which runs many of the main
components of the board–CPU, graphics, memory, the USB controller, etc. Many of the
projects made with a Raspberry Pi are open and well-documented as well and are things you
can build and modify yourself.

What are the differences in Raspberry Pi models?

The Raspberry Pi Foundation has just recently released a new model, the Raspberry Pi

Dept of MCA, SMITPage 3


MC4312 Internet of Things Lab

2, which supersedes some of the previous boards, although the older boards will still be
produced as long as there is a demand for them. It is generally backwards compatible with

previous versions of the board, so any tutorials or projects you see which were built for a
previous version of the board should still work.

There are a two Raspberry Pi models, the A and the B, named after the afore
mentioned BBC Micro, which was also released in a Model A and a Model B. The A comes
with 256MB of RAM and one USB port. It is cheaper and uses less power than the B. The
current model B comes with a second USB port, an ethernet port for connection to a network,
and 512MB of RAM.

The Raspberry Pi A and B boards been upgraded to the A+ and B+ respectively.


These upgrades make minor improvements, such as an increased number of USB ports and
improved power consumption, particularly in the B

What kind of operating system does the Raspberry Pi run?

The Raspberry Pi was designed for the Linux operating system, and many Linux
distributions now have a version optimized for the Raspberry Pi.

Two of the most popular options are Raspbian, which is based on the Debian
operating system, and Pidora, which is based on the Fedora operating system. For beginners,
either of these two work well; which one you choose to use is a matter of personal preference.
A good practice might be to go with the one which most closely resembles an operating
system you’re familiar with, in either a desktop or server environment.

If you would like to experiment with multiple Linux distributions and aren't sure
which one you want, or you just want an easier experience in case something goes wrong, try
NOOBS, which stands for New Out Of Box Software. When you first boot from the SD card,
you will be given a menu with multiple distributions (including Raspbian and Pidora) to
choose from. If you decide to try a different one, or if something goes wrong with your
system, you simply hold the Shift key at boot to return to this menu and start over.

Dept of MCA, SMITPage 4


MC4312 Internet of Things Lab

There are, of course, lots of other choices. OpenELEC and RaspBMC are both
operating system distributions based on Linux that are targeted towards using the Raspberry
Pi as a media center. There are also non-Linux systems, like RISC OS, which run on the Pi.
Some enthusiasts have even used the Raspberry Pi to learn about operating systems by
designing their own.

1. Raspberry Pi Model A+

After the first Raspberry Pi Model A was launched in February 2012, with the letter
release of the Raspberry Pi Model B, the company was looking to upgrade the features of
these basic models. And after a year of the first release, the Raspberry Pi Model A+ was
launched.

• It has more GPIO pins and better audio with a dedicated low-noise power supply
• It is having a nicer push-push micro SD card socket, which is the
replacement of the old friction-fit SD card version
• It has switching regulators which help in consuming low power comparing to linear
regulators in the model A

• It has aligned USB connector, four square mounting holes, composite


video moved onto 3.5mm jack, and all these things make it 2cm shorter
than the original Pi – smaller, neater design
• It is a good option for embedded projects, the projects in which Ethernet or multiple
USB ports are not required, and where low power is required

Dept of MCA, SMITPage 5


MC4312 Internet of Things Lab

2. Raspberry Pi Model B+

The Raspberry Pi Model B+ was the final revision of the original model of the Raspberry Pi
family. It is versatile and low-cost Pi, which is confidently much-valued performer
than the A, A+, and B models. Comparing it to the original model B,

• It has more GPIO pins, which are having the same pinout as in the Raspberry Pi
model A and B
• Replacing the old type of friction-fit SD card socket, it has push-push nicer micro SD
version
• It has 4 USB 2.0 ports, which are doubled than are in model B
• It consumes low power with switching regulators and has better audio with a
dedicated low- noise power supply
• It has a neater and smaller form factor which is better than the model B and as same
as model A+
• It is the best choice if you require good connectivity, but not necessarily required top-
notch performance as in general applications

3. Raspberry Pi 2 Model B

This is the second generation Raspberry Pi model which is thereplacement of the


Raspberry Pi Model B+. With the updated chipset, 1GB RAM with a quad-core processor, it
is top-of- the-line performer Pi member. It is even capable of running Windows IoT (Internet
of Things) applications, which makes it a surprisingly capable beast.
Dept of MCA, SMITPage 6
MC4312 Internet of Things Lab

• It comes with a 900MHz quad-core ARM Cortex-A7 processor with 1GB RAM
• Same as model B+, it is having 40 GPIO pins, 4 USB ports, HDMI and
Ethernet ports, combined composite video and 3.5mm audio jack, Camera
and Display interfaces, Micro SD card slot, and a VideoCore IV 3D
Graphics core
• It can run a full range of ARM GNU/Linux versions
• It requires third times more power than the Model A+ and Model B+, even
then it sucks up less than a single Watt power
• It has an identical form factor compared to the Raspberry Pi Model B+ and also it is
completely compatible with the Original Raspberry Pi
• It is best for – what to say- for anything, just can be overpowered if you
require something very small or for a single use

4. Raspberry Pi Zero

This is the revolutionary, world’s cheapest tiny programmable computer which is


priced only $5 at the time it was launched. The Raspberry Pi Zero is almost half the size of
the model A+ with doubled utility..

• It is 40% faster than the original Pi model


• Comes with a single-core CPU with 512MB RAM and 1GHz speed
• It has on-the-go mini HDMI and USB ports
• Requires micro USB power
• It has composite video and reset headers, and an HAT-compatible 40-pin header

Dept of MCA, SMITPage 7


MC4312 Internet of Things Lab

• It only requires some more connectivity and soldering if you want to use it for some
complex projects
• It is the best version to choose if you want single-use applications and low-powered
projects

5. Raspberry Pi 3 Model B

On the leap day of 2016, the Raspberry Pi Foundation has launched its smartest and fastest Pi
version named as the Raspberry Pi 3 Model B. It is a $35 computer, which has everything in
features to challenge the modern PCs. It has an elevated performance, which makes it
comfortable for using as a desktop computer.

• It comes with built-in Wi-Fi and Bluetooth, which outperforms all the previous
models which require a separate connection for each
• It is compatible with the latest wireless 802.11n standards
• It comes with a Broadcom 2837 64-bit quad-core processor, which runs at 1.2GHZ
speed
• It has 1GB SDRAM and micro SD card storage slot
• It has 40 GPIO Pins, 4 USB 2.0 ports, and full HDMI & Ethernet ports
• Also included Camera & Display interfaces, combined composite video and 3.5mm
audio jack, graphics core of VideoCore IV 3D
• It is compatible with the original Pi models and the Pi 2
• It has an identical form factor that of Raspberry Pi 2 Model B
• It is IoT-ready and is best for anything you have in mind to build with, best for
schools as well

Dept of MCA, SMITPage 8


MC4312 Internet of Things Lab

Benchmark:

Raspber Pi 2 Model Pi 3 Model


Model A+ Model B+ Pi Zero
ry Pi: B B
Release: Nov 2014 July 2014 Feb 2015 Nov 2015 Feb 2016

Availabl Yes Yes Yes Yes Yes


e:
Price
20 25 35 5 35
(US$):
900MHz 1.2GHz
700MHz single 700MHz single 1GHz
32- 64-
Processo core core ARM1176JZF
ARM1176JZF- ARM1176JZF- bit quad- -S bit quad-
r:
S S core ARM single core core ARM
Cortex-A7 Cortex-
A53
Broadcom Broadcom Broadcom Broadcom Broadcom
SoC
BCM2835 BCM2835 BCM2836 BCM2835 BCM2837

Dept of MCA, SMITPage 9


MC4312 Internet of Things Lab

RAM: 512MB Shared 512 MB 1GB 512MB Shared 1GB


Shared Shared Shared
USB 2.0
1 4 4 1 4
Ports:

Beagle Board

The beagleboard is a low-power open-source single-board computer produced by


Texas Instruments in association with Digi-Key and Newark element14. The beagleboard
was also designed with open source software development in mind, and as a way of
demonstrating the Texas Instrument's OMAP3530 system-on-a-chip. The board was
developed by a small team of engineers as an educational board that could be used in colleges
around the world to teach open source hardware and software capabilities. It is also sold to
the public under the Creative Commons share-alike license. The board was designed using
Cadence orcad for schematics and Cadence Allegro for PCB manufacturing; no simulation
software was used.
There are two distinct versions of the BeagleBone: the Original BeagleBone and the
BeagleBone Black. The two boards are similar except for a few small details. Here is the
Original BeagleBone:

Another familiar, common designation on the web for the BeagleBone Black is BBB.
Dept of MCA, SMITPage 10
MC4312 Internet of Things Lab

Here is the BeagleBone Black:

Following are the components featured in both the Original BeagleBone and the BeagleBone
Black:

● Processor: You can call the processor the “brains” of your BeagleBone. Both boards
feature an ARM Cortex-A8 operating at a maximum speed of 720MHz for the Original
BeagleBone and 1GHz for the BeagleBone Black. This means that the latter makes a
decision/calculation every 0.000000001 second!
● RAM: The Original BeagleBone has 256MB of DDR2 (Double Data Rate 2), whereas
the BeagleBone Black has 512MB of DDR3.
● microSD card slot: The Original BeagleBone doesn’t have any built-in memory, so it
always needs to have a microSD card inside to be able to work. By default, it comes with
a 4GB microSD card. The BeagleBone Black doesn’t come with a microSD card
because it has built-in memory. Regardless, you can still insert a microSD card into it to
install or update your operating system or because you want to have more available

Dept of MCA, SMITPage 11


MC4312 Internet of Things Lab

memory to play around with.


● DC power connector: Your BeagleBone needs 5 volts (V) and 500 milliamps (mA) of
direct current to power up. Connecting the BeagleBone to your computer with a USB
cable also provides the necessary power for the board to power up. If you have a
connector that fits into your BeagleBone connector, that doesn’t necessarily mean that
it’s the right power adapter! Not all power adapters provide exactly 5V; some of them
actually provide 12V. You also need to check for the connector’s polarity; the center
ring has to provide the 5V and the outer ring has to provide Ground (GND). You need to
be careful. Even though the board has a voltage regulator, feeding it excess power or
wrong polarity could permanently damage it!
● USB client: Both boards offer an USB client for powering up, communications, and
debugging.
● USB host: Both boards include one USB port. This port enables you to connect
peripherals such as a keyboard or a USB stick.
● Ethernet: Both boards feature a standard RJ45 Ethernet port. By plugging an Ethernet
cable in it and connecting the BeagleBone directly to a router or by sharing the Wi-Fi
connection of your computer, you can easily manage software on your BeagleBone, as
well as build projects that require an Internet connection.
● Headers: The BeagleBone headers, labeled P8 and P9, can be used in many ways. You
can use them to insert capes or supply power, for example, and you can program them to
establish communications with other devices or act as inputs or outputs.
● USR LEDs: The USR LEDs indicate the status of your board:
o USR0: Blinks for as long as the system is running
o USR1: Blinks whenever the microSD card is being accessed
o USR2: Blinks to indicate that the central processing unit (CPU) is active

o USR3: For the BeagleBone Black, this LED blinks when the eMMC (embedded
MultiMediaCard) memory is being accessed
● Reset button: This button resets your board when you press it. Keep in mind, though,
that your BeagleBone is just like a regular computer; you should reboot it this way only
when it crashes.
Besides the previously mentioned components, the BeagleBone Black has a few
additional components. These are:
● eMMC: The eMMC memory is the built-in memory on your BeagleBone Black. The
Dept of MCA, SMITPage 12
MC4312 Internet of Things Lab

amount you have depends on your BeagleBone Black’s revisions (Rev):


o BeagleBone Black Rev A and B: 2GB of eMMC memory
o BeagleBone Black Rev C: 4GB of eMMC memory
● Micro HDMI: This port is used to connect your BeagleBone Black to a computer
display or a television set.
● Serial header: The BeagleBone Black has a separate header for one of its serial ports,
enabling you to easily connect a USB-to-TTL serial cable (read Chapter 3 for more on
this topic).
● Power button: If you press the power button, the board shuts down after a
few seconds. You can turn it ON once more by pressing the power button again. You
can also do a full power cycle by pressing the board for about 10 seconds; the board
turns OFF and then comes back ON. You should avoid this, though, as it may corrupt
the eMMC or SD card. Use it only if your board is not responding to your commands.
● User boot button: By default, your BeagleBone Black boots from onboard memory
with the operating system (OS) installed there. By holding down this button when you
power the board, you indicate that you want it to boot from the microSD card. You
also use this button to install an operating system on the eMMC.
● Choosing an Operating System
There are a few operating systems you can choose to use on your BeagleBone Black.
Angstrom, Ubuntu, and Debian all appear to have stable images.

Angstrom is the default operating system, and usually the best choice. Angstrom
Angstrom is the default Linux distribution that is pre-installed on the eMMC on the
BeagleBone Black. It's a stripped down version of Linux specifically designed for
embedded devices.Depending on how long ago you purchased your BeagleBone
Black, you may not have the latest version of Angstrom installed. It's usually
preferable to get the latest version, especially this early in the product's lifecycle

Languages supported

Beaglebone black supports various high level languages such as a C, C++ and
scripting languages like java, python.
Programming of application is mostly written in C language for controller or
Dept of MCA, SMITPage 13
MC4312 Internet of Things Lab

processor. Python is an interpreted language and great library source available for BBB.
At low level, programming in python is efficient and responds quicker than C
language.

Product Comparison Table


PocketBeagl BeagleBone BeagleBone BeagleBoard-
e Black Blue X15
AM5728
AM3358 AM3358 AM3358
Processor 2x ARM Cortex-
ARM Cortex- ARM Cortex-A8 ARM Cortex-
A15
A8 A8
Maximu
m 1GHz 1GHz 1GHz 1.5GHz
Processor
Speed
4x200-MHz
2x200-MHz 2x200-MHz
Co- 2x200-MHz PRUs, 2x ARM
PRUs, ARM PRUs, ARM
processor PRUs, Cortex-M4, 2x
Cortex-M3, Cortex-M3,
s ARM Cortex- SGX PowerVR,
SGX PowerVR SGX PowerVR
M3, SGX 2x HD video
PowerVR
Analog 8 (3.3V), 6
7 (1.8V) 4 (1.8V) TBD
Pins (1.8V)
Digital 44 (3.3V) 65 (3.3V) 24 (3.3V) TBD
Pins
512MB DDR3 512MB DDR3
512MB DDR3 (800MHz x 16), (800MHz x 16), 2GB DDR, 4GB
Memory (800MHz x 4GB on-board 4GB on-board on-board storage
16), storage using storage using using eMMC,
microSD card eMMC, microSD eMMC, microSD card
slot card slot microSD card slot
slot
USB 2.0 USB 2.0
USB 2.0 SS USB 3.0
USB Host/Client Host/Client
Host/Client Port, Host, HS USB
Dept of MCA, SMITPage 14
MC4312 Internet of Things Lab

Port, USB 2.0 USB 2.0 Host Port, USB 2.0


2.0 OTG
on Port Host Port
Port (TBD)
expansion
header
WiFi, 2x 10/100/1000
Network add-ons 10/100 Ethernet
Bluetooth, BLE Ethernet
microHDMI,
Video SPI displays SPI displays HDMI, TBD
cape add-ons
microHDMI, add-ons,
Audio add-ons 3.5mm stereo
cape add-ons Bluetooth
jack
4x UART, 8x
PWM, LCD,
Supporte TBD GPMC, MMC1, TBD TBD
d 2x SPI, 2x I2C,
Interfaces A/D
Converter,
2xCAN Bus, 4
Timers
MSRP $25 $49 $79 $249

What is a Microcontroller

● Computer on a single integrated chip


● Processor (CPU)
● Memory (RAM / ROM / Flash)
● I/O ports (USB, I2C, SPI, ADC)
● Common microcontroller families:
– Intel: 4004, 8008, etc.
● Atmel: AT and AVR
● Microchip: PIC
● ARM: (multiple manufacturers)
● Used in:

Dept of MCA, SMITPage 15


MC4312 Internet of Things Lab

● Cellphones,
● Toys
● Household appliances
● Cars
● Cameras

The ATmega328P Microcontroller used in Ardino has

●isAVR
What 8-bit RISC architecture
Ardino:
● It was founded by Massimo Banzi and David Cuartielles in 2005
● Available in DIP package
● Based on “Wiring Platform”, which dates to 2003
● Up to 20 MHz clock
● Open-source hardware platform
●● 32kB
Openflash
source development environment
memory
● Easy-to learn language and libraries (based on Wiring language)
● 1 kB SRAM
● Integrated development environment (based on processing programming
● 23 programmable I/O
environment)
● channels
● Available for Windows / Mac / Linux
● Six 10-bit
Input ADC inputs
voltage: 7-12 V (USB, DC plug, or Vin)\ Max output current per pin: 40 Ma

Dept of MCA, SMITPage 16


MC4312 Internet of Things Lab

Conclusion: We understood different types of controllers, History and their applications.

Dept of MCA, SMITPage 17


MC4312 Internet of Things Lab

STUDY OF DIFFERENT OPERATING SYSTEMS FOR RASPBERRY-PI /BEAGLE


BOARD

Aim:

1. To understand different operating systems for Raspberry-Pi

2. To Understanding the process of OS installation on Raspberry-Pi Theory:

Different operating systems for Raspberry-Pi

The Raspberry Pi was designed for the Linux operating system, and many Linux
distributions now have a version optimized for the Raspberry Pi.

Two of the most popular options are Raspbian, which is based on the Debian
operating system, and Pidora, which is based on the Fedora operating system. For beginners,
either of these two work well; which one you choose to use is a matter of personal preference.
A good practice might be to go with the one which most closely resembles an operating
system you’re familiar with, in either a desktop or server environment.

Lots of other choices. OpenELEC and RaspBMC are both operating system
distributions based on Linux that are targeted towards using the Raspberry Pi as a media
center. There are also non-Linux systems, like RISC OS, which run on the Pi. Some
enthusiasts have even used the Raspberry Pi to learn about operating systems by designing
their own.

Raspbian is a Debian-based computer operating system for Raspberry Pi. Since 2015
till now it is officially provided by the Raspberry Pi Foundation as the primary operating
system for the family of Raspberry Pi single-board computers.

Raspbian was created by Mike Thompson and Peter Green as an independent


project.•The initial build was completed in June 2012.•The operating system is still under
active development. Raspbian is highly optimized for the

Raspberry Pi line's low-performance ARM CPUs.

Raspbian uses PIXEL, Pi Improved Xwindows Environment, Lightweight as its main


desktop environment as of the latest update. •It is composed of a modified LXDE desktop
environment and the Openbox stacking window manager with a new theme and few other
changes. The distribution is shipped with a copy of computer algebra program Mathematica
Dept of MCA, SMITPage 18
MC4312 Internet of Things Lab

and a version of Minecraft called Minecraft Pi as well as a lightweight version of Chromium


as of the latest version.

Flashing the SD Card

To prepare a blank SD card for use with the Raspberry Pi, you’ll need to flash an
operating system onto the card. While this is slightly more complicated than simply dragging
and dropping files onto the card, it shouldn’t take more than a few minutes to complete.

Firstly, you’ll need to decide which Linux distribution you would like to use
with your Raspberry Pi. Each has its advantages and disadvantages.

Don’t worry if you change your mind later and want to try a different version of
Linux: an SD card can be flashed again with a new operating system at any point.

The most up-to-date list of Linux releases compatible with the Pi is available from the
Raspberry Pi website at http://www.raspberrypi.org/downloads.

The Foundation provides BitTorrent links for each distribution. These are small files
that can be used with BitTorrent software to download the files from other users. Using these
links is an efficient and fast way to distribute large files, and keeps the Foundation’s
download servers from becoming overloaded. To use a BitTorrent link, you’ll need to have
a compatible client installed. If you don’t already have a BitTorrent client installed,
download one and install it before trying to download the Raspberry Pi Linux distribution.

One client for Windows, OS X and Linux is μTorrent, available from


http://www.utorrent.com/downloads.
Which distribution you choose to download is up to you.

Raspberry Pi distribution, a good choice for beginners., Linux distributions for the
Raspberry Pi are provided as a single image file, compressed to make it faster to download.
Once you’ve downloaded the Zip archive (a compressed file, which takes less time to
download than the uncompressed files would)for your chosen distribution, you’ll
need to decompress it somewhere on your system.
In most operating systems, you can simply double-click the file to open it, and then
choose Extract or Unzip to retrieve the contents.
After you’ve decompressed the archive, you’ll end up with two separate files. The file

Dept of MCA, SMITPage 19


MC4312 Internet of Things Lab

ending in sha1 is a hash, which can be used to verify that the download hasn’t been
corrupted in transit. The file ending in img contains an exact copy of an SD card set up by
the distribution’s creators in a way that the Raspberry Pi understands. This is the file that
needs to be flashed to the SD card.
Flashing from Windows

If your current PC is running Windows, things are slightly trickier than with Linux or
OS X. Windows does not have a utility like dd, so some third-party software is required to
get the image file flashed onto the SD card.
Although it’s possible to install a Windows-compatible version of dd, there is an
easier way:

the Image Writer for Windows. Designed specifically for creating USB or SD card
images of Linux distributions, it features a simple graphical user interface that makes the
creation of a Raspberry Pi SD card straightforward.
The latest version of Image Writer for Windows can be found at the official website:
https://launchpad.net/win32- image-writer.
Follow these steps to download, install and use the Image Writer for Windows
software to prepare the SD card for the Pi:

Dept of MCA, SMITPage 20


MC4312 Internet of Things Lab

1. Download the binary (not source) Image Writer for Windows Zip file, and extract it to a
folder on your computer.
2. Plug your blank SD card into a card reader connected to the PC.

3. Double-click the Win32DiskImager.exe file to open the program, and click the blue folder
icon to open a file browse dialogue box.
4. Browse to the imagefilename.img file you extracted from the distribution archive,
replacing imagefilename.img with the actual name of the file extracted from the Zip archive,
and then click the Open button.
5. Select the drive letter corresponding to the SD card from the Device drop-down dialogue
box. If you’re unsure which drive letter to choose, open My Computer or Windows Explorer
to check.
6. Click the Write button to flash the image file to the SD card. This process takes a while, so
be patient!

Conclusion: We learned different types of OS and how to install n OS on Raspberry Pi

[Type text]Page 21
MC4312 Internet of Things Lab

EX.NO -1 A INTERFACING OF BASIC PERIPHERAL - LED BLINK


AIM:
To interface the basic peripherals with Audriono Uno and execute using Proteous

TOOLS REQUIRED :
● Arduino 1.8
● Proteous 8
PROCEDURE:
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno,
● Animated LED

[Type text]Page 22
MC4312 Internet of Things Lab

[Type text]Page 23
MC4312 Internet of Things Lab

STEP-3:Add a required components from the library and place in a workspace

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the LED BLINK.

PROGRAM FOR LED BLINK:

int a=10; //declaration of pin no


int b=12; //declaration of pin no
void setup()
{
pinMode(a,OUTPUT); //this is the output pin no:10
pinMode(b,OUTPUT); //this is the output pin no:12
}
void loop()

[Type text]Page 24
MC4312 Internet of Things Lab

{
//high indicate the VCC and low indicate the GROUND
digitalWrite(a,HIGH); //turn the LED on (HIGH IS THE VOLTAGE LEVEL)
delay(10); //wait a second
digitalWrite(a,LOW); //turn the LED on (LOW THE VOLTAGE LEVEL)
delay(10); //wait a second
digitalWrite(b,LOW); //this is the GROUND
}

RESULT :
Thus the interfacing of the basic peripherals with Audriono Uno was executed using Proteous

[Type text]Page 25
MC4312 Internet of Things Lab

EX.NO -1 B INTERFACING OF BASIC PERIPHERAL - ELECTRONIC COUNTER 0-9


(PUSH SWITCH & 7 SEG DISPLAY)

Aim:
To interface the basic peripherals with Audriono Uno and execute using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno,
● Animated Seven segment Display
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 26
MC4312 Internet of Things Lab

[Type text]Page 27
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the seven segment display.

PROGRAM
//The Coding:// int x0,x1,x2,x3,x4,x5,x6,x7,x8,x9;
int delay_time=200;
void setup()
{ //configure pin2 as an input and enable the internal pull-up resistor
pinMode(12, INPUT_PULLUP);
pinMode(1,OUTPUT);
pinMode(2,OUTPUT);

[Type text]Page 28
MC4312 Internet of Things Lab

pinMode(3,OUTPUT);
pinMode(4,OUTPUT);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
}
void loop() {
//read the pushbutton value into a variable
int sensorVal = digitalRead(12);

if (sensorVal == LOW) {
x0=true;
}
while(x0){
zero();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x1=true;
x0=false;
}
}
while(x1){
one();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x2=true;
x1=false;
}
}
while(x2){
two();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {

[Type text]Page 29
MC4312 Internet of Things Lab

x3=true;
x2=false;
}
}
while(x3){
three();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x4=true;
x3=false;
}
}
while(x4){
four();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x5=true;
x4=false;
}
}
while(x5){
five();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x6=true;
x5=false;
}
}
while(x6){
six();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x7=true;

[Type text]Page 30
MC4312 Internet of Things Lab

x6=false;
}
}
while(x7){
seven();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x8=true;
x7=false;
}
}
while(x8){
eight();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x9=true;
x8=false;
}
}
while(x9){
nine();
sensorVal = digitalRead(12);
if (sensorVal == LOW) {
x0=true;
x9=false;
}
}
}
void zero()
{
for(int i=1;i<7;i++)
{
digitalWrite(i,HIGH);

[Type text]Page 31
MC4312 Internet of Things Lab

digitalWrite(7,LOW);
} delay(delay_time);
}
void one()
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(delay_time);
}
void two()
{
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,LOW);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
delay(delay_time);
}
void three()
{
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,LOW);

[Type text]Page 32
MC4312 Internet of Things Lab

digitalWrite(7,HIGH);
delay(delay_time);
}
void four()
{
digitalWrite(1,LOW);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(delay_time);
}
void five()
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(delay_time);
}
void six()
{
digitalWrite(1,HIGH);
digitalWrite(2,LOW);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);

[Type text]Page 33
MC4312 Internet of Things Lab

digitalWrite(7,HIGH);
delay(delay_time);
}
void seven()
{
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,LOW);
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,LOW);
delay(delay_time);
}
void eight()
{
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,HIGH);
digitalWrite(6,HIGH);
digitalWrite(7,HIGH);
delay(delay_time);
}
void nine()
{
digitalWrite(1,HIGH);
digitalWrite(2,HIGH);
digitalWrite(3,HIGH);
digitalWrite(4,HIGH);
digitalWrite(5,LOW);
digitalWrite(6,HIGH);

[Type text]Page 34
MC4312 Internet of Things Lab

digitalWrite(7,HIGH);
delay(delay_time);
}

RESULT:
Thus the interfacing of the basic peripherals with Audriono Uno using Proteous was executed
successfully.

[Type text]Page 35
MC4312 Internet of Things Lab

EX.NO 1C(a) INTERFACING OF BASIC PERIPHERAL - SERVO MOTOR - SERVO


KNOB
Aim:
To interface servo motor with Audriono Uno and execute the servo knob modeusing Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated Seven segment Display
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 36
MC4312 Internet of Things Lab

[Type text]Page 37
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the seven segment display.

PROGRAM:
#include <Servo.h>

Servo myservo; // create servo object to control a servo


// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

[Type text]Page 38
MC4312 Internet of Things Lab

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}

RESULT:
Thus the interfacing of the basic peripherals with Audriono Uno using Proteous was executed
successfully
[Type text]Page 39
MC4312 Internet of Things Lab

EX.NO 1C (b) INTERFACING OF SERVO MOTOR - SERVO SWEEP


Aim:
To interface servo motor with Audriono Uno and execute the servo knob modeusing Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno,
● Animated Seven segment Display
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 40
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

[Type text]Page 41
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the seven segment display.

PROGRAM
#include <Servo.h>

Servo myservo; // create servo object to control a servo


// twelve servo objects can be created on most boards

int pos = 0; // variable to store the servo position

void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}

void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree

[Type text]Page 42
MC4312 Internet of Things Lab

myservo.write(pos); // tell servo to go to position in variable 'pos'


delay(15); // waits 15 ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15 ms for the servo to reach the position
}
}
/*

RESULT:
Thus the interfacing of the basic peripherals with Audriono Uno using Proteous was executed
successfully

[Type text]Page 43
MC4312 Internet of Things Lab

EX.NO 1D INTERFACING OF BASIC PERIPHERAL - STEPPER MOTOR


CONTROL - SPEED CONTROL
Aim:
To interface stepper motor with Audriono Uno and execute the servo knob modeusing
Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated Seven segment Display
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 44
MC4312 Internet of Things Lab

[Type text]Page 45
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the stepper motor.
PROGRAM

#include <Stepper.h>

const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution // for your
motor

// initialize the stepper library on pins 8 through 11:


Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

int stepCount = 0; // number of steps the motor has taken

[Type text]Page 46
MC4312 Internet of Things Lab

void setup() {
// nothing to do inside the setup
}

void loop() {
// read the sensor value:
int sensorReading = analogRead(A0);
// map it to a range from 0 to 100:
int motorSpeed = map(sensorReading, 0, 1023, 0, 100);
// set the motor speed:
if (motorSpeed > 0) {
myStepper.setSpeed(motorSpeed);
// step 1/100 of a revolution:
myStepper.step(stepsPerRevolution / 100);
}
}

RESULT:
Thus the interfacing of the basic peripherals with Audriono Uno using Proteous was executed
successfully

[Type text]Page 47
MC4312 Internet of Things Lab

EX.NO 2 EMBEDDED APPLICATIONS - GREEN HOUSE MONITORING AND


CONTROL

Aim:
To execute green house monitoring and control which is the one of the embedded applications
of audriono and execute using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno
● 10 watt t1K
● L293D
● ldr
● led-red
● led-yellow
● LM35
● motor

[Type text]Page 48
MC4312 Internet of Things Lab

● Pot-HG
● Relay
● ULN2003A.
STEP-3:Add a required components from the library and place in a workspace

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

[Type text]Page 49
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the LM35 Temperature level indicator.

PROGRAM
const int ledPin = 13;
const int lm35Pin=A4;
const int ldrPin = A0;
const int potPin=A5;
const int shadingMotorPin1=3;
const int shadingMotorPin2=2;
const int fanPin =7;
const int pumpPin=6;
const int lampPin=5;

void setup() {
Serial.begin(9600);

[Type text]Page 50
MC4312 Internet of Things Lab

pinMode(ledPin, OUTPUT);
pinMode(shadingMotorPin1, OUTPUT);
pinMode(shadingMotorPin2, OUTPUT);
pinMode(pumpPin, OUTPUT);
pinMode(fanPin, OUTPUT);
pinMode(lampPin, OUTPUT);
pinMode(ldrPin, INPUT);
pinMode(lm35Pin, INPUT);
pinMode(potPin, INPUT);
}

void loop() {

int ldrStatus = analogRead(ldrPin);


int lm35Status = analogRead(lm35Pin);
float val=(lm35Status/1024.0)*5000;
float temp=val/10;
int potStatus= analogRead(potPin);
if (temp<= 20) {

digitalWrite(lampPin, HIGH);
digitalWrite(fanPin,LOW);
Serial.print("Its COLD, Turn on the Heater : ");

Serial.print(temp);
Serial.println(" *C");

} else {

digitalWrite(lampPin, LOW);
digitalWrite(fanPin,HIGH);
Serial.print("Its HOT, Turn ON the FAN : ");
Serial.print(temp);

[Type text]Page 51
MC4312 Internet of Things Lab

Serial.println(" *C");

}
if (ldrStatus <= 500) {

digitalWrite(ledPin, LOW);
digitalWrite(shadingMotorPin1, HIGH);
digitalWrite(shadingMotorPin2, LOW);
Serial.print("Its BRIGHT, Turn off the LED : ");
Serial.println(ldrStatus);

} else {

digitalWrite(ledPin, HIGH);
digitalWrite(shadingMotorPin1, LOW);
digitalWrite(shadingMotorPin2, HIGH);
Serial.print("Its DARK, Turn on the LED : ");
Serial.println(ldrStatus);
}
if (potStatus <= 200) {
digitalWrite(pumpPin, HIGH);
Serial.print("Water level is LOW, Turn ON the Pump : ");
Serial.println(potStatus);

} else {
digitalWrite(pumpPin, LOW);
Serial.print("Water level is GOOD, Turn OFF the Pump : ");
Serial.println(potStatus);
}
delay(5000);
}

RESULT:

[Type text]Page 52
MC4312 Internet of Things Lab

Thus the green house monitoring and control which is the one of the embedded applications of
audriono and was executed sucessfully using Proteous

[Type text]Page 53
MC4312 Internet of Things Lab

EX.NO 3(i) IOT APPLICATIONS-LM 35 AUTOMATED


TEMPERATURE LEVEL INDICATOR WITH ARDUINO
Aim:
To interface LM35 with Audriono Uno and execute the temperature level indicator using
Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno,
● Animated lm35.
● Virtual Terminal
● LED Green
● LED Red

STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 54
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE

[Type text]Page 55
MC4312 Internet of Things Lab

Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate the LM35 Temperature level indicator.

PROGRAM:
int val;
int tempPin = 1;

void setup()
{
pinMode(12,OUTPUT);
pinMode(13,OUTPUT);
Serial.begin(9600);
}
void loop()
{
val = analogRead (tempPin);
float mv = (val/1024.0)*5000;
float cel = mv/10;

[Type text]Page 56
MC4312 Internet of Things Lab

Serial.print ("Temperature = ");


Serial.print (cel);
Serial.print ("*C");
Serial.println ();

if (cel<30)
{
digitalWrite (12,HIGH);
digitalWrite (13, LOW);
}
else
{
digitalWrite (13,HIGH);
digitalWrite (12, LOW);
}
delay (500);
}

RESULT :
Thus the interfacing of LM35 with Audriono Uno and the temperature level indicator using
Proteous was executed successfully.

[Type text]Page 57
MC4312 Internet of Things Lab

EX.NO 3(ii) IOT APPLICATIONS--INTERFACING LDR WITH ARDUINO


Aim:
To interface LDR with Audriono Uno and execute the LIGHT DEPENDENT RESISTOR
using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section


Components needed:
● Arduino uno,
● Animated LDR.
● Battery
● Resistor
● Diode
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 58
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

[Type text]Page 59
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate LDR.

PROGRAM:
int ldr=A0;//Set A0(Analog Input) for
LDR. int value=0;

void setup()
{ Serial.begin(9600)
;
pinMode(3,OUTPU
T);

void loop() {

value=analogRead(ldr);//Reads the Value of


LDR(light). if(value<300)
{
[Type text]Page 60
MC4312 Internet of Things Lab

digitalWrite(3,HIGH);//Makes the LED glow in Dark.

else

digitalWrite(3,LOW);//Turns the LED OFF in Light.

RESULT:
Thus the interfacing of LDR with Audriono Uno and the LIGHT DEPENDENT RESISTOR
using Proteous was executed successfully.

[Type text]Page 61
MC4312 Internet of Things Lab

EX.NO 3(iii) IOT APPLICATIONS--INTERFACING OF IR LED SENSOR

Aim:
To interface IR sensor with Audriono Uno and execute the LED sensor using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated IR sensor.
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 62
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

[Type text]Page 63
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate IR sensor.

PROGRAMS:

void setup() {

// put your setup code here, to run


once: pinMode(4,INPUT);
pinMode(12,OUTPUT);//LED

void loop() {// put your main code here, to run repeatedly:

if(digitalRead(4)==LOW)
{ digitalWrite(12,HIGH);}

else{ digitalWrite(12,LOW);}}
RESULTS:

Thus the interfacing of IR sensor with Audriono Uno and the LED sensor using Proteous
was executed successfully.

[Type text]Page 64
MC4312 Internet of Things Lab

EX.NO 3(iv) IOT APPLICATIONS-INTERFACING OF ULTRA SONIC SENSOR

Aim:
To interface ultra sonic sensor with Audriono Uno and execute the sensor using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated ultrasonic sensor sensor.
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 65
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE

[Type text]Page 66
MC4312 Internet of Things Lab

Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate IR sensor.

PROGRAM

const int pingPin = 7;

const int echoPin = 6;

void setup()

Serial.begin(9600);

void loop()

[Type text]Page 67
MC4312 Internet of Things Lab

long duration, inches, cm;

pinMode(pingPin, OUTPUT);

digitalWrite(pingPin, LOW);

delayMicroseconds(2);

digitalWrite(pingPin, HIGH);

delayMicroseconds(10);

digitalWrite(pingPin, LOW);

pinMode(echoPin, INPUT);

duration = pulseIn(echoPin, HIGH);

inches = microsecondsToInches(duration);

cm = microsecondsToCentimeters(duration);

Serial.print(inches);

Serial.print("in, ");

Serial.print(cm);

Serial.print("cm");

Serial.println();

delay(1000);

long microsecondsToInches(long microseconds)

{ return microseconds / 74 / 2;

long microsecondsToCentimeters

(long microseconds)

{ return microseconds / 29 /2

} 2; }

[Type text]Page 68
MC4312 Internet of Things Lab

RESULT:
Thus the interfacing of ultra sonic sensor with Audriono Uno and the sensor operation was
executed successfully using Proteous

[Type text]Page 69
MC4312 Internet of Things Lab

EX.NO 3(v) IOT APPLICATIONS-INTERFACING OF RELAY

Aim:
To interface relay with Audriono Uno and execute the relay using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated relay.
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 70
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file
[Type text]Page 71
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate relay.
PROGRAMS:

int a=13;

void setup() {

pinMode(a,OUTPUT);}

void loop() {

digitalWrite(a,HIGH);//RELAY WILL BE
ON delay(5000);//WAIT FOR FIVE
SECONDS

digitalWrite(a,LOW);//RELAY WILL BE OFF}

RESULT:

Thus the interfacing the relay with Audriono Uno and it was executed successfully using
Proteous

[Type text]Page 72
MC4312 Internet of Things Lab

EX.NO 3(vi) IOT APPLICATIONS-INTERFACING OF GAS SENSOR

Aim:
To interface gas sensor with Audriono Uno and execute this using Proteous
Tools Required :
● Arduino 1.8
● Proteous 8
Procedure :
STEP-1:Open PROTEUS PROFESSIONAL

STEP-2:Click>P>Enter the component in the keyword section Components needed:Arduino


uno,Animated gas sensor.
STEP-3:Add a required components from the library and place in a workspace

[Type text]Page 73
MC4312 Internet of Things Lab

STEP-4:Open Arduino IDE


Press CTRL+N and type the program>CTRL+S to save the file>CTRL+R to verify>CTRL+ALT+S
to locate .hex file

[Type text]Page 74
MC4312 Internet of Things Lab

STEP-5:Double click on Arduino>program file>place the .hex file>click OK Then click play button
on bottom to simulate relay.
PROGRAM

int gas=8;
int buzzer=10; void setup() {
pinMode(gas,INPUT); pinMode(buzzer,OUTPUT);
}
void loop() { if(digitalRead(8)==HIGH)
{digitalWrite(10,HIGH);
}
else { digitalWrite(10,LOW);
}
}
RESULT:
Thus the interfacing of gas sensor was successfully executed using Proteous.

[Type text]Page 75
MC4312 Internet of Things Lab

EX.NO 4 IOT APPLICATIONS USING DJANGO FRAMEWORK

Aim :
To write a simple script that serves a simple HTTPResponse and a simple HTML Page
Tools Required :
● Python
● Django
Procedure:
Step :1 Install Django

Step II.Django-admin startproject helloapp

Running this command creates a skeleton Django app with the following structure:

helloapp
├─helloapp
│ ├── init .py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
[Type text]Page 76
MC4312 Internet of Things Lab

└── manage.py
STEP:III

STEP IV.move to helloapp

[Type text]Page 77
MC4312 Internet of Things Lab

create your own app


python manage.py start app howdy
STEP :IV

Running this command will create an app called howdy. Your file structure should now look
something like this.
helloapp
├── helloapp
│ ├── init .py
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── howdy
│ ├── init .py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ ├── models.py
│ ├── tests.py
│ └── views.py

[Type text]Page 78
MC4312 Internet of Things Lab

└── manage.py
now open settings.py in helloapp and change installed app to
# helloapp/settings.py INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.staticfiles', 'howdy'
STEP :V

This was changed to


STEP :VI After save it.
let's run our server and see what will be output.

[Type text]Page 79
MC4312 Internet of Things Lab

python manage.py run server


STEP :VII

If you look carefully, you will see a warning that you have unapplied migrations.
STEP:VIII
Ignore that for now. Go to your browser and access http://127.0.0.1:8000/.

I. Press control+break buttons you will come out from it.


II. Migrations make it easy for you to change your database schema (model) without having to
lose any data. Any time you create a new database model, running migrations will update your
database tables to use the new schema without you having to lose any data or go through the
tedious process of dropping and recreating the database yourself.

[Type text]Page 80
MC4312 Internet of Things Lab

STEP:IX
python manage.py migrate

III. Open urls.py in helloapp


# helloapp/urls.py
from django.conf.urls import url, include from django.contrib import admin
urlpatterns = [
url(r'^admin/', admin.site.urls), url(r'^', include('howdy.urls')),
]

OUTPUT:

[Type text]Page 81
MC4312 Internet of Things Lab

This was changed to

Save it

[Type text]Page 82
MC4312 Internet of Things Lab

Now run server


python manage.py run server

ModuleNotFoundError: No Module named ‘howdy.urls’


Let's fix that. Go to the howdy app folder and create a file called urls.py. The howdy app folder
should now look like this.
├── howdy
│ ├── init .py
│ ├── admin.py
│ ├── apps.py
│ ├── migrations
│ │ ├── init .py
│ ├── models.py
│ ├── tests.py
│ ├── urls.py
│ └── views.py
Inside the new urls.py file, write this.
# howdy/urls.py
from django.conf.urls import url from howdy import views

[Type text]Page 83
MC4312 Internet of Things Lab

urlpatterns = [
url(r'^$', views.HomePageView.as_view()),
]
This code imports the views from our howdy app and expects a view called HomePageView to be
defined. Since we don't have one, open the views.py file in the howdy app and write this code.
# howdy/views.py from django.shortcuts import render from django.views.generic import
TemplateView
# Create your views here. class HomePageView(TemplateView): def get(self, request, **kwargs):
return render(request, 'index.html', context=None)
This file defines a view called Home Page View. Django views take in a request and return a
response. In our case, the method get expects a HTTP GET request to the url defined in our urls.py
file. On a side note, we could rename our method to post to handle HTTP POST requests.
Once a HTTP GET request has been received, the method renders a template called
index.html which is just a normal HTML file which could have special Django template tags written
alongside normal HTML tags. If you run the server now, you will see the following error page.

RESULT:
Thus a simple script that serves a simple HTTPResponse and a simple HTML Page was
created successfully.

[Type text]Page 84

You might also like