0% found this document useful (0 votes)
179 views30 pages

IOT Lab Manual

The document describes experiments involving interfacing devices like an LCD, switch, and stepper motor with an 8051 microcontroller. It provides code samples and explanations for displaying text on a 16x2 LCD and controlling a stepper motor based on the state of a switch.
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)
179 views30 pages

IOT Lab Manual

The document describes experiments involving interfacing devices like an LCD, switch, and stepper motor with an 8051 microcontroller. It provides code samples and explanations for displaying text on a 16x2 LCD and controlling a stepper motor based on the state of a switch.
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/ 30

Department of Mechanical Engineering

YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Sr. No Name of Experiment CO


UC-8051 based Experiments
Interfacing LCD 16x2 with 8051 and developing ‘C’ program to display
1 CO1
string on LCD.

Interfacing switch button and stepper motor with 8051 and developing
2 CO1
program to rotate it according to position of switch button.

Arduino based Experiment

Developing C language program to generate PWM signal on Arduino to


3 CO2
change intensity of light and speed of DC motor.

Developing C language program for Arduino to precisely adjust position of


4 CO3
servo motor.

Developing C program for Arduino to detect distance between object and


5 CO4
sensor.

Interfacing Bluetooth HC-05 module with Arduino and developing C


6 CO5
program to control LED using mobile App.

Uploading data on Arduino IoT cloud and monitor the status of data on cloud
7 CO6
to turn ON/OFF LED.

Subject In charge
Prof. R.K. SINGH

==================================================================================
Page 1 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

EXPERIMENT NO. 1

Title: To study 16x2 LCD and interface with 8051.

Aim: Developing C language program to print ‘APSIT’ on 16x2 LCD.

Theory: LCD (Liquid Crystal Display) screen is an electronic display module and find a wide
range of applications. A 16x2 LCD display is very basic module and is very commonly used in
various devices and circuits. A 16x2 LCD means it can display 16 characters per line and there
are 2 such lines. In this LCD each character is displayed in 5x7 pixel matrix. This LCD has two
registers, namely, Command and Data.

Commands: There are some preset commands which will do a specific task in the LCD.
These commands are very important for displaying data in LCD. The list of commands given
below:

Command Description
38H Use two lines and 5x7 matrix, 8bit data length
01H Clear the screen
0EH Display ON cursor ON
06H Increment address to move cursor to the right
80H Force cursor to bring at 1st position of 1st Line
C0H Force cursor to bring at 1st position of 2nd Line

Steps to be followed for programing


Initializing LCD
To initialize LCD using 8051 the following commands are to be given to the LCD.
0x38: is used for 8-bit data initialization.
0x0C: for making LCD display on and cursor off.
0x06: is to increment address to move cursor to the right.

Sending commands to LCD


Placing the command on the D7 – D0
RS=0; RS should be low for sending commands
E=1; enable pin should be high
Insert delay
E=0; Latch command in LCD

Writing the Data to the LCD


==================================================================================
Page 2 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Placing the command on the D7 – D0
RS=1; RS should be low for sending ASCII of character
E=1; enable pin should be high
Insert delay
E=0; Latch command in LCD

C program to display APSIT on LCD 16×2


#include<reg51.h>

sbit en = P1^0;
sbit rs = P1^2;
sbit rw = P1^1;

void delay(unsigned int time)


{ unsigned i,j ;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

void lcd_cmd(){
en = 0;
rs = 0;
en = 1;
delay(10);
en = 0;
}

void lcd_data(){
en = 0;
rs = 1;
en = 1;
delay(10);
en = 0;
}

void main(){
rw = 0;
delay(100);

==================================================================================
Page 3 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

P2 = 0x38;
lcd_cmd();

P2 = 0x06;
lcd_cmd();

P2 = 0x0E;
lcd_cmd();

P2 = 0x01;
lcd_cmd();

P2 = 'A';
lcd_data();

P2 = 'P';
lcd_data();

P2 = 'S';
lcd_data();

P2 = 'I';
lcd_data();

P2 = 'T';
lcd_data();
while(1);
}

==================================================================================
Page 4 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 1: Interfacing diagram

Conclusion: LCDs (Liquid Crystal Displays) are used for displaying status or parameters in
embedded systems. LCD 16x2 is 16 pin device which has 8 data pins (D0-D7) and 3 control
pins (RS, RW, EN). The control pins help us configure the LCD in command mode or data
mode. C program is developed to display a string on 16x2 screen.

==================================================================================
Page 5 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 2: Characters are displayed on 16x2 LCD

EXPERIMENT NO. 2

Title: Study of stepper motor and its interfacing with 8051 microcontroller.

Aim: Suppose a switch and stepper motor are interfaced with 8051. Write an C language
program which will monitor the status of Switch and perform following

a) If Switch is pressed (SW = 0), stepper motor moves clockwise


