IOT lab MANUAL
IOT lab MANUAL
Bhopal
“Internet of Things”
SEMESTER –VIII
ORIENTAL COLLEGE OF TECHNOLOGY, BHOPAL
LIST OF EXPERIMENTS
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.
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.
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
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.
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
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(h);
Serial.print(t);
Serial.print(F("°C "));
Serial.print(f);
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)
{
else
{
}
LAB ASSIGNMENT -6
oled-temp-humid-meter.ino
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Wire.begin();
void setup() {
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
am2320.begin();
void displayTempHumid(){
delay(2000);
// Read Humidity
float h = am2320.readHumidity();
float t = am2320.readTemperature();
display.clearDisplay();
//Set the color - always use white despite actual display color
display.setTextColor(WHITE);
display.setTextSize(1);
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.
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
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)) {
return;
Serial.print("Humidity: ");
Serial.print(h);
Serial.print(" %\t");
Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" *C ");
Serial.print(hic);
Serial.print(" *C ");}
LAB ASSIGNMENT -8
/*
* 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
}