0% found this document useful (0 votes)
0 views

IOT lab MANUAL

The document is a lab manual for the Internet of Things course at Oriental College of Technology, Bhopal, detailing various experiments involving Arduino and Raspberry Pi. It includes instructions for interfacing different components such as LEDs, sensors, and Bluetooth modules, along with example code for each experiment. The manual serves as a practical guide for students to learn about IoT applications and programming.

Uploaded by

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

IOT lab MANUAL

The document is a lab manual for the Internet of Things course at Oriental College of Technology, Bhopal, detailing various experiments involving Arduino and Raspberry Pi. It includes instructions for interfacing different components such as LEDs, sensors, and Bluetooth modules, along with example code for each experiment. The manual serves as a practical guide for students to learn about IoT applications and programming.

Uploaded by

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

Oriental College of Technology,

Bhopal

LAB MANUAL (CD-804)

“Internet of Things”

BACHELOR OF TECHNOLOGY (B.TECH.) COURSE

SEMESTER –VIII
ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL

DEPARTMENT OF CSE (Data Science)

LIST OF EXPERIMENTS

S. No Name of Experiment Course


Outcome

Familiarization with Arduino/Raspberry Pi and perform necessary


1
software installation. CO4

To interface LED/Buzzer with Arduino/Raspberry Pi and write a


2 CO4
program to turn ON LED for 1 sec after every 2 seconds

To interface Push button/Digital sensor (IR/LDR) with


3
Arduino/Raspberry Pi and write a program to turn ON LED when push
CO4
button is pressed or at sensor detection.

To interface DHT11 sensor with Arduino/Raspberry Pi and write a


4
program to print temperature and humidity readings. CO5

To interface motor using relay with Arduino/Raspberry Pi and write a


5
program to turn ON motor when push button is pressed. CO3

To interface OLED with Arduino/Raspberry Pi and write a program to


6 CO4
print temperature and humidity readings on it.

To interface Bluetooth with Arduino/Raspberry Pi and write a program


7 CO5
to send sensor data to smartphone using Bluetooth.

To interface Bluetooth with Arduino/Raspberry Pi and write a program


8
to turn LED ON/OFF when ‘1’/’0’ is received from smartphone using
Bluetooth. CO5
EXPERIMENT -1

Familiarization with Arduino/Raspberry Pi and perform necessary software installation.

Step 1 − First you must have your Arduino board (you can choose your favorite board) and a
USB cable. In case you use Arduino UNO, Arduino Duemilanove, Nano, Arduino Mega 2560,
or Diecimila, you will need a standard USB cable (A plug to B plug), the kind you would connect
to a USB printer as shown in the following image.

In case you use Arduino Nano, you will need an A to Mini-B cable instead as shown in the
following image.

Step 2 − Download Arduino IDE Software.


You can get different versions of Arduino IDE from the Download page on the Arduino Official
website. You must select your software, which is compatible with your operating system
(Windows, IOS, or Linux). After your file download is complete, unzip the file.
Step 3 − Power up your board.
The Arduino Uno, Mega, Duemilanove and Arduino Nano automatically draw power from either,
the USB connection to the computer or an external power supply. If you are using an Arduino
Diecimila, you have to make sure that the board is configured to draw power from the USB
connection. The power source is selected with a jumper, a small piece of plastic that fits onto two
of the three pins between the USB and power jacks. Check that it is on the two pins closest to the
USB port.
Connect the Arduino board to your computer using the USB cable. The green power LED (labeled
PWR) should glow.
Step 4 − Launch Arduino IDE.
After your Arduino IDE software is downloaded, you need to unzip the folder. Inside the folder,
you can find the application icon with an infinity label (application.exe). Double-click the icon to
start the IDE.
Step 5 − Open your first project.
Once the software starts, you have two options −

 Create a new project.


 Open an existing project example.
To create a new project, select File → New.
To open an existing project example, select File → Example → Basics → Blink.