b) If switch is released (SW = 1), Stepper motor moves counterclockwise direction.

Theory: There are three basic categories of stepper motors, namely

• Permanent Magnet Stepper Motor


• Variable Reluctance Stepper Motor
==================================================================================
Page 6 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
• Hybrid Stepper Motor
The permanent magnet design motor is the most common among several types of stepper
motors.
The most common stepper motors have four stator windings that are paired with a centre tapped
common as shown in figure. This type of stepper motor is commonly referred as four phase
of unipolar stepper motors. Centre tap allows a change of current direction in each of two coils
when a winding is grounded, thereby resulting in a polarity change of the stator. Notice that
while a conventional motor shaft runs freely, the stepper motor shaft moves in a fixed
repeatable increment, which allows one to move it to a precise position. This repeatable fixed
movement is possible as a result of basic magnetic theory where poles of the same polarity
repel and opposite poles attract. The direction Configuration of the rotation is dictated by the
stator poles. The stator poles are determined by the current sent through the wire coils, As the
direction of the current is changed, the polarity is also changed causing the reverse motion of
the rotor.

Figure 1: Rotor alignment


Interfacing
Port P0 of 8051 for connecting the stepper motor. Here ULN-2003 is used. This is basically a
high voltage, high current Darlington transistor array. Each ULN2003 has seven NPN
Darlington pairs. It can provide high voltage output with common cathode clamp diodes for
switching inductive loads.

Full Drive Mode − In this mode, two coils are energized at the same time. This mode produces
more torque. Here the power consumption is also high.

==================================================================================
Page 7 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 2: Microcontroller Interfaced with 8051

Normal Four step sequence


Clockwise Steps Winding Winding Winding Winding Counter-
A B C D clockwise
1 1 0 0 1
2 1 1 0 0
3 0 1 1 0
4 0 0 1 1

==================================================================================
Page 8 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
#include<reg51.h>

sbit button = P3^0;


void delay(unsigned int time)
{ unsigned i,j ;
for(i=0;i<time;i++)
for(j=0;j<1275;j++);
}

void main(){
int i;
button = 1;

while(1){
if(button == 0){
for(i = 0; i<4; i++)
{ P1 = 0x11<<i;
delay(50);
}
}
else
{ for(i = 0; i<4; i++)
{ P1 = 0x88>>i;
delay(50);
}
}
}
}

Flow chart C Program

Conclusion:
Stepper and switch button are interfaced with microcontroller 8051. Direction of rotation of
stepper motor is controlled by switch position. Sequence of patter need to be change to change
direction of rotation.
EXPERIMENT NO. 3
==================================================================================
Page 9 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Title: Study of PWM of Arduino Uno.

Aim: Generation of PWM signal at one of the pins of Arduino Uno (ATMEGA328P) to

a) Control intensity of LED


b) Control speed of DC motor.

Theory:

Many low-cost microcontrollers have peripherals to process analog input signals, such as an
Analog-to-Digital Converter (ADC), but often do not have a Digital-to-Analog Converter
(DAC) included. most microcontrollers offer a Pulse-Width Modulation (PWM) module,
which can be combined with a low-pass filter to create an analog output. Pulse-width
modulation (PWM) is a powerful technique for controlling analog circuits with
a microcontroller's digital outputs.

PWM is commonly used to control the speed of electric motors, the brightness of lights,
in ultrasonic cleaning applications, and many more.

Some of the important terminologies PWM are given below.

• Amplitude: Amplitude of a PWM signal is usually the Vcc of the circuit.

• Period: Period is defined by the time it takes from one rising edge to the subsequent

one.

• Pulse width: Pulse width is the lapse in time between rising and falling edges of an

individual pulse.

• Duty cycle: Duty cycle is the percentage of the logic 1 pulse width, compared to the

period of the waveform.

