Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
27 views51 pages

IoT Manual-1

Uploaded by

Sachin Pardeshi
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)
27 views51 pages

IoT Manual-1

Uploaded by

Sachin Pardeshi
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/ 51

RCPIT, Shirpur Department of Electrical Engineering

(Affiliated to DBATU, Lonere, and M. S.)

Department of Electrical Engineering


IoT and Its Applications in Electrical
Engineering Laboratory
(PEEE5052L)
T.Y. B. Tech (Electrical)
[SEM-V]
Shahada Road, Near Nimzari Naka, Shirpur, Maharashtra 425405 Ph: 02563 259802,
Web: www.rcpit.ac.in

IoT and Its Applications in Electrical Engineering Laboratory Page 1


RCPIT, Shirpur Department of Electrical Engineering

The Shirpur Education Society’s


R. C. Patel Institute of Technology, Shirpur

CERTIFICATE
This is to certify that Mr / Miss ________________________________of Third
Year Electrical Engineering branch, Roll No. ______has performed practical work
satisfactorily in the Subject IoT and Its Applications in Electrical Engineering
Laboratory (PEEE5052L), in the premises of the Department of Electrical
Engineering during the academic year 20 - 20

Date: / / 20
Place: Shirpur

Signature of the Teacher Head of Department

IoT and Its Applications in Electrical Engineering Laboratory Page 2


RCPIT, Shirpur Department of Electrical Engineering

Table of Contents
Exp.
Title P. No. Date Sign
No.
Perform any 10 experiments from the following list of experiments

1 Study and Install IDE of Arduino and different types of Arduino.

2 Write program using Arduino IDE for Blink LED.

Write program to monitor temperature and humidity using


3
Arduino.

4 Design of digital dc voltmeter and ammeter.

5 Design of digital ac voltmeter and ammeter.

6 Measurement of power and energy.

7 Traffic signal control.

8 Railway gate control by stepper motors.

9 Direction and Speed control of DC motor.

Reading sensor data and sending it to cloud platform for


10
temperature and humidity sensor.

IoT and Its Applications in Electrical Engineering Laboratory Page 3


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 4


RCPIT, Shirpur Department of Electrical Engineering

Experiment 1

Aim: Study and Install IDE of Arduino and different types of Arduino.
Theory:
Arduino is a prototype platform (open-source) based on an easy-to-use hardware and software. It
consists of a circuit board, which can be programed (referred to as a microcontroller) and a ready-
made software called Arduino IDE (Integrated Development Environment), which is used to write
and upload the computer code to the physical board.
The key features are:
• Arduino boards are able to read analog or digital input signals from different sensors and turn it
into an output such as activating a motor, turning LED on/off, connect to the cloud and many
other actions.
• You can control your board functions by sending a set of instructions to the microcontroller on
the board via Arduino IDE (referred to as uploading software).
• Unlike most previous programmable circuit boards, Arduino does not need an extra piece of
hardware (called a programmer) in order to load a new code onto the board. You can simply
use a USB cable.
• Additionally, the Arduino IDE uses a simplified version of C++, making it easier to learn to
program.
• Finally, Arduino provides a standard form factor that breaks the functions of the
microcontroller into a more accessible package.

Board Types
Various kinds of Arduino boards are available depending on different microcontrollers used.
However, all Arduino boards have one thing in common: they are programed through the Arduino
IDE.
The differences are based on the number of inputs and outputs (the number of sensors, LEDs, and
buttons you can use on a single board), speed, operating voltage, form factor etc. Some boards are
designed to be embedded and have no programming interface (hardware), which you would need
to buy separately. Some can run directly from a 3.7V battery, others need at least 5V.
Here is a list of different Arduino boards available.

IoT and Its Applications in Electrical Engineering Laboratory Page 5


RCPIT, Shirpur Department of Electrical Engineering

Arduino boards based on ATMEGA328 microcontroller

Operating Clock Digital Analog Programming


Board Name PWM UART
Volt Speed i/o Inputs Interface

USB via
Arduino Uno R3 5V 16MHz 14 6 6 1
ATMega16U2

Arduino Uno R3 USB via


5V 16MHz 14 6 6 1
SMD ATMega16U2