Here, we are selecting just one of the examples with the name Blink. It turns the LED on and off
with some time delay. You can select any other example from the list.
Step 6 − Select your Arduino board.
To avoid any error while uploading your program to the board, you must select the correct
Arduino board name, which matches with the board connected to your computer.
Go to Tools → Board and select your board.
Here, we have selected Arduino Uno board according to our tutorial, but you must select the name
matching the board that you are using.
Step 7 − Select your serial port.
Select the serial device of the Arduino board. Go to Tools → Serial Port menu. This is likely to
be COM3 or higher (COM1 and COM2 are usually reserved for hardware serial ports). To find
out, you can disconnect your Arduino board and re-open the menu, the entry that disappears
should be of the Arduino board. Reconnect the board and select that serial port.
Step 8 − Upload the program to your board.
Before explaining how we can upload our program to the board, we must demonstrate the function
of each symbol appearing in the Arduino IDE toolbar.
A − Used to check if there is any compilation error.
B − Used to upload a program to the Arduino board.
C − Shortcut used to create a new sketch.
D − Used to directly open one of the example sketch.
E − Used to save your sketch.
F − Serial monitor used to receive serial data from the board and send the serial data to the board.
Now, simply click the "Upload" button in the environment. Wait a few seconds; you will see the
RX and TX LEDs on the board, flashing. If the upload is successful, the message "Done
uploading" will appear in the status bar.
Note − If you have an Arduino Mini, NG, or other board, you need to press the reset button
physically on the board, immediately before clicking the upload button on the Arduino Software.

Install Raspberry Pi Desktop on your PC or Mac


1. Introduction.
2. Download Raspberry Pi Desktop.
3. Create a USB drive installer.
4. Boot from the USB drive.
5. Install Raspberry Pi Desktop.
6. Start up Raspbery Pi Desktop.
LAB ASSIGNMENT -2

To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to turn ON LED


for 1 sec after every 2 seconds.

void setup()
{
// initialize digital pin LED_BUILTIN as an output.
pinMode(LED_BUILTIN, OUTPUT);
}
// the loop function runs over and over again forever