The percentage of time for which the signal remains “ON” is known as the duty cycle. If the

signal is always “ON,” then the signal must have a 100 % duty cycle. The formula to

calculate the duty cycle is given as follows:


==================================================================================
Page 10 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 1: Different parameters of PWM waveform.

Figure 2: Interfacing of DC motor and LED with Arduino to control speed and light intensity
respectively

Implementation of PWM signal using Arduino: The Arduino's programming language makes
PWM easy to use; simply call analogWrite(pin, dutyCycle), where duty Cycle is a value from
0 to 255, and pin is one of the PWM pins (3, 5, 6, 9, 10, or 11).

The ATmega168P/328P chip has three PWM timers, controlling 6 PWM outputs. By
manipulating the chip's timer registers directly, we can obtain more control than the
analogWrite function provides.
==================================================================================
Page 11 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Arduino program to control intensity of light and speed of DC motor is given below.

#define led 9
#define motor 3
int i;
void setup()
{ Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(motor, OUTPUT);
}

void loop()
{ for(i = 0; i<256; i++){
analogWrite(led, i);
analogWrite(motor, i);
delay(30);
}

for(i = 0; i<256; i++){


analogWrite(led, 255-i);
analogWrite(motor, 255-i);
delay(30);
}
delay(1000);

Conclusion: PWM is commonly used as a way to generate an analog signal that correlates to a
digital value. In above experiment, we have generated PWM signal at two different pins of
Arduino, to control intensity of light and speed of DC motor.

EXPERIMENT NO. 4

Title: Interfacing of Servo motor with Arduino.


==================================================================================
Page 12 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Aim: Controlling position of servomotor using Arduino.

a) Sweeps the shaft of a RC servo motor back and forth across 180 degrees.
b) Move the shaft of servo motor with angle 00, 300, 600, 900, 1200, 1500 and 1800 back
and forth.

Theory:

A servo motor is a type of motor that can rotate with great precision. Normally this type of
motor consists of a control circuit that provides feedback on the current position of the motor
shaft, this feedback allows the servo motors to rotate with great precision. If we want to rotate
an object at some specific angles or distance, then we use a servo motor. It is just made up of a
simple motor which runs through a servo mechanism.

A servo motor usually comes with a gear arrangement that allows us to get a very high torque
servo motor in small and lightweight packages. Servo motor works on PWM (Pulse width
modulation) principle, means its angle of rotation is controlled by the duration of applied pulse
to its Control PIN. Servo motor can be rotated from 0 to 180 degrees.

The position sensor provides a feedback signal corresponding to the present position of the load.
This sensor is a potentiometer that produces the voltage corresponding to the absolute angle of
the motor shaft through gear mechanism. Then the feedback voltage value applies on the input
of error amplifier.
The error amplifier is a negative feedback amplifier and it reduces the difference between its
inputs. It compares the voltage related to current position of the motor with desired voltage
related to desired position of the motor. And it produces the error either a positive or negative
voltage.
This error voltage applied to the armature of the motor. If the error is more then motor armature
gets more output. The amplifier amplifies the error voltage and powers the armature. Thus motor
rotates till the error becomes zero. If the error is negative, the armature voltage reverses and hence
the armature rotates in the opposite direction.
==================================================================================
Page 13 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure-1: Interfacing of servo motor with Arduino Uno

#include <Servo.h> #include <Servo.h>


int pos = 0; int i;
Servo servo; Servo servo;

void setup() void setup()


{ servo.attach(3); { servo.attach(3);
} }

void loop() void loop()


{ for (pos = 0; pos <= 180; pos++) { { for (i = 0; i<7; i++) {
servo.write(pos); servo.write(30*i);
delay(15); delay(2000);
} }

for (pos = 0; pos >= 180; pos++) { for (i = 0; i<7; i++) {


servo.write(pos); servo.write(180 - 30*i);
delay(15); delay(2000);
} }
} }

==================================================================================
Page 14 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Code-A: Sweeps the shaft of a RC servo Code-B: Move the shaft motor with angle
0
motor back and forth across 180 . 00, 300, 600, 900, 1200, 1500 and 1800 back
and forth

Conclusion: If we want to rotate an object at some specific angles or distance, then we


use a servo motor. We have interfaced servo motor SG90 with Arduino Uno and develop
programs to rotate a rotor with specific angle.

==================================================================================
Page 15 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
EXPERIMENT NO. 5