Red Board 5V 16MHz 14 6 6 1 USB via FTDI

Arduino Pro 3.3v/8 FTDI-Compatible


3.3V 8MHz 14 6 6 1
MHz Header

Arduino Pro FTDI-Compatible


5V 16MHz 14 6 6 1
5V/16MHz Header

FTDI-Compatible
Arduino mini 05 5V 16MHz 14 8 6 1
Header

Arduino Pro mini FTDI-Compatible


3.3V 8MHz 14 8 6 1
3.3v/8mhz Header

Arduino Pro mini FTDI-Compatible


5V 16MHz 14 8 6 1
5v/16mhz Header

FTDI-Compatible
Arduino Ethernet 5V 16MHz 14 6 6 1
Header

FTDI-Compatible
Arduino Fio 3.3V 8MHz 14 8 6 1
Header

LilyPad Arduino FTDI-Compatible


3.3V 8MHz 14 6 6 1
328 main board Header

LilyPad Arduino FTDI-Compatible


3.3V 8MHz 9 4 5 0
simple board Header

ARDUINO – 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.

IoT and Its Applications in Electrical Engineering Laboratory Page 6


RCPIT, Shirpur Department of Electrical Engineering

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(https://www.arduino.cc/en/software) 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.

IoT and Its Applications in Electrical Engineering Laboratory Page 7


RCPIT, Shirpur Department of Electrical Engineering

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

IoT and Its Applications in Electrical Engineering Laboratory Page 8


RCPIT, Shirpur Department of Electrical Engineering

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.

IoT and Its Applications in Electrical Engineering Laboratory Page 9


RCPIT, Shirpur Department of Electrical Engineering

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.

IoT and Its Applications in Electrical Engineering Laboratory Page 10


RCPIT, Shirpur Department of Electrical Engineering

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.

IoT and Its Applications in Electrical Engineering Laboratory Page 11


RCPIT, Shirpur Department of Electrical Engineering

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.

Types of Arduino Boards

Arduino UNO R3

Arduino Uno is the most popular and widely used development board. It is powered by
an ATMega328P microcontroller. It is the most popular choice among the community because
it’s, cheap, easy to learn and use, and also a variety of premade modules are available for this which
makes it easier for developing new projects or prototypes. It consists of 14Digital I/O out of which
IoT and Its Applications in Electrical Engineering Laboratory Page 12
RCPIT, Shirpur Department of Electrical Engineering

6 pins are 8bit PWM pins, 6 pins are10-bit Analog inputs, and basic communication ports like SPI,
I2C, and UART.
Now, there are many different types of Arduino UNO boards available across the global market,
but most of these boards are the clone or copy version of the original UNO board that you see
above. Hence the color or the appearance of the board might be different than what is shown above.
Arduino Nano

Arduino Nano is a small breadboard-friendly version of Arduino UNO. It has more or less
functionality of the Arduino UNO but in a small form factor. The only major differences from UNO
are the lack of a DC power jack, the usage of a Mini USB port instead of a USB B port, and the
USB-TTL converter chip. Nano uses an FT232, a dedicated USB-UART bridge chip from FTDI
instead of an ATMega16U2. It is also a very popular choice among the developers just like UNO
because of its small size and cheap price.

Arduino PRO Mini

IoT and Its Applications in Electrical Engineering Laboratory Page 13


RCPIT, Shirpur Department of Electrical Engineering

Pro mini is actually a cut-down version of Nano. It has most of the functionalities similar to
Arduino Nano but it lacks the onboard USB -TTL bridge and the USB port. Instead, it has a header,
in which the UART pins are brought out. We can use these pins to program the Pro mini using an
external USB-UART module. This board is specially meant for applications where the space is
limited. Pro mini is available in two versions, 3.3V, and 5v versions. In the 3.3V version, the CPU
speed is limited to 8MHz because of certain limitations of ATMega328 for better stability.

Arduino Leonardo

Arduino Leonardo is powered by an ATmega32U4 chip rather than the ATMega328P chip
which is used in all the previously mentioned boards. It has more IO pins (20) and more
PWM (7) and analog input (12) pins. One other major difference is that the ATMega32U4
has built-in USB communication eliminating the need for a second processor or a
dedicated USB to UART bridge chip. This allows the board to connect to a computer as a
Human Interface Device (HID) or as a Virtual (CDC) serial / COM port. We use
this Virtual COM port along with the bootloader to program the Leonardo.

Arduino Micro

IoT and Its Applications in Electrical Engineering Laboratory Page 14


RCPIT, Shirpur Department of Electrical Engineering

Just like Arduino Nano is a UNO in a small form factor, Arduino Micro is actually a Leonardo in a
small form-factor breadboard-friendly sized board. Its functionalities are the same as the Arduino
Leonardo. The only difference is the lack of a DC input jack. Similarly, Arduino Micro can also act
as an HID or Virtual COM port device.

Arduino Nano Every

Arduino Nano Every is a new generation board in a small form factor. As we already
discussed Arduino Nano is the preferred board for many projects requiring a small and
cheap solution. We could call the Arduino Nano Every, an upgraded Arduino Nano with
lot more features. Nano Every is powered by a more powerful processor ATMega4809. It
has 50% more program memory and a 200% bigger RAM which will enable us to muse this
board for bigger programs. The castellated holes allow us to use the Nano Every on a PCB
without the need for the header pins.

Arduino Mega2560 Rev3

Arduino Mega 2560 is the biggest of all the boards we have discussed so far. It is designed
for applications where a lot of I/O or peripherals are needed. It is powered by a bigger and
more capable processor the ATMega2560. This board has the greatest number of I/O than

IoT and Its Applications in Electrical Engineering Laboratory Page 15


RCPIT, Shirpur Department of Electrical Engineering

most other boards, 54 I/O pins (of which 15 can be used as PWM outputs), 16 analog inputs,
and 4 UARTs. It has more flash storage and SRAM than most other basic Arduino boards. It
is most popular with the opensource CNC and 3D printer community as well as the
opensource PLC community.

IoT and Its Applications in Electrical Engineering Laboratory Page 16


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 17


RCPIT, Shirpur Department of Electrical Engineering

Experiment 2

Aim: Write program using Arduino IDE for Blink LED.


Component:

• 1 × Breadboard
• 1 × Arduino Uno
• 1 × LED
• 1 × 330Ω Resistor
• 2 × Jumper
Implementation:
LEDs are small, powerful lights that are used in many different applications. To start, we will work
on blinking an LED, the Hello World of microcontrollers. It is as simple as turning a light on and
off. Establishing this important baseline will give you a solid foundation as we work towards
experiments that are more complex.

Procedure
1. Make a connection as per above diagram.
2. Write the program in Arduino IDE.
3. Upload your code in Arduino board.

Program:

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
*/

// the setup function runs once when you press reset or power the board
IoT and Its Applications in Electrical Engineering Laboratory Page 18
RCPIT, Shirpur Department of Electrical Engineering

void setup() { // initialize digital pin 13 as an output.


pinMode(2, OUTPUT);
}

// the loop function runs over and over again forever

void loop() {
digitalWrite(2, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(2, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 19


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 20


RCPIT, Shirpur Department of Electrical Engineering

Experiment 3

Aim: Write program to monitor temperature and humidity using Arduino.


Component:
• 1 × Breadboard
• 1 × Arduino Uno
• 1 × DHT Temperature and Humidity Sensor (3 Pin)
• Jumper wires
• 1 x Arduino USB 2.0 cable
Implementation:
The DHT11 detects water vapor by measuring the electrical resistance between two electrodes. The
humidity sensing component is a moisture holding substrate with electrodes applied to the surface.
When water vapor is absorbed by the substrate, ions are released by the substrate which increases the
conductivity between the electrodes. The change in resistance between the two electrodes is
proportional to the relative humidity. Higher relative humidity decreases the resistance between the
electrodes, while lower relative humidity increases the resistance between the electrodes.
The DHT11 measures temperature with a surface mounted NTC temperature sensor (thermistor) built
into the unit.

Procedure:
1. Make a connection as per above diagram.
2. Write the program in Arduino IDE.
3. Download and install DHT library.
4. Upload your code in Arduino board.

Program:
#include <dht.h>
#define dht_apin A0 // Analog Pin sensor is connected to
dht DHT;
void setup(){
Serial.begin(9600);

IoT and Its Applications in Electrical Engineering Laboratory Page 21


RCPIT, Shirpur Department of Electrical Engineering

delay(500);//Delay to let system boot


Serial.println("DHT11 Humidity & temperature Sensor\n\n");
delay(1000);//Wait before accessing Sensor

}//end "setup()"

void loop(){
//Start of Program
DHT.read11(dht_apin);
Serial.print("Current humidity = ");
Serial.print(DHT.humidity);
Serial.print("% ");
Serial.print("temperature = ");
Serial.print(DHT.temperature);
Serial.println("C ");
delay(5000);//Wait 5 seconds before accessing sensor again.
//Fastest should be once every two seconds.

}// end loop(

Output:

IoT and Its Applications in Electrical Engineering Laboratory Page 22


RCPIT, Shirpur Department of Electrical Engineering

Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 23


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 24


RCPIT, Shirpur Department of Electrical Engineering

Experiment 4

Aim: Design of digital dc voltmeter and ammeter.


Components:
• 1 × Breadboard
• 1 × Arduino Uno
• 1 × ACS712 and Voltage sensor
• Jumper wires
• 1 x Arduino USB 2.0 cable

Implementation:
DC Voltmeter

DC Ammeter

IoT and Its Applications in Electrical Engineering Laboratory Page 25


RCPIT, Shirpur Department of Electrical Engineering

PROCEDURE
A) Procedure for DC Voltmeter:
1. Make the connection as per the electrical circuit diagram
2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the voltage on Serial monitor.
5. If a potentiometer is used between the battery and sensor to change the voltage value.
6. Observe the changed voltage is updated on Serial Monitor.

B) Procedure for DC Ammeter:


1. Make the connection as per the electrical circuit diagram
2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the current on LCD display.
5. If the load is increased by adding a series resistor to LED then current increases and is
updated in LCD display.
Code :
A) Code for DC Voltmeter:
void setup()
{
Serial.begin(9600);
}
void loop() {
int volt = analogRead(A0); // read the input
double voltage = map(volt,0,1023, 0, 2500) + offset; // map 0-1023 to 0-2500 and add
correction offset
voltage /=100; // divide by 100 to get the decimal values
Serial.print("Voltage: ");
Serial.print(voltage); //print the voltge
Serial.println("V");
delay(500);
}
B) Code for DC Voltmeter:
IoT and Its Applications in Electrical Engineering Laboratory Page 26
RCPIT, Shirpur Department of Electrical Engineering

