Mc4312-Iot Lab Manual
Mc4312-Iot Lab Manual
LAB MANUAL
(2021 Regulation)
Prepared by
S.KEERTHANA.,M.E
AP/EEE
G.SANDRA KARUNYA.,M.E
AP/CSE
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.
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.
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.
The Raspberry Pi Foundation has just recently released a new model, the Raspberry Pi
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 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.
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
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
• 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
• 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
Benchmark:
Beagle Board
Another familiar, common designation on the web for the BeagleBone Black is BBB.
Dept of MCA, SMITPage 10
MC4312 Internet of Things Lab
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
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
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.
What is a Microcontroller
● Cellphones,
● Toys
● Household appliances
● Cars
● Cameras
●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
Aim:
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.
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.
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
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:
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!
[Type text]Page 21
MC4312 Internet of Things Lab
TOOLS REQUIRED :
● Arduino 1.8
● Proteous 8
PROCEDURE:
STEP-1:Open PROTEUS PROFESSIONAL
[Type text]Page 22
MC4312 Internet of Things Lab
[Type text]Page 23
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 LED BLINK.
[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
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
[Type text]Page 26
MC4312 Internet of Things Lab
[Type text]Page 27
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
//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
[Type text]Page 36
MC4312 Internet of Things Lab
[Type text]Page 37
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>
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
[Type text]Page 40
MC4312 Internet of Things Lab
[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>
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
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
[Type text]Page 44
MC4312 Internet of Things Lab
[Type text]Page 45
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 stepper motor.
PROGRAM
#include <Stepper.h>
const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution // for your
motor
[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
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
[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
[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() {
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
[Type text]Page 54
MC4312 Internet of Things Lab
[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
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
[Type text]Page 58
MC4312 Internet of Things Lab
[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() {
else
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
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
[Type text]Page 62
MC4312 Internet of Things Lab
[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() {
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
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
[Type text]Page 65
MC4312 Internet of Things Lab
[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
void setup()
Serial.begin(9600);
void loop()
[Type text]Page 67
MC4312 Internet of Things Lab
pinMode(pingPin, OUTPUT);
digitalWrite(pingPin, LOW);
delayMicroseconds(2);
digitalWrite(pingPin, HIGH);
delayMicroseconds(10);
digitalWrite(pingPin, LOW);
pinMode(echoPin, INPUT);
inches = microsecondsToInches(duration);
cm = microsecondsToCentimeters(duration);
Serial.print(inches);
Serial.print("in, ");
Serial.print(cm);
Serial.print("cm");
Serial.println();
delay(1000);
{ 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
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
[Type text]Page 70
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
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
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
[Type text]Page 73
MC4312 Internet of Things Lab
[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
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
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
[Type text]Page 77
MC4312 Internet of Things Lab
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
[Type text]Page 79
MC4312 Internet of Things Lab
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/.
[Type text]Page 80
MC4312 Internet of Things Lab
STEP:IX
python manage.py migrate
OUTPUT:
[Type text]Page 81
MC4312 Internet of Things Lab
Save it
[Type text]Page 82
MC4312 Internet of Things Lab
[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