Title: Interfacing Ultrasonic distance sensor with Arduino.

Aim: Interface Ultrasonics distance sensor, a LED with Arduino and develop C program to
turn on the LED if distance between object and sensor is more than 50 cm otherwise turn
off the LED.

Theory: The ultrasonic sensor (or transducer) works on the same principles as a radar system.
An ultrasonic sensor can convert electrical energy into acoustic waves and vice versa. The
acoustic wave signal is an ultrasonic wave traveling at a frequency above 18kHz. The famous
HC SR04 ultrasonic sensor generates ultrasonic waves at 40kHz frequency. Typically, a
microcontroller is used for communication with an ultrasonic sensor.

To begin measuring the distance, the microcontroller sends a trigger signal to the
ultrasonic sensor. The duty cycle of this trigger signal is 10µS for the HC-SR04 ultrasonic
sensor. When triggered, the ultrasonic sensor generates eight acoustic (ultrasonic) wave bursts
and initiates a time counter. As soon as the reflected (echo) signal is received, the timer stops.
The output of the ultrasonic sensor is a high pulse with the same duration as the time difference
between transmitted ultrasonic bursts and the received echo signal.

Theoretically, the distance can be calculated using the TRD (time/rate/distance)


measurement formula. By dividing this distance by 2, you can determine the actual distance
from the transducer to the object. Ultrasonic waves travel at the speed of sound (343 m/s at
20°C). The distance between the object and the sensor is half of the distance traveled by the
sound wave. The following equation calculates the distance to an object placed in front of an
ultrasonic sensor:

time taken×speed of ultrasonic sensor t×0.0343 cm/uS


Distance = =
2 2

Distance = 0.0171×t cm

==================================================================================
Page 16 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 1: HC SR-04 Ultrasonic sensor

Figure 2: Timing waveform of trigger and Eco waveform.

Figure 3: Interfacing of Ultrasonic sensor and LED with Arduino


==================================================================================
Page 17 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Program to turn ON LED if distance between object and sensor is more than 50cm otherwise
LED will be turned OFF.
#define led 3
#define trig 11
#define echo 10

float distance;
long duration;

void setup()
{ pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
Serial.begin(9600);
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}

void loop()
{ digitalWrite(trig, LOW);
delay(20);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);

duration = pulseIn(ech, HIGH);

distance = duration * 0.0171;


Serial.println(distance);

if(distance > 50)


digitalWrite(led, HIGH);
else
digitalWrite(led, LOW);

delay(1000);
}
==================================================================================
Page 18 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Conclusion: Ultrasonic Sensor works on principle of radar system. Ultrasonic sensor


generates ultrasonic pulse which are allow to fall on object. Reflected waves are captured by
sensor. Time taken by ultrasonic signal to travel distance between object and sensor is
measured by using microcontroller and distance is calculated.

==================================================================================
Page 19 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
EXPERIMENT NO. 6

Title: Controlling LEDs using Bluetooth wireless device.

Aim: Interface 2 LEDs and Bluetooth HC-05 with Arduino Uno. Pair Bluetooth HC-05 with
smart phone, and Control status of LED1 and Led2 through app.

Theory:

Bluetooth is a low cost, low power, short range wireless technology for data and voice
communication. Bluetooth was developed in the late 1990s and soon achieved massive
popularity in consumer devices. Bluetooth operates at 2.4GHz of the Radio Frequency
spectrum. It supports a data rate of up to 1Mbps and a range of approximately 30 feet. Bluetooth
enabled devices essentially contain a Bluetooth wireless radio for the transmission and
reception of data.

Bluetooth supports point-to-point (device to device) and point-to-multipoint (device to multiple


device broadcasting) wireless communication. The point-to-point communication follows the
master-slave relationship. A Bluetooth device can function as either master or slave. When a
network is formed with one Bluetooth device as master and more than one device as slaves, it
is called a Piconet. A Piconet supports a maximum of seven slave devices.

Bluetooth Module HC-05

HC-05 is a Bluetooth module which is designed for wireless communication. This module can
be used in a master or slave configuration. It has 6 pins. Description of these pins is given
below.

