[go: up one dir, main page]

0% found this document useful (0 votes)
11 views39 pages

Iot Lab

The document outlines a skill-oriented course on IoT applications in electrical engineering, detailing a list of experiments involving Arduino and Raspberry Pi. It explains the fundamentals of IoT, the differences between microprocessors and microcontrollers, and provides an overview of the Arduino platform, including its hardware, software, and programming basics. Additionally, it covers essential coding concepts and structures for developing projects using Arduino.

Uploaded by

nirmalapaila2005
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)
11 views39 pages

Iot Lab

The document outlines a skill-oriented course on IoT applications in electrical engineering, detailing a list of experiments involving Arduino and Raspberry Pi. It explains the fundamentals of IoT, the differences between microprocessors and microcontrollers, and provides an overview of the Arduino platform, including its hardware, software, and programming basics. Additionally, it covers essential coding concepts and structures for developing projects using Arduino.

Uploaded by

nirmalapaila2005
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/ 39

SKILL ORIENTED COURSE IOT

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.

• Hackers / Makers • Kids!


• Engineers • Teachers!!
• Artists • You!!!
• Musicians
Arduino Board
“Strong Friend” Created in Ivrea, Italy
in 2005 by Massimo Banzi & David Cuartielles
Open Source Hardware
Processor
Coding is accessible & transferrable → (C++, Processing, java)
Arduino Software Installation

• 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

•Access to multiple I/O

•Drive motors, turn on lights,


trigger controls.

•Low Power requirements

•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

Two required functions /


methods / routines:
void setup()
{
// runs once
}
void loop()
{
error & status messages // repeats
}
Compile upload Basic Program
Two required routines /
methods / functions:

void setup()
Serial
{
Monitor
// runs once
}
New file
void loop()
{
// repeats forever!!!
}
comments
Go ahead and plug your board in!
Settings: Tools → Board

Next, double-check that the proper board is selected under the


Tools→Board menu.
An integrated development environment (IDE) is software
for building applications that combines common developer tools
into a single graphical user interface (GUI).
Settings: Tools → Serial Port

Your computer
communicates to the Arduino
microcontroller via a serial
port → through a USB-Serial
adapter.

Check to make sure that the


drivers are properly installed.
Analog and Digital
• All Arduino signals are either Analog or
Digital
• All computers including Arduino, only
understand Digital
• It is important to understand the difference
between Analog and Digital signals since
Analog signals require an Analog to Digital
conversion
Concepts: Analog vs. Digital
Microcontrollers are digital devices – ON or OFF.
Also called – discrete.

analog signals are anything that can be a full


range of values. What are some examples? More
on this later…

5V 5V

0V 0V
Input vs. Output
Everything is referenced from the perspective of the
microcontroller.

Inputs is a signal going into the board.


Output is any signal exiting an electrical system

• Almost all systems that use physical computing will


have some form of output

• Often – Outputs include LEDs, a motor, a servo, a


piezo element, a relay and an RGB LED
pinMode()

BIG 6 CONCEPTS
digitalWrite()/digitalRead()

analogRead()/analogWrite()

delay()

if() statements/if-else() statements

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…

General Use Example


if(condition) if(button_State==HIGH)
{ {
// do this digitalWrite(ledPin,
HIGH);
} delay(300);
digitalWrite(ledPin,
LOW);
delay(300);
}
IF & Example
int counter = 0;

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

if(counter < 10)


{
Serial.println(counter);
}
counter = counter + 1;

}
IF – ELSE & Example
int counter = 0;
void setup() {
Serial.begin(9600);
}
void loop() {

if(counter < 10)


{
Serial.println(“less than 10”);
}
else
{
Serial.println(“greater than or equal to
10”);
Serial.end();
}
counter = counter + 1;
} 32
Serial Transmission(Tx,Rx)
Transferring data from the computer to an
Arduino is done using Serial Transmission
To setup Serial communication we use the
following

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?

You might also like