void setup() {
Serial.begin(9600);
}
void loop() {
float average = 0;
for(int i = 0; i< 1000; i++)
{
average = average + (.0264 * analogRead(A0) -13.51) / 1000;
//5A mode, if 20A or 30A mode, need to modify this formula to
//(.19 * analogRead(A0) -25) for 20A mode and
//(.044 * analogRead(A0) -3.78) for 30A mode
delay(1); }
Serial.println(average);
}
Output:

IoT and Its Applications in Electrical Engineering Laboratory Page 27


RCPIT, Shirpur Department of Electrical Engineering

Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 28


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 29


RCPIT, Shirpur Department of Electrical Engineering

Experiment 5

Aim: Design of digital ac voltmeter and ammeter.


Components:
• 1 × Breadboard
• 1 × Arduino Uno
• 1 × ACS712 and
• 1 x ZMPT101B Voltage sensor
• Jumper wires
• 1 x Arduino USB 2.0 cable

Implementation:
AC Voltmeter

AC Ammeter

IoT and Its Applications in Electrical Engineering Laboratory Page 30


RCPIT, Shirpur Department of Electrical Engineering

PROCEDURE
A) Procedure for AC Voltmeter:
1) Make the connection as per the electrical circuit diagram
2) Open the Arduino IDE in computer and write the program.
3) Compile the program for any errors and upload it to the Arduino.
4) Observe the voltage on Serial monitor.
5) Observe the changed voltage is updated on Serial Monitor.
B) Procedure for DC Ammeter:
1) Make the connection as per the electrical circuit diagram
2) Open the Arduino IDE in computer and write the program.
3) Compile the program for any errors and upload it to the Arduino.
4) Observe the current on LCD display.
5) If the load is increased by adding a series resistor to LED then current increases and is
updated in LCD display.
Code:
AC Voltmeter
double sensorValue1 = 0;
double sensorValue2 = 0;
int crosscount = 0;
int climb_flag = 0;
int val[100];
int max_v = 0;
double VmaxD = 0;
double VeffD = 0;
double Veff = 0;

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