Pin-1 EN This pin is used to enable data mode or command mode of module.
Pin-2 VCC Connect 5 V or 3.3 V to this Pin
Pin-3 GND Ground pin of Module
Pin-4 TXD Transmit Data to which is received wirelessly.
Pin-5 RXD Receive data which is to be sent wirelessly to other Bluetooth device.
==================================================================================
Page 20 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Pin-6 State It tells whether module is connected or not.

Interfacing of HC-05 and LEDs is shown in figure 1. RXD and TXD pins of HC-05 are
interfaced with TX and RX pins of Arduino. HC-05 is power up using Vcc and GND pins.

Figure 1: Arduino Uno interfaced with HC-05 and LEDs

char inByte;
#define LED1 13;
#define LED2 12;

void setup() {
Serial.begin(9600);
pinMode(LED1, OUTPUT);
pinMode(LED2, OUTPUT);

digitalWrite(LED1, LOW);
digitalWrite(LED2, LOW);
}

void loop() {
if(Serial.available()>0)
{ inByte = Serial.read();

==================================================================================
Page 21 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
switch(inByte){
case 'a' : digitalWrite(LED1, HIGH); break;
case 'b' : digitalWrite(LED1, LOW); break;
case 'c' : digitalWrite(LED2, HIGH); break;
case 'd' : digitalWrite(LED2, LOW); break;
}
}
}
Program to Control LEDs via Bluetooth

Steps to Perform the experiment

1) Upload Arduino Sketch in Arduino Uno Board.


2) Interface HC-05 and LEDs with Arduino Uno as per shown in figure.
3) Install “Arduino Bluetooth Home Automation” app in smart phone.
4) Pair HC-05 with Smart phone.
5) Open Arduino Bluetooth Home Automation app on smart phone
6) Connect Bluetooth with HC-05 module.
7) Press control button of the app to change the status of LEDs.

Conclusion: HC-05 Bluetooth module and LEDs are interfaced with Arduino. HC-05 is paired
with smart phone and data is transmitted to Arduino via Bluetooth. LEDs are turned ON and
OFF through android app.

==================================================================================
Page 22 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
EXPERIMENT NO. 7

Title: Data logging and device controlling using Arduino IoT cloud.

Aim: a) Uploading Temperature and Humidity of surrounding environment on to the Arduino


IoT cloud using ESP-8266 NodeMCU
b) Controlling status of LED over internet using Arduino IoT cloud and NodeMCU.

Theory:
The Arduino IoT Cloud is an online platform that makes it easy to create, deploy and
monitor IoT projects. Connected devices around the world are increasing by billions every
year. The Arduino IoT Cloud is a platform that allows anyone to create IoT projects, with
a user-friendly interface, and an all-in-one solution for configuration, writing code,
uploading and visualization.
Below is a list of Arduino IoT Cloud features.
Data Monitoring – We can easily monitor data through dashboard.
Variable Synchronisation – Variable synchronisation allows to sync variables across
devices, enabling communication between devices with minimal coding.
Scheduler - schedule jobs to go on/off for a specific amount of time (seconds, minutes,
hours).
Webhooks - integrate your project with another service, such as IFTTT.
Dashboard Sharing - share the data with other people around the world.
To use the Arduino IoT Cloud, a cloud compatible board is required. You can choose
between using an official Arduino board, or a board based on the ESP32 / ESP8266
microcontroller. The Arduino IoT Cloud currently supports connection via Wi-Fi (via The
Things Network) and mobile networks.

==================================================================================
Page 23 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

ESP8266
The Arduino IoT Cloud supports a wide range of third-party boards based on the ESP32 and
ESP8266 microcontrollers with support for Wi-Fi. To set them up, simply choose the third-
party option in the device setup.
Setting up the Arduino IoT Cloud and accessing the different features available involves a
few simple steps.
1. Creating an Arduino Account
To starting using the Arduino IoT cloud, we first need to log in or sign up to Arduino. Link
is https://create.arduino.cc/iot/. After we have signed up, you can access the Arduino IoT
Cloud from any page on arduino.cc by clicking on the four dots menu in the top right
corner.
2. Creating a Thing
The journey always begins by creating a new Thing. In the Thing overview, we can choose
what device to use, what Wi-Fi network we want to connect to, and create variables that we
can monitor and control. This is the main configuration space, where all changes we make
are automatically generated into a special sketch file.

Figure 1: The Thing overview.

==================================================================================
Page 24 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 2: Configuring a device.