void loop()
{
digitalWrite (LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second (1 sec = 1000ms)
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second (1 sec = 1000ms)
}
LAB ASSIGNMENT -3

To interface Push button/Digital sensor (IR/LDR) with Arduino/Raspberry Pi and write a


program to turn ON LED when push button is pressed or at sensor detection.

Push Button is simplest of devices and it is the basic input device that can be connected to any
controller or processor like Arduino or Raspberry Pi.A push button in its simplest form consists
of four terminals. In that, terminals 1 and 2 are internally connected with each other and so are
terminals 3 and 4. So, even though you have four terminals, technically, you have only two
terminals to use.

The above image shows a simple pushbutton and also highlights the internal connection.

const int BUTTON = 2;


const int LED = 3;
int BUTTONstate = 0;

void setup()
{
pinMode(BUTTON, INPUT);
pinMode(LED, OUTPUT);
}

void loop()
{
BUTTONstate = digitalRead(BUTTON);
if (BUTTONstate == HIGH)
{
digitalWrite(LED, HIGH);
}
else{
digitalWrite(LED, LOW);
}
}
LAB ASSIGNMENT -4

To interface DHT11 sensor with Arduino/Raspberry Pi and write a program to print


temperature and humidity readings.

The following is the circuit diagram of the DHT11 and Raspberry Pi Interface.

Components Required
 Raspberry Pi 3 Model B
 DHT11 Temperature and Humidity Sensor
 Connecting Wires
 Power Supply
 Computer

void setup()

Serial.begin(9600);

Serial.println(F("DHTxx test!"));

dht.begin();

Serial.print(F(" Humidity: "));

Serial.print(h);

Serial.print(F("% Temperature: "));

Serial.print(t);

Serial.print(F("°C "));

Serial.print(f);

Serial.print(F("°F Heat index: "));

Serial.print(hic);

Serial.print(F("°C "));

Serial.print(hif);

Serial.println(F("°F"));
LAB ASSIGNMENT -5

To interface motor using relay with Arduino/Raspberry Pi and write a program to turn
ON motor when push button is pressed.

Microcontrollers are the heart of embedded systems. There are various types of embedded systems
for different applications. The applications of embedded systems range from controlling small DC
motors to use in industrial automation. When it comes to controlling high voltage devices,
microcontrollers often depend on Relays to drive them. Relays act as a bridge between the low
power microcontrollers and high voltage devices.

Circuit Diagram

Components

 Arduino UNO
 Relay
 1N4007 PN Junction Diode
 2N2222 NPN Transistor
 1KΩ Resistor
 Push button
 Prototyping board
 Power supply – 5V and 12V
 Connecting wires
const int buttonPin = 12;
const int transistorPin = 7;

int buttonState = 0;

void setup()
{

pinMode(buttonPin, INPUT_PULLUP);
pinMode transistorPin, OUTPUT);

void loop()
{

buttonState = digitalRead(buttonPin);

if (buttonState == LOW)
{

digitalWrite (transistorPin, HIGH);

else
{

digitalWrite (transistorPin, LOW);

}
LAB ASSIGNMENT -6

To interface OLED with Arduino/Raspberry Pi and write a program to print temperature


and humidity readings on it.

OLED Temperature and Humidity Meter

oled-temp-humid-meter.ino

Displays results on 128 x 64 OLED display

Uses AM2320 I2C Temperature and Humidity sensor

Uses Adafruit SSD1306 OLED Library

Uses Adafruit AM2320 Library

Uses Adafruit GFX Graphics Library

// Include Wire Library for I2C

#include <Wire.h>

// Include Adafruit Graphics & OLED libraries

#include <Adafruit_GFX.h>

#include <Adafruit_SSD1306.h>

// Include Adafruit AM2320 Temp Humid Library


#include <Adafruit_AM2320.h>

// Reset pin not used but needed for library

#define OLED_RESET 4

Adafruit_SSD1306 display(OLED_RESET);

// Define object am2320

Adafruit_AM2320 am2320 = Adafruit_AM2320();

void setup() {

// Start Wire library for I2C

Wire.begin();

void setup() {

// initialize OLED with I2C addr 0x3C

display.begin(SSD1306_SWITCHCAPVCC, 0x3C);

// Initialize Temp & Humid Sensor

am2320.begin();

void displayTempHumid(){

// Delay to allow sensor to stabalize

delay(2000);

// Read Humidity

float h = am2320.readHumidity();

// Read temperature as Celsius

float t = am2320.readTemperature();

// Clear the display

display.clearDisplay();

//Set the color - always use white despite actual display color
display.setTextColor(WHITE);

//Set the font size

display.setTextSize(1);

//Set the cursor coordinates

display.setCursor(0,0);

display.print("DroneBot Workshop");

display.setCursor(0,10);

display.print("Humidity: ");

display.print(h);

display.print(" %");

display.setCursor(0,20);

display.print("Temperature: ");

display.print(t);

display.print(" C");

void loop() {

displayTempHumid();

display.display();

}
LAB ASSIGNMENT -7

To interface Bluetooth with Arduino/Raspberry Pi and write a program to send sensor data
to smartphone using Bluetooth.

Connecting The DHT-11 Sensor

To use the DHT-11, the DHT library by Adafruit is used. Go here to download the library. When
the letter “t” is received, the temperature, humidity, and heat index will be transmitted back via
Bluetooth.

#include "DHT.h"

#define DHTPIN 2

#define DHTTYPE DHT11

DHT dht(DHTPIN, DHTTYPE);

void setup() {

Serial.begin(9600);

dht.begin();}

void loop()
{ char c;

if(Serial.available())

c = Serial.read();

if(c=='t')

readSensor();

}}

void readSensor() {

float h = dht.readHumidity();

float t = dht.readTemperature();

if (isnan(h) || isnan(t)) {

Serial.println("Failed to read from DHT sensor!");

return;

float hic = dht.computeHeatIndex(t, h, false);

Serial.print("Humidity: ");

Serial.print(h);

Serial.print(" %\t");

Serial.print("Temperature: ");

Serial.print(t);

Serial.print(" *C ");

Serial.print("Heat index: ");

Serial.print(hic);

Serial.print(" *C ");}
LAB ASSIGNMENT -8

To interface Bluetooth with Arduino/Raspberry Pi and write a program to turn LED


ON/OFF when ‘1’/’0’ is received from smartphone using Bluetooth.

Arduino Pins Bluetooth Pins


RX (Pin 0) ———-> TX
TX (Pin 1) ———-> RX
5V ———-> VCC
GND ———-> GND
Connect a LED negative to GND of Arduino and positive to pin 13 with a resistance valued
between 220Ω – 1KΩ. And you're done with the circuit

/*
* Bluetooh Basic: LED ON OFF - Avishkar
* Coder - Mayoogh Girish
* Website - http://bit.do/Avishkar
* Download the App :
* This program lets you to control a LED on pin 13 of arduino using a bluetooth module
*/
char Incoming_value = 0; //Variable for storing Incoming_value
void setup()
{
Serial.begin(9600); //Sets the data rate in bits per second (baud) for serial data
transmission
pinMode(13, OUTPUT); //Sets digital pin 13 as output pin
}
void loop()
{
if(Serial.available() > 0)
{
Incoming_value = Serial.read(); //Read the incoming data and store it into variable
Incoming_value
Serial.print(Incoming_value); //Print Value of Incoming_value in Serial monitor
Serial.print("\n"); //New line
if(Incoming_value == '1') //Checks whether value of Incoming_value is equal to 1
digitalWrite(13, HIGH); //If value is 1 then LED turns ON
else if(Incoming_value == '0') //Checks whether value of Incoming_value is equal to 0
digitalWrite(13, LOW); //If value is 0 then LED turns OFF
}

You might also like