Iot Lab
Iot Lab
APPLICATIONS OF
ELECTRICAL ENGINEERING
Mr.Y.Sumith
List of Experiments:
Any TEN of the following Experiments are to be conducted
1. Familiarization with Arduino/Raspberry Pi and perform necessary software installation.
2. To interface LED/Buzzer with Arduino/Raspberry Pi and write a program to turn ON LED for 1 sec after
every 2 seconds.
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.
4. To interface temperature sensor with Arduino/Raspberry Pi and write a program to print temperature and
humidity readings.
5. To interface Organic Light Emitting Diode (OLED) with Arduino/Raspberry Pi
6. To interface Bluetooth with Arduino/Raspberry Pi and write a program to send sensor data to smartphone
using Bluetooth.
7. 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.
8. Write a program on Arduino/Raspberry Pi to upload and retrieve temperature and humidity data to
thingspeak cloud.
9. 7 Segment Display
10. Analog Input & Digital Output
11. Night Light Controlled & Monitoring System
12. Fire Alarm Using Arduino
13. IR Remote Control for Home Appliances
14. A Heart Rate Monitoring System
15. Alexa based Home Automation System
What is a IoT?
The term IoT, or Internet of Things, refers to the
collective network of connected devices and the
technology that facilitates communication between
devices and the cloud, as well as between the
devices themselves.
The Internet of Things (IoT) describes the network of
physical objects—“things”—that are embedded with
sensors, software, and other technologies for the
purpose of connecting and exchanging data with other
devices and systems over the internet.
Micro processor vs microcntroller
an integrated circuit that contains all the functions of a central
processing unit of a computer.
the microprocessor is the central unit that executes and manages
the logical instructions passed to it
It performs some basic operations like addition, subtraction,
multiplication, division, and some logical operations using its
Arithmetic and Logical Unit (ALU).
A microcontroller is a compact integrated circuit designed to govern
a specific operation in an embedded system
What is Arduino and Who cares?
•Arduino is an open-source platform that helps circuit
developers build electronic projects.
•It consists of both hardware and software.
•Arduino hardware is a programmable circuit board
called a microcontroller.
•Arduino software is an IDE (integrated development
environment) through which developers write and upload
the code to the microcontroller.
• Open Source
• Free
• Available on-line with resources at:
www.arduino.cc
Path:https://www.arduino.cc/en/software
Different Varieties of Arduino
7-12 volt input power USB
(9v is common) (to Computer)
RESET
SCL\SDA
(I2C Bus)
SDA-Serial Data
SCL-Serial Clock
POWER
5V / 3.3V / GND
Digital I\O
PWM(3, 5, 6, 9, 10, 11)
Analog
INPUTS
What can it do?
•Great for prototyping ideas
•Flexible / Open-source
Arduino
Integrated Development Environment (IDE)
The Arduino Integrated Development Environment - or Arduino Software (IDE) - contains
a text editor for writing code, a message area, a text console, a toolbar with buttons for
common functions and a series of menus. It connects to the Arduino hardware to upload
programs and communicate with them
void setup()
Serial
{
Monitor
// runs once
}
New file
void loop()
{
// repeats forever!!!
}
comments
Go ahead and plug your board in!
Settings: Tools → Board
Your computer
communicates to the Arduino
microcontroller via a serial
port → through a USB-Serial
adapter.
5V 5V
0V 0V
Input vs. Output
Everything is referenced from the perspective of the
microcontroller.
BIG 6 CONCEPTS
digitalWrite()/digitalRead()
analogRead()/analogWrite()
delay()
Serial Transmission
Pin mode
pinMode()
• A pin on arduino can be set as input or
output by using pinMode function.
• pinMode(13, OUTPUT); // sets pin 13 as
output pin
• pinMode(13, INPUT); // sets pin 13 as
input pin
Reading/writing digital values
digitalWrite()
• digitalWrite(13, LOW); // Makes the output
voltage on pin 13 , 0V
• digitalWrite(13, HIGH); // Makes the
output voltage on pin 13 , 5V
• int buttonState = digitalRead(2); // reads
the value of pin 2 in buttonState
Reading/writing digital values
digitalRead()
• Reads the value from a specified digital
pin, either HIGH or LOW
• Eg: int inPin=7;
val = digitalRead(inPin); Or
val = digitalRead(7);
ie. reads the value from inPin and assigns it
to val.
Reading/Writing Analog Values
analogRead()
analogRead(A0); // used to read the analog
value from the pin A0
analogWrite()
analogWrite(2,128);
delay
delay(ms) delayMicroseconds(us)
• Pauses the program for • Pauses the program for
the amount of time (in the amount of time (in
milliseconds) specified as milliseconds) specified as
parameter. parameter.
• Eg: • Eg:
delay(1000); delayMicroseconds (50);
ie. pauses1000 ms = 1 s ie. pauses 50us
Conditional Statements
If…
void setup() {
Serial.begin(9600);
}
void loop() {
}
IF – ELSE & Example
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
void setup() {
Serial.begin(9600);
}
Writing to the Console
void setup() {
Serial.begin(9600);
Serial.println(“Hello World!”);
void loop() {}
Basic Coding structure
▪ setup() function
• Called when a sketch starts.
• To initialize variables, pin modes, start using libraries, etc.
• Will only run once, after each power-up or reset of the Arduino
board.
▪ loop() function
• Loops consecutively.
• Code in the loop() section of the sketch is used to actively control the
Arduino board.
▪ Commenting
• Any line that starts with two slashes (//) will not be read by the
compiler, so you can write anything you want after it.
35
Structure:Arduino programs can be divided in three
main parts: Structure, Values (variables and constants),
and Functions. Let us start with the Structure. Software
structure consist of two main functions −
1. Setup( ) function
2. Loop( ) function
Void setup ( )
{
}
•PURPOSE − The setup() function is called when
a sketch starts. Use it to initialize the variables, pin
modes, start using libraries, etc.
• The setup function will only run once, after each
power up or reset of the Arduino board.
•INPUT
•OUTPUT
•RETURN
Void Loop ( )
{
}
•PURPOSE − After creating a setup() function, which
initializes and sets the initial values,
•the loop() function does precisely what its name suggests,
and loops consecutively, allowing your program to change
and respond. Use it to actively control the Arduino board.
•INPUT
•OUTPUT
•RETURN
Using Variables
To clean-up code, for read-ability, and flexibility
– we can create placeholders in code.
Example:
int ledPin = 3;
void setup(){
pinMode(ledPin, OUTPUT);
}
void loop(){
digitalWrite(ledPin, HIGH);
}
Questions?