3. Configuring a Device
Devices can easily be added and linked to a Thing. The Arduino IoT Cloud requires computer
to have the Arduino Agent installed. We can choose from any board that has been configured,
or select the “Configure new device” option. Here we can manage and add new devices.

4. Creating Variables
The variables we create are automatically generated into a sketch file. There are several data
types we can choose from, such as int, float, boolean, long, char. When clicking on
the “Add variable” button, we can choose name, data type, update setting and interaction
mode.

Figure 3: Creating variables.

==================================================================================
Page 25 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

5. Connecting to a Network
To connect to a Wi-Fi network, simply click the “Configure” button in the network
section. Enter the credentials and click “Save”. This information is also generated into your
sketch file!

Figure 4: Entering network credentials.

6. Editing the Sketch


Now that we have configured variables, devices and network settings, we can get to
programming our devices!

An automatically generated sketch file can be found in the “Sketch” tab. It has the same
structure as a typical *.ino file, but with some additional code to make the connection to your
network and to the cloud. A sketch that, for example, reads an analog sensor, and use the cloud
variable to store it. When the sketch has been uploaded, it will work as a regular sketch, but
it will also update the cloud variables that we use! Additionally, each time we create a variable
that has the Read & Write permission enabled, a function is also generated, at the bottom of
sketch file. Each time this variable changes, it will execute the code within this function! This
means that we can leave most of the code out of the loop() and only run code when needed.

To upload the program to our board, simply click the "Upload" button.

==================================================================================
Page 26 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 5: The Serial Monitor Tool.


After we have successfully uploaded the code, we can open the “Serial Monitor” tab to view
information regarding our connection.
7. Creating a Dashboard
In this way we can configured the device & network, created variables, completed the sketch
and successfully uploaded the code, we can move on to the fun part: creating dashboards!
Dashboards are visual user interface for interacting with your boards over the cloud, and we
can setup many different setups depending on what your IoT project needs. We can access
our dashboards by clicking on the “Dashboards” tab at the top of the Arduino IoT Cloud
interface, where we can create new dashboards, and see a list of dashboards created for other
Things.

If we click on “Create new dashboard”, we enter a dashboard editor. Here, we can create
something called widgets. Widgets are the visual representation of our variables we create,
and there are many different to choose from. Below is an example using several types of
widgets.

==================================================================================
Page 27 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================

Figure 6: The different widgets available.


When we create widgets, we also need to link them to our variables. This is done by
clicking on a widget we create, select a Thing, and select a variable that we want to link.
Once it is linked, we can either interact with it, for example a button, or we can monitor a
value from a sensor. As long as our board is connected to the cloud, the values will update!

This is how IoT platform is created on Arduino IoT cloud.

Figure 7: DHT11 and LED are interfaced with ESP-8266 NodeMCU

==================================================================================
Page 28 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
#include "DHT.h"
#define DHTPIN D3
#define DHTTYPE DHT11 void onLedChange() {
DHT dht(DHTPIN, DHTTYPE);
if(led == true)
void setup() { { digitalWrite(D0, LOW);
Serial.begin(9600);
Serial.println(F("DHT11 test!")); }
dht.begin();
} else
{ digitalWrite(D0, HIGH);
void loop() {
float h, t; }
delay(2000);
h = dht.readHumidity(); }
t = dht.readTemperature();
if (isnan(h) || isnan(t)) {
Serial.println(F("Failed to read Data!"));
return;
}
Serial.print(F("Humidity: "));
Serial.print(h);
Serial.print(F("% Temperature: "));
Serial.print(t);
Serial.println(F("C "));
}

Program to read data from DHT-11 which Subroutine to change status of LED
is to be incorporated in sketch of cloud using switch of dashboard.

Figure 8: Dashboard of Arduino Cloud IoT

==================================================================================
Page 29 of 30
Prof. R.K. SINGH
Department of Mechanical Engineering
YEAR: 2023-24
COURSE NAME: MEL-802 Laboratory Based on IoT
Class: BE MECH SEM:VIII
=================================================================
Conclusion: We successfully upload the data on cloud and could fetch from cloud. In first part
of the experiment, we have sent Temperature and humidity data on Arduino IoT cloud and
observed on Dashboard. Whereas in second part of the experiment, we have switched ON and
Switch of the LED using switch button on dashboard via internet.

==================================================================================
Page 30 of 30
Prof. R.K. SINGH

You might also like