void loop() {
for ( int i = 0; i < 100; i++ ) {
sensorValue1 = analogRead(A0);
if (analogRead(A0) > 511) {
val[i] = sensorValue1;
}
else {
val[i] = 0;
}
delay(1);
}
IoT and Its Applications in Electrical Engineering Laboratory Page 31
RCPIT, Shirpur Department of Electrical Engineering

max_v = 0;
for ( int i = 0; i < 100; i++ )
{
if ( val[i] > max_v )
{
max_v = val[i];
}
val[i] = 0;
}
if (max_v != 0) {
VmaxD = max_v;
VeffD = VmaxD / sqrt(2);
Veff = (((VeffD - 420.76) / -90.24) * -210.2) + 210.2;
}
else {
Veff = 0;
}
Serial.print("Voltage: ");
Serial.println(Veff);
VmaxD = 0;
delay(100);
}
AC Voltmeter
double sensorValue1 = 0;
double sensorValue2 = 0;
int crosscount = 0;
int climb_flag = 0;
int val[100];
int max_v = 0;
double VmaxD = 0;
double VeffD = 0;
double Veff = 0;

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

void loop() {

for ( int i = 0; i < 100; i++ ) {


sensorValue1 = analogRead(A0);
if (analogRead(A0) > 511) {
val[i] = sensorValue1;
}
else {
val[i] = 0;
}

IoT and Its Applications in Electrical Engineering Laboratory Page 32


RCPIT, Shirpur Department of Electrical Engineering

delay(1);
}
max_v = 0;
for ( int i = 0; i < 100; i++ )
{
if ( val[i] > max_v )
{
max_v = val[i];
}
val[i] = 0;
}
if (max_v != 0) {
VmaxD = max_v;
VeffD = VmaxD / sqrt(2);
Veff = (((VeffD - 420.76) / -90.24) * -210.2) + 210.2;
}
else {
Veff = 0;
}
Serial.print("Voltage: ");
Serial.println(Veff);
VmaxD = 0;
delay(100);
}

Output

Conclusion
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 33


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 34


RCPIT, Shirpur Department of Electrical Engineering

Experiment 6

Aim: Measurement of power and energy.


Components:
• 1 × Breadboard
• 1 × Arduino Uno
• 1 × ACS712 and
• 1 x ZMPT101B Voltage sensor
• Jumper wires
• 1 x Arduino USB 2.0 cable
Implementation:

PROCEDURE
1. Make the connection as per the electrical circuit diagram
2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the Power, Energy consumed by the load on LCD display
Code:
#include int currentPin = 1;
double kilos = 0;
int peakPower = 0;
LiquidCrystallcd(8, 9, 4, 5, 6, 7);

IoT and Its Applications in Electrical Engineering Laboratory Page 35


RCPIT, Shirpur Department of Electrical Engineering

void setup()
{
lcd.begin(16,2);
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Running");
}
void loop()
{
int current = 0;
int maxCurrent = 0;
int minCurrent = 1000;
for (int i=0 ;i<=200 ; i++) //Monitors and logs the current input for 200 cycles to determine max
and min current
{
current = analogRead(currentPin); //Reads current input and records maximum and minimum
current
if(current >= maxCurrent)
maxCurrent = current;
else if(current <= minCurrent)
minCurrent = current;
}
if (maxCurrent<= 517)
{
maxCurrent = 516;
}
double RMSCurrent = ((maxCurrent - 516)*0.707)/11.8337; //Calculates RMS current based on
maximum value
int RMSPower = 220*RMSCurrent; //Calculates RMS Power Assuming Voltage 220VAC, change
to 110VAC accordingly
if (RMSPower>peakPower)
{
peakPower = RMSPower;
IoT and Its Applications in Electrical Engineering Laboratory Page 36
RCPIT, Shirpur Department of Electrical Engineering

}
kilos = kilos + (RMSPower * (2.05/60/60/1000)); //Calculate kilowatt hours used
delay (2000);
lcd.clear();
lcd.setCursor(0,0); // Displays all current data
lcd.print(RMSCurrent);
lcd.print("A");
lcd.setCursor(10,0);
lcd.print(RMSPower);
lcd.print("W");
lcd.setCursor(0,1);
lcd.print(kilos);
lcd.print("kWh");
lcd.setCursor(10,1);
lcd.print(peakPower);
lcd.print("W");
}
Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 37


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 38


RCPIT, Shirpur Department of Electrical Engineering

Experiment 7

Aim: Traffic signal control.


Component:
•1 × Breadboard
•1 × Arduino Uno
•1 x Red LED
•1 x Yellow LED
•1 x Green LED
•3 x 220 ohm resistor
•Jumper wires
•1 x Arduino USB 2.0 cable
Implementation:

Procedure:
1. Make the connection as per the circuit diagram
2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Observe the status of traffic light.
Code:
// variables
int GREEN = 2;
int YELLOW = 3;
int RED = 4;
int DELAY_GREEN = 5000;
int DELAY_YELLOW = 2000;
int DELAY_RED = 5000;

IoT and Its Applications in Electrical Engineering Laboratory Page 39


RCPIT, Shirpur Department of Electrical Engineering

// basic functions
void setup()
{
pinMode(GREEN, OUTPUT);
pinMode(YELLOW, OUTPUT);
pinMode(RED, OUTPUT);
}
void loop()
{
green_light();
delay(DELAY_GREEN);
yellow_light();
delay(DELAY_YELLOW);
red_light();
delay(DELAY_RED);
}
void green_light()
{
digitalWrite(GREEN, HIGH);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, LOW);
}
void yellow_light()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, HIGH);
digitalWrite(RED, LOW);
}
void red_light()
{
digitalWrite(GREEN, LOW);
digitalWrite(YELLOW, LOW);
digitalWrite(RED, HIGH);
}

Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 40


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 41


RCPIT, Shirpur Department of Electrical Engineering

Experiment 8

Aim: Railway gate control by servo motors.


Component:
• 1 x Arduino UNO
• 1 x Servo motor
• 2 x IR Sensor Modules
• Jumper Wires
• USB cable for uploading code into Arduino UNO
• Breadboard
Implementation:

Code:
#include <Servo.h> // servo library
Servo s1;
int val = 0 ;
int va2 = 0 ;
void setup()
{
Serial.begin(9600);
pinMode(2,INPUT); // IR sensor 1

IoT and Its Applications in Electrical Engineering Laboratory Page 42


RCPIT, Shirpur Department of Electrical Engineering

pinMode(3,INPUT); // IR sensor 2
s1.attach(9); // Servo Connect 9 pin
s1.write(0);
}
void loop()
{
val = digitalRead(2); // IR sensor 1 output pin connected
va2 = digitalRead(3); // IR sensor 2 output pin connected
Serial.println(val); // see the value in serial monitor in Arduino IDE
Serial.println(va2); // see the value in serial monitor in Arduino IDE
delay(10); // Time Delay
if(val == 1 )
{
s1.write(0); // SERVO 0 DEGREE
}
if(va2 == 1 )
{
s1.write(90); // SERVO 90 DEGREE
}
}
Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 43


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 44


RCPIT, Shirpur Department of Electrical Engineering

Experiment 9

Aim: Direction and Speed control of DC motor.


Component:
• Arduino UNO board
• L293D driver
• 12V DC motor
• 10K ohm potentiometer
• Pushbutton
• 12V source
• Breadboard
• Jumper wires
Implementation:

Procedure:
1. Make the connection as per the circuit diagram
2. Open the Arduino IDE in computer and write the program.
3. Compile the program for any errors and upload it to the Arduino.
4. Use push button for direction control of motor and use pot for speed control of the motor.
Code:
// Arduino DC motor speed and direction control
#define button 8
#define pot 0
IoT and Its Applications in Electrical Engineering Laboratory Page 45
RCPIT, Shirpur Department of Electrical Engineering

#define pwm1 9
#define pwm2 10
boolean motor_dir = 0;
int motor_speed;
void setup() {
pinMode(button, INPUT_PULLUP);
pinMode(pwm1, OUTPUT);
pinMode(pwm2, OUTPUT);
}
void loop() {
motor_speed = analogRead(pot) / 4;
if(motor_dir)
analogWrite(pwm1, motor_speed);
else
analogWrite(pwm2, motor_speed);
if(!digitalRead(button)){ // If direction button is pressed
while(!digitalRead(button)); // Wait until direction button released
motor_dir = !motor_dir; // Toggle direction variable
if(motor_dir)
digitalWrite(pwm2, 0);
else
digitalWrite(pwm1, 0);
}
}

Conclusion:
____________________________________________________________________
____________________________________________________________________
____________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 46


RCPIT, Shirpur Department of Electrical Engineering

Laboratory Report
Experiment No: ____
__

Name of Student: --------------------------------------------------- Roll No--------------------------.

Date of Lab: ----------------------- Date of Submission: ---------

Evaluations

1) Lab Attendance [2] ------------------


2) Observations and Conclusion [2] -------------------
3) Oral [1] ------------------

Overall Marks (5) -------------------------

_______________________
Sign of Practical Teacher

IoT and Its Applications in Electrical Engineering Laboratory Page 47


RCPIT, Shirpur Department of Electrical Engineering

Experiment 10

Aim: Reading sensor data and sending it to cloud platform for temperature and
humidity sensor.
Component:
• 1 x NodeMCU
• 1 x DHT11 Temperature and Humidity sensor
• 3 x Jumper Male to female
Implementation:

Procedure:
1. Go to https://thingspeak.com/ and create an account if you do not have one. Login to your
account.
2. Create a new channel by clicking on the button.Enter basic details of the channel.
Then Scroll down and save the channel.
3. Channel Id is the identity of your channel. Note down this. Then go to API keys copy and paste
this key to a separate notepad file will need it later.
Code:

#include <DHT.h> // Including library for dht


#include <ESP8266WiFi.h>
String apiKey = "Your API of thingsspeak"; // Enter your Write API key from
ThingSpeak
const char *ssid = "Your wifi Network name"; // replace with your wifi ssid and
wpa2 key
const char *pass = "Network password";
const char* server = "api.thingspeak.com";

IoT and Its Applications in Electrical Engineering Laboratory Page 48


RCPIT, Shirpur Department of Electrical Engineering

#define DHTPIN 0 //pin where the dht11 is connected

DHT dht(DHTPIN, DHT11);

WiFiClient client;

void setup()
{
Serial.begin(115200);
delay(10);
dht.begin();
Serial.println("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, pass);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");

void loop()
{
float h = dht.readHumidity();
float t = dht.readTemperature();
if (isnan(h) || isnan(t))
{
Serial.println("Failed to read from DHT sensor!");
return;
}
if (client.connect(server,80)) // "184.106.153.149" or
api.thingspeak.com
{
String postStr = apiKey;
postStr +="&field1=";
postStr += String(t);
postStr +="&field2=";
postStr += String(h);
postStr += "\r\n\r\n";

IoT and Its Applications in Electrical Engineering Laboratory Page 49


RCPIT, Shirpur Department of Electrical Engineering

client.print("POST /update HTTP/1.1\n");


client.print("Host: api.thingspeak.com\n");
client.print("Connection: close\n");
client.print("X-THINGSPEAKAPIKEY: "+apiKey+"\n");
client.print("Content-Type: application/x-www-form-urlencoded\n");
client.print("Content-Length: ");
client.print(postStr.length());
client.print("\n\n");
client.print(postStr);

Serial.print("Temperature: ");
Serial.print(t);
Serial.print(" degrees Celcius, Humidity: ");
Serial.print(h);
Serial.println("%. Send to Thingspeak.");
}
client.stop();

Serial.println("Waiting...");

// thingspeak needs minimum 15 sec delay between updates, i've set it to 30 seconds
delay(10000);
}

Result:

IoT and Its Applications in Electrical Engineering Laboratory Page 50


RCPIT, Shirpur Department of Electrical Engineering

Conclusion:
________________________________________________________________________________
________________________________________________________________________________
________________________________________________________________________________

IoT and Its Applications in Electrical Engineering Laboratory Page 51

You might also like