SlideShare a Scribd company logo
SENSORS ANDSENSORS AND
ARDUINOARDUINO
SensorSensor
• A sensor is a device that detects and responds to
some type of input from the physical environment.
• The specific input could be light, heat, motion,
moisture, pressure, or any one of a great number of
other environmental phenomena.
• The output is generally a signal that is converted to
human-readable display at the sensor location or
transmitted electronically over a network for
reading or further processing.
Sensors ExampleSensors Example
Sensors we need to learnSensors we need to learn
• PIR sensor--- Detecting Movement
• Ultrasonic Sensor--- Measuring Distance
PIR SENSORPIR SENSOR
• PIR sensors allow you to sense motion, almost always
used to detect whether a human has moved in or
out of the sensors range.
• They are small, inexpensive, low-power, easy to use
and don't wear out.
• For that reason they are commonly found in
appliances and gadgets used in homes or
businesses.
• They are often referred to as PIR, "Passive Infrared",
"Pyroelectric", or "IR motion" sensors.
PIR SensorPIR Sensor
• PIRs are basically made of a pyroelectric sensor
 (which you can see above as the round metal can
with a rectangular crystal in the center), which can
detect levels of infrared radiation.
• Everything emits some low level radiation, and the
hotter something is, the more radiation is emitted. 
• The PIR sensor itself has two slots in it, each slot is made
of a special material that is sensitive to IR. 
• When the sensor is idle, both slots detect the same
amount of IR, the ambient amount radiated from the
room or walls or outdoors.
• When a warm body like a human or animal passes by, it
first intercepts one half of the PIR sensor, which causes
a positive differential change between the two halves.
• When the warm body leaves the sensing area, the
reverse happens, whereby the sensor generates a
negative differential change. These change pulses are
what is detected.
Circuit DiagramCircuit Diagram
• Pin1 -VCC
• Pin 2- Output of PIR sensor connected to 2 pin of
arduino
• Pin 3-Ground
int ledPin = 13; // choose the pin for the LED
int inputPin = 2; // choose the input pin (for PIR sensor)
int pirState = LOW; // we start, assuming no motion detected
int val = 0; // variable for reading the pin status
void setup()
{
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inputPin, INPUT); // declare sensor as input
Serial.begin(9600);
}
void loop()
{
val = digitalRead(inputPin); // read input value
if (val == HIGH)
{ // check if the input is HIGH
digitalWrite(ledPin, HIGH); // turn LED ON
if (pirState == LOW)
{
// we have just turned on
Serial.println("Motion detected!");
// We only want to print on the
output change, not state
pirState = HIGH;
}
}
else
{
digitalWrite(ledPin, LOW); // turn LED OFF
if (pirState == HIGH){ // we have just turned of
Serial.println("Motion ended!"); // We only want to
print on the output change, not state
pirState = LOW;
}
}
}
UltrasonicUltrasonic
SensorSensor
• An Ultrasonic sensor is a device that can measure
the distance to an object by using sound waves.
• It measures distance by sending out a sound wave
at a specific frequency and listening for that sound
wave to bounce back.
• By recording the elapsed time between the sound
wave being generated and the sound wave
bouncing back, it is possible to calculate the
distance between the sonar sensor and the object.
 
• Since it is known that sound travels through air at
about 344 m/s (1129 ft/s), you can take the time for
the sound wave to return and multiply it by 344
meters (or 1129 feet) to find the total round-trip
distance of the sound wave.
• Round-trip means that the sound wave traveled 2
times the distance to the object before it was
detected by the sensor; it includes the 'trip' from the
sonar sensor to the object AND the 'trip' from the
object to the Ultrasonic sensor (after the sound
wave bounced off the object).
• To find the distance to the object, simply divide the
round-trip distance in half.
• The Trig pin will be used to send the signal and
the Echo pin will be used to listen for returning signal
Example- Distance MeasurementExample- Distance Measurement
#define echoPin 7 // Echo Pin
#define trigPin 8 // Trigger Pin
#define LEDPin 13 // Onboard LED
int maximumRange = 200; // Maximum range needed
int minimumRange = 0; // Minimum range needed
long duration, distance; // Duration used to calculate distance
void setup()
{
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(LEDPin, OUTPUT); // Use LED indicator (if required)
}
void loop() /* The following trigPin/echoPin
cycle is used to determine the distance of the nearest
object by bouncing soundwaves off of it. */
{
duration = pulseIn(echoPin, HIGH);
//Calculate the distance (in cm) based on the speed
of sound.
distance = duration/58.2;
Serial.print(Distance);
Dealy(1000);}
Interfacing DCInterfacing DC
Motor WithMotor With
ArduinoArduino
DC MotorDC Motor
• Working principle of a DC motor --A motor is an
electrical machine which converts electrical energy into
mechanical energy.
• The principle of working of a DC motor is that "whenever
a current carrying conductor is placed in a magnetic
field, it experiences a mechanical force".
• A DC motor (Direct Current motor) is the most common
type of motor. DC motors normally have just two leads,
one positive and one negative.
• If you connect these two leads directly to a battery, the
motor will rotate. If you switch the leads, the motor will
rotate in the opposite direction.
• To control the direction of the spin of DC motor,
without changing the way that the leads are
connected, you can use a circuit called an H-
Bridge.
• An H bridge is an electronic circuit that can drive
the motor in both directions.
• H-bridges are used in many different applications,
one of the most common being to control motors in
robots.
• It is called an H-bridge because it uses four
transistors connected in such a way that the
schematic diagram looks like an "H." 
• You can use discrete transistors to make this circuit, but
for this lecture, we will be using the L293d/L298 H-Bridge
IC.
• In L293 all four input- output lines are independent, while
in L298, a half H driver cannot be used independently,
full H driver has to be used.
• Protective Diodes against back EMF are provided
internally in L293D but must be provided externally
in L298.
• The L298 can control the speed and direction of DC
motors and stepper motors and can control two motors
simultaneously.
• Its current rating is 2A for each motor. At these currents,
however, you will need to use heat sinks.
L293D Motor Driver ICL293D Motor Driver IC
Controlling Speed of DCControlling Speed of DC
MotorMotor
• We will connect the Arduino to IN1 (pin 5), IN2 (pin
7), and Enable1 (pin 6) of the L293d IC. Pins 5 and 7
are digital, i.e. ON or OFF inputs, while pin 6 needs a
pulse-width modulated (PWM) signal to control the
motor speed.
const int pwm = 2 ; //initializing pin 2 as pwm
const int in_1 = 8 ;
const int in_2 = 9 ; //For providing logic to L293d
IC to choose the direction of the DC motor
void setup()
{
pinMode(pwm,OUTPUT) ; //we have to set PWM pin as
output
pinMode(in_1,OUTPUT) ; //Logic pins are also set as
output
pinMode(in_2,OUTPUT) ; }
void loop()
{
//For Clock wise motion , in_1 = High , in_2 = Low
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,LOW) ;
analogWrite(pwm,255) ;
delay(3000) ;
/*setting pwm of the motor to 255 we can change the
speed of rotaion by chaning pwm input but we are only
using arduino so we are using higest value to driver the
motor */
//For brake
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;
delay(1000) ; }
//For brake
digitalWrite(in_1,HIGH) ;
digitalWrite(in_2,HIGH) ;
delay(1000) ;
//For Anti Clock-wise motion
- IN_1 = LOW , IN_2 = HIGH
digitalWrite(in_1,LOW) ;
digitalWrite(in_2,HIGH) ;
delay(3000) ;
Bluetooth Technology
IntroductionIntroduction

Bluetooth is a wireless communication technology used for
exchange of data over short distances.

It is found in many devices ranging from mobile phones and
computers.

Bluetooth technology is a combination of both hardware and
software.

It is intended to create a personal area networks (PAN) over
a short range.

It operates in the unlicensed industrial, scientific and medical
(ISM) band at 2.4 to 2.485 GHz.

It uses a radio technology called frequency hopping spread
spectrum (FHSS).
FHSSFHSS
• Frequency hopping spread spectrum (FHSS) is a method
of transmitting radio signals by shifting carriers across
numerous channels with pseudorandom sequence
which is already known to the sender and receiver.
• Frequency hopping spread spectrum is defined in the
2.4 GHz band and operates in around 79 frequencies
ranging from 2.402 GHz to 2.480 GHz.
• Every frequency is GFSK modulated with channel width
of 1MHz and rates defined as 1 Mbps and 2 Mbps
respectively.
• Frequency hopping spread spectrum is a robust
technology with only very little influence from
reflections, noise and other environmental factors

It is a packet-based protocol with a master-slave
structure.

Each master can communicate with up to 7 slaves in a
piconet.

The range of Bluetooth depends upon the class of radio
using.

Class 3 radios have range up to 1 meter or 3 feet.

Class 2 radios have range of 10 meters or 33 feet.

Class 1 radios have range of 100 meters or 300 feet.

The most commonly used radio is Class 2.
Advantages andAdvantages and
DisadvantagesDisadvantages
Advantages

The biggest advantage of using this technology is that there
are no cables or wires required for the transfer of data over
short ranges.

Bluetooth technology consumes less power when compared
with other wireless communication technologies.

For example Bluetooth technology using Class 2 radio uses
power of 2.5 mW.

As it is using frequency hopping spread spectrum radio
technology there is less prone to interference of data if the
other device also operates in the same frequency range.

Bluetooth doesn’t require clear line of sight between the
synced devices.
Disadvantage

Since it uses the greater range of Radio Frequency
(RF), it is much more open to interception and
attack.

It can be used for short range communications
only.

Although there are fewer disadvantages, Bluetooth
still remains best for short wireless technology.
Introduction to HC-05Introduction to HC-05
and HC-06 Modulesand HC-06 Modules
HC 05

HC-05 is a class 2 Bluetooth
module with Serial Port Profile
(SPP).

It can be configure either as
master or salve.

It is a replacement for wired
serial connection.

The module has two modes of
operation, Command Mode
where we can send AT
commands to it and Data
Mode where it transmits and
receives data to another
bluetooth module.

HC-05 Specification:
 Bluetooth Protocol : Bluetooth Specificatio v2.0 + EDR
 Frequency : 2.4 GHz ISM band
 Profiles : Bluetooth Serial Port
 Working Temperature : -20 to + 75 centigrade
 Power of emitting : 3 dBm

The pins on the module are:
 Vcc – Power supply for the module.
 GND – Ground of the module.
 TX – Transmitter of Bluetooth module.
 RX – Receiver of the module.
 Key – Used for the module to enter into AT command mode.

The default mode is DATA Mode, and this is the
default configuration, that may work fine for
many applications:
Baud Rate: 9600 bps, Data : 8 bits, Stop Bits: 1 bit,
Parity : None, Handshake: None

Passkey: 1234

Device Name: HC-05
HC 06

HC-06 is a drop-in replacement for wired serial
connection.

This can be used as serial port replacement to
establish connection between PC and MCU
(Microcontroller).

This is a Slave Mode only Bluetooth device.

HC-06 offers encrypted connection

This module can be configured for baud rates 1200
to 115200 bps
Hooking up with ArduinoHooking up with Arduino

The connections are:
HC-05 Arduino
Vcc -----------> 5V
GND -----------> GND
TX -----------> RX
RX -----------> TX

Let’s control theLet’s control the
LED on ArduinoLED on Arduino
using a basic code tousing a basic code to
send command oversend command over
Bluetooth.Bluetooth.

The code is shown:The code is shown:
void setup() {
Serial.begin(9600);
pinMode(13,OUTPUT);
}
void loop() {
if(Serial.available())
{
ch=Serial.read();
if(ch=='h')
{
digitalWrite(13,HIGH);
}
if(ch=='l')
{
digitalWrite(13,LOW);
}
}
}
Configuring HC-05 withConfiguring HC-05 with
AT commandsAT commands

HC-05 can be configured i.e. its name and
password can be changed and many more using
AT commands.

It can also be configured as either master or slave.

To set the HC-05 into AT command mode the KEY
pin of the module is made high i.e. it is connected
to either 5V or 3.3V pin of Arduino and TX of
Arduino is connected to TX of HC-05 and RX of HC-
05 to RX of Arduino.

To enter the AT commands open up the COM port of
the Arduino to which the Bluetooth module is
connected and set the baud rate to 38400.

After opening COM port if you enter command “AT”
(without quotes) it should return “OK” thus it can be
said that HC-05 entered into AT command mode.

Refer following link for detailed AT commands and its
descriptions:

http://www.linotux.ch/arduino/HC-
0305_serial_module_AT_commamd_set_201104_revise
d.pdf
Popular AT commandsPopular AT commands
1. AT
2. AT+RESET
3. AT+VERSION?
4. AT+ORGL
5. AT+ADDR?
6. AT+ ROLE?
7. AT+NAME?
8. AT+PSWD?
9. AT+UART?
10. AT+STATE?
11. AT+DISC
12. AT+BIND?
13. AT+RMAAD?
14. AT+ADCN?
15. AT+MRAD?
16. AT+PAIR
access AT commandaccess AT command
modemode
• Some bluetooth mode does not have KEY pin.
• In such module, different approach is considered:
• first connect the Bluetooth module to an Arduino
(Nano, UNO or whatever) using the following
connections…
• HC-05 GND –> Gnd
• HC-05 VCC –> +5V (initially disconnected)  *
• HC-05 TX –> D2 (any pin as required)
• HC-05 RX –> D3 (any pin as required)
• STATE (output) and EN (input) are not connected
• Follow these steps:
1. Disconnect the power to the HC-05 module.
2. Load the sketch to the Arduino
3. Depress the small reset button on the HC-05 module and hold
it down while you connect its Vcc pin to +5V.
• The red LED on the module (that would otherwise be blinking
quickly) will flash slowly indicating it is in AT mode.
• Open a serial monitor in the Arduino IDE (or any other
terminal software) and set its baud rate to 57600 and ensure
that on the IDE serial terminal, ensure “Both NL & CR” is
selected.
• You should then see the prompt “Enter AT commands: “.
• You can then type your AT commands into the terminal input
line and have them control the HC-05. 
• Here are a few AT commands that I found useful:
• To ensure the unit is responding, enter AT. The unit should
respond OK
• To return the HC-05 to its default settings, enter AT+ORGL
• To see the version of your HC-05 enter AT+VERSION?
• To change the name of the device to AJCLOCK, for
example, enter AT+NAME=AJCLOCK
• To change the default security code (1234) to 2332 enter
AT+PSWD=2332
• To check baud rate, enter AT+UART? (my unit reset to
38400)
• To change baud rate to say, 115200, 1 stop bit, 0 parity,
enter AT+UART=115200,1,0
CodeCode• #include <SoftwareSerial.h>
• SoftwareSerial btSerial(2, 3); // RX | TX
• void setup() {
• Serial.begin(57600);
• Serial.println("Enter AT commands:");
• btSerial.begin(38400); // HC-05 default speed in AT command more
• }
• void loop() {
• if (btSerial.available())
• Serial.write(btSerial.read());
• if (Serial.available())
• btSerial.write(Serial.read());
• }
Servo MotorServo Motor
• A servo motor allows a precise control of the angular
position, velocity, and acceleration. It’s like you’re at the
steering wheel of your car.
• You control precisely the speed of the car and the
direction.
• These servos are essential parts if we need to control the
position of objects, rotate sensors, move arms and legs,
drive wheels and tracks, and more.
• Inside the micro servo, you will find the pieces from
the above image.
• The top cover hosts the plastic gears while the
middle cover hosts a DC motor, a controller, and
the potentiometer.
• The servo motor has three leads, with one more
than a DC motor.
• Each lead has a color code. So you have to
connect the brown wire from the micro servo to the
GND pin on the Arduino.
• Connect the red wire from the servo to the +5V on
the Arduino. And finally, connect the orange wire
from the SG90 servo to a digital pin (pin 9) on the
Arduino.
SweepSweep
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// twelve servo objects can be created on most boards
int pos = 0; // variable to store the servo position
void setup() {
myservo.attach(9); // attaches the servo on pin 9 to the servo object
}
void loop() {
for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees
// in steps of 1 degree
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
}
ProgramProgram
•#include <Servo.h>
•Servo myservo; // create servo
object to control a servo
•int potpin = 0; // analog pin used
to connect the potentiometer
•int val; // variable to read the
value from the analog pin
•void setup() {
• myservo.attach(9); // attaches
the servo on pin 9 to the servo
object
•}
•void loop() {
• val = analogRead(potpin);
// reads the value of the
potentiometer (value between 0
and 1023)
• val = map(val, 0, 1023, 0, 180);
// scale it to use it with the servo
(value between 0 and 180)
• myservo.write(val); //
sets the servo position according
to the scaled value
• delay(15); //
waits for the servo to get there
•}

More Related Content

What's hot

Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
Dhruwank Vankawala
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
Sai_praneeth
 

What's hot (20)

Arduino windows remote control
Arduino windows remote controlArduino windows remote control
Arduino windows remote control
 
Embedded &amp; pcb design
Embedded &amp; pcb designEmbedded &amp; pcb design
Embedded &amp; pcb design
 
Codesign-Oriented Platform for Agile Internet of Things Prototype Development
Codesign-Oriented Platform for Agile Internet of Things Prototype DevelopmentCodesign-Oriented Platform for Agile Internet of Things Prototype Development
Codesign-Oriented Platform for Agile Internet of Things Prototype Development
 
I2C programming with C and Arduino
I2C programming with C and ArduinoI2C programming with C and Arduino
I2C programming with C and Arduino
 
Basics of open source embedded development board (
Basics of open source embedded development board (Basics of open source embedded development board (
Basics of open source embedded development board (
 
Raspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication ProtocolsRaspberry Pi - Lecture 3 Embedded Communication Protocols
Raspberry Pi - Lecture 3 Embedded Communication Protocols
 
Uart 16550
Uart 16550Uart 16550
Uart 16550
 
LUMOS
LUMOSLUMOS
LUMOS
 
Embedded systems and its ports
Embedded systems and its portsEmbedded systems and its ports
Embedded systems and its ports
 
I2C
I2CI2C
I2C
 
8051 serial communication-UART
8051 serial communication-UART8051 serial communication-UART
8051 serial communication-UART
 
Interrupts at AVR
Interrupts at AVRInterrupts at AVR
Interrupts at AVR
 
Project
ProjectProject
Project
 
Hardware View of Intel 8051
Hardware View of Intel 8051Hardware View of Intel 8051
Hardware View of Intel 8051
 
UART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPTUART(universal asynchronous receiver transmitter ) PPT
UART(universal asynchronous receiver transmitter ) PPT
 
8051 microcontroller and it’s interface
8051 microcontroller and it’s interface8051 microcontroller and it’s interface
8051 microcontroller and it’s interface
 
AVR Micro controller Interfacing
AVR Micro controller Interfacing AVR Micro controller Interfacing
AVR Micro controller Interfacing
 
My i2c
My i2cMy i2c
My i2c
 
Arduino a000066-datasheet
Arduino a000066-datasheetArduino a000066-datasheet
Arduino a000066-datasheet
 
Inter intergrated circuits-communication protocol
Inter intergrated circuits-communication protocolInter intergrated circuits-communication protocol
Inter intergrated circuits-communication protocol
 

Similar to SENSORS AND BLUETOOTH COMMUNICATION

Bot Robo Tanker Sound Detector
Bot Robo  Tanker  Sound DetectorBot Robo  Tanker  Sound Detector
Bot Robo Tanker Sound Detector
ncct
 
accelerometer based robot.pptx
accelerometer based robot.pptxaccelerometer based robot.pptx
accelerometer based robot.pptx
Kishor Mhaske
 

Similar to SENSORS AND BLUETOOTH COMMUNICATION (20)

Ultrasonic sensors
Ultrasonic sensorsUltrasonic sensors
Ultrasonic sensors
 
Sensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controllerSensor and Actuators using Rasberry Pi controller
Sensor and Actuators using Rasberry Pi controller
 
MASS PIR
MASS PIRMASS PIR
MASS PIR
 
Sensors-and-Actuators-working principle and types of sensors
Sensors-and-Actuators-working principle and types of sensorsSensors-and-Actuators-working principle and types of sensors
Sensors-and-Actuators-working principle and types of sensors
 
Bot Robo Tanker Sound Detector
Bot Robo  Tanker  Sound DetectorBot Robo  Tanker  Sound Detector
Bot Robo Tanker Sound Detector
 
Automatic Door Opener using PIR Sensor
Automatic Door Opener using PIR SensorAutomatic Door Opener using PIR Sensor
Automatic Door Opener using PIR Sensor
 
Physical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensorsPhysical prototyping lab5-complex_sensors
Physical prototyping lab5-complex_sensors
 
Secure Surveillance Using Virtual Intelligent Agent With Dominating
Secure Surveillance Using Virtual Intelligent Agent With DominatingSecure Surveillance Using Virtual Intelligent Agent With Dominating
Secure Surveillance Using Virtual Intelligent Agent With Dominating
 
Arduino Blind Aid
Arduino Blind AidArduino Blind Aid
Arduino Blind Aid
 
Self Obstacle Avoiding Rover
Self Obstacle Avoiding RoverSelf Obstacle Avoiding Rover
Self Obstacle Avoiding Rover
 
Bluetooth Home Automation
Bluetooth Home AutomationBluetooth Home Automation
Bluetooth Home Automation
 
Arduino with brief description of sensorsppt.pptx
Arduino with brief description of sensorsppt.pptxArduino with brief description of sensorsppt.pptx
Arduino with brief description of sensorsppt.pptx
 
accelerometer based robot.pptx
accelerometer based robot.pptxaccelerometer based robot.pptx
accelerometer based robot.pptx
 
Ultrasonic_Based_Security_System
Ultrasonic_Based_Security_SystemUltrasonic_Based_Security_System
Ultrasonic_Based_Security_System
 
Radar using ultrasonic sensor and arduino.pptx
Radar using ultrasonic sensor and arduino.pptxRadar using ultrasonic sensor and arduino.pptx
Radar using ultrasonic sensor and arduino.pptx
 
Flow measurement
Flow measurementFlow measurement
Flow measurement
 
radarfinalADCA
radarfinalADCAradarfinalADCA
radarfinalADCA
 
Interfacing ultrasonic rangefinder with avr mc us
Interfacing ultrasonic rangefinder with avr mc usInterfacing ultrasonic rangefinder with avr mc us
Interfacing ultrasonic rangefinder with avr mc us
 
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY PiULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
ULTRASONIC PERIPATETIC SCANNER FOR AUTONOMOUS TEST BENCH USING RASPBERRY Pi
 
0 b0k73f kxjbk1txc5q3jmvdjhymm
0 b0k73f kxjbk1txc5q3jmvdjhymm0 b0k73f kxjbk1txc5q3jmvdjhymm
0 b0k73f kxjbk1txc5q3jmvdjhymm
 

Recently uploaded

CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
R&R Consult
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
Kamal Acharya
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
Kamal Acharya
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
Atif Razi
 

Recently uploaded (20)

fundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projectionfundamentals of drawing and isometric and orthographic projection
fundamentals of drawing and isometric and orthographic projection
 
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxCFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptx
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
Arduino based vehicle speed tracker project
Arduino based vehicle speed tracker projectArduino based vehicle speed tracker project
Arduino based vehicle speed tracker project
 
2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge2024 DevOps Pro Europe - Growing at the edge
2024 DevOps Pro Europe - Growing at the edge
 
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data StreamKIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
KIT-601 Lecture Notes-UNIT-3.pdf Mining Data Stream
 
fluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answerfluid mechanics gate notes . gate all pyqs answer
fluid mechanics gate notes . gate all pyqs answer
 
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdfONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
ONLINE VEHICLE RENTAL SYSTEM PROJECT REPORT.pdf
 
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docxThe Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
The Ultimate Guide to External Floating Roofs for Oil Storage Tanks.docx
 
Laundry management system project report.pdf
Laundry management system project report.pdfLaundry management system project report.pdf
Laundry management system project report.pdf
 
Event Management System Vb Net Project Report.pdf
Event Management System Vb Net  Project Report.pdfEvent Management System Vb Net  Project Report.pdf
Event Management System Vb Net Project Report.pdf
 
Explosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdfExplosives Industry manufacturing process.pdf
Explosives Industry manufacturing process.pdf
 
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data AnalysisIT-601 Lecture Notes-UNIT-2.pdf Data Analysis
IT-601 Lecture Notes-UNIT-2.pdf Data Analysis
 
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical SolutionsRS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
RS Khurmi Machine Design Clutch and Brake Exercise Numerical Solutions
 
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWINGBRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
BRAKING SYSTEM IN INDIAN RAILWAY AutoCAD DRAWING
 
Halogenation process of chemical process industries
Halogenation process of chemical process industriesHalogenation process of chemical process industries
Halogenation process of chemical process industries
 
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptxCloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
Cloud-Computing_CSE311_Computer-Networking CSE GUB BD - Shahidul.pptx
 
Democratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek AryaDemocratizing Fuzzing at Scale by Abhishek Arya
Democratizing Fuzzing at Scale by Abhishek Arya
 
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdfA CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
A CASE STUDY ON ONLINE TICKET BOOKING SYSTEM PROJECT.pdf
 
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
NO1 Pandit Amil Baba In Bahawalpur, Sargodha, Sialkot, Sheikhupura, Rahim Yar...
 

SENSORS AND BLUETOOTH COMMUNICATION

  • 2. SensorSensor • A sensor is a device that detects and responds to some type of input from the physical environment. • The specific input could be light, heat, motion, moisture, pressure, or any one of a great number of other environmental phenomena. • The output is generally a signal that is converted to human-readable display at the sensor location or transmitted electronically over a network for reading or further processing.
  • 4. Sensors we need to learnSensors we need to learn • PIR sensor--- Detecting Movement • Ultrasonic Sensor--- Measuring Distance
  • 5. PIR SENSORPIR SENSOR • PIR sensors allow you to sense motion, almost always used to detect whether a human has moved in or out of the sensors range. • They are small, inexpensive, low-power, easy to use and don't wear out. • For that reason they are commonly found in appliances and gadgets used in homes or businesses. • They are often referred to as PIR, "Passive Infrared", "Pyroelectric", or "IR motion" sensors.
  • 6. PIR SensorPIR Sensor • PIRs are basically made of a pyroelectric sensor  (which you can see above as the round metal can with a rectangular crystal in the center), which can detect levels of infrared radiation. • Everything emits some low level radiation, and the hotter something is, the more radiation is emitted. 
  • 7. • The PIR sensor itself has two slots in it, each slot is made of a special material that is sensitive to IR.  • When the sensor is idle, both slots detect the same amount of IR, the ambient amount radiated from the room or walls or outdoors. • When a warm body like a human or animal passes by, it first intercepts one half of the PIR sensor, which causes a positive differential change between the two halves. • When the warm body leaves the sensing area, the reverse happens, whereby the sensor generates a negative differential change. These change pulses are what is detected.
  • 8. Circuit DiagramCircuit Diagram • Pin1 -VCC • Pin 2- Output of PIR sensor connected to 2 pin of arduino • Pin 3-Ground
  • 9. int ledPin = 13; // choose the pin for the LED int inputPin = 2; // choose the input pin (for PIR sensor) int pirState = LOW; // we start, assuming no motion detected int val = 0; // variable for reading the pin status void setup() { pinMode(ledPin, OUTPUT); // declare LED as output pinMode(inputPin, INPUT); // declare sensor as input Serial.begin(9600); }
  • 10. void loop() { val = digitalRead(inputPin); // read input value if (val == HIGH) { // check if the input is HIGH digitalWrite(ledPin, HIGH); // turn LED ON if (pirState == LOW) { // we have just turned on Serial.println("Motion detected!"); // We only want to print on the output change, not state pirState = HIGH; } }
  • 11. else { digitalWrite(ledPin, LOW); // turn LED OFF if (pirState == HIGH){ // we have just turned of Serial.println("Motion ended!"); // We only want to print on the output change, not state pirState = LOW; } } }
  • 13. • An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. • It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. • By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object.  
  • 14. • Since it is known that sound travels through air at about 344 m/s (1129 ft/s), you can take the time for the sound wave to return and multiply it by 344 meters (or 1129 feet) to find the total round-trip distance of the sound wave. • Round-trip means that the sound wave traveled 2 times the distance to the object before it was detected by the sensor; it includes the 'trip' from the sonar sensor to the object AND the 'trip' from the object to the Ultrasonic sensor (after the sound wave bounced off the object). • To find the distance to the object, simply divide the round-trip distance in half.
  • 15.
  • 16. • The Trig pin will be used to send the signal and the Echo pin will be used to listen for returning signal
  • 17. Example- Distance MeasurementExample- Distance Measurement #define echoPin 7 // Echo Pin #define trigPin 8 // Trigger Pin #define LEDPin 13 // Onboard LED int maximumRange = 200; // Maximum range needed int minimumRange = 0; // Minimum range needed long duration, distance; // Duration used to calculate distance void setup() { Serial.begin (9600); pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); pinMode(LEDPin, OUTPUT); // Use LED indicator (if required) }
  • 18. void loop() /* The following trigPin/echoPin cycle is used to determine the distance of the nearest object by bouncing soundwaves off of it. */ { duration = pulseIn(echoPin, HIGH); //Calculate the distance (in cm) based on the speed of sound. distance = duration/58.2; Serial.print(Distance); Dealy(1000);}
  • 19. Interfacing DCInterfacing DC Motor WithMotor With ArduinoArduino
  • 20. DC MotorDC Motor • Working principle of a DC motor --A motor is an electrical machine which converts electrical energy into mechanical energy. • The principle of working of a DC motor is that "whenever a current carrying conductor is placed in a magnetic field, it experiences a mechanical force". • A DC motor (Direct Current motor) is the most common type of motor. DC motors normally have just two leads, one positive and one negative. • If you connect these two leads directly to a battery, the motor will rotate. If you switch the leads, the motor will rotate in the opposite direction.
  • 21. • To control the direction of the spin of DC motor, without changing the way that the leads are connected, you can use a circuit called an H- Bridge. • An H bridge is an electronic circuit that can drive the motor in both directions. • H-bridges are used in many different applications, one of the most common being to control motors in robots. • It is called an H-bridge because it uses four transistors connected in such a way that the schematic diagram looks like an "H." 
  • 22. • You can use discrete transistors to make this circuit, but for this lecture, we will be using the L293d/L298 H-Bridge IC. • In L293 all four input- output lines are independent, while in L298, a half H driver cannot be used independently, full H driver has to be used. • Protective Diodes against back EMF are provided internally in L293D but must be provided externally in L298. • The L298 can control the speed and direction of DC motors and stepper motors and can control two motors simultaneously. • Its current rating is 2A for each motor. At these currents, however, you will need to use heat sinks.
  • 23. L293D Motor Driver ICL293D Motor Driver IC
  • 24.
  • 25. Controlling Speed of DCControlling Speed of DC MotorMotor • We will connect the Arduino to IN1 (pin 5), IN2 (pin 7), and Enable1 (pin 6) of the L293d IC. Pins 5 and 7 are digital, i.e. ON or OFF inputs, while pin 6 needs a pulse-width modulated (PWM) signal to control the motor speed.
  • 26. const int pwm = 2 ; //initializing pin 2 as pwm const int in_1 = 8 ; const int in_2 = 9 ; //For providing logic to L293d IC to choose the direction of the DC motor void setup() { pinMode(pwm,OUTPUT) ; //we have to set PWM pin as output pinMode(in_1,OUTPUT) ; //Logic pins are also set as output pinMode(in_2,OUTPUT) ; }
  • 27. void loop() { //For Clock wise motion , in_1 = High , in_2 = Low digitalWrite(in_1,HIGH) ; digitalWrite(in_2,LOW) ; analogWrite(pwm,255) ; delay(3000) ; /*setting pwm of the motor to 255 we can change the speed of rotaion by chaning pwm input but we are only using arduino so we are using higest value to driver the motor */
  • 28. //For brake digitalWrite(in_1,HIGH) ; digitalWrite(in_2,HIGH) ; delay(1000) ; } //For brake digitalWrite(in_1,HIGH) ; digitalWrite(in_2,HIGH) ; delay(1000) ; //For Anti Clock-wise motion - IN_1 = LOW , IN_2 = HIGH digitalWrite(in_1,LOW) ; digitalWrite(in_2,HIGH) ; delay(3000) ;
  • 30. IntroductionIntroduction  Bluetooth is a wireless communication technology used for exchange of data over short distances.  It is found in many devices ranging from mobile phones and computers.  Bluetooth technology is a combination of both hardware and software.  It is intended to create a personal area networks (PAN) over a short range.  It operates in the unlicensed industrial, scientific and medical (ISM) band at 2.4 to 2.485 GHz.  It uses a radio technology called frequency hopping spread spectrum (FHSS).
  • 31. FHSSFHSS • Frequency hopping spread spectrum (FHSS) is a method of transmitting radio signals by shifting carriers across numerous channels with pseudorandom sequence which is already known to the sender and receiver. • Frequency hopping spread spectrum is defined in the 2.4 GHz band and operates in around 79 frequencies ranging from 2.402 GHz to 2.480 GHz. • Every frequency is GFSK modulated with channel width of 1MHz and rates defined as 1 Mbps and 2 Mbps respectively. • Frequency hopping spread spectrum is a robust technology with only very little influence from reflections, noise and other environmental factors
  • 32.  It is a packet-based protocol with a master-slave structure.  Each master can communicate with up to 7 slaves in a piconet.  The range of Bluetooth depends upon the class of radio using.  Class 3 radios have range up to 1 meter or 3 feet.  Class 2 radios have range of 10 meters or 33 feet.  Class 1 radios have range of 100 meters or 300 feet.  The most commonly used radio is Class 2.
  • 33. Advantages andAdvantages and DisadvantagesDisadvantages Advantages  The biggest advantage of using this technology is that there are no cables or wires required for the transfer of data over short ranges.  Bluetooth technology consumes less power when compared with other wireless communication technologies.  For example Bluetooth technology using Class 2 radio uses power of 2.5 mW.  As it is using frequency hopping spread spectrum radio technology there is less prone to interference of data if the other device also operates in the same frequency range.  Bluetooth doesn’t require clear line of sight between the synced devices.
  • 34. Disadvantage  Since it uses the greater range of Radio Frequency (RF), it is much more open to interception and attack.  It can be used for short range communications only.  Although there are fewer disadvantages, Bluetooth still remains best for short wireless technology.
  • 35. Introduction to HC-05Introduction to HC-05 and HC-06 Modulesand HC-06 Modules HC 05  HC-05 is a class 2 Bluetooth module with Serial Port Profile (SPP).  It can be configure either as master or salve.  It is a replacement for wired serial connection.  The module has two modes of operation, Command Mode where we can send AT commands to it and Data Mode where it transmits and receives data to another bluetooth module.
  • 36.
  • 37.  HC-05 Specification:  Bluetooth Protocol : Bluetooth Specificatio v2.0 + EDR  Frequency : 2.4 GHz ISM band  Profiles : Bluetooth Serial Port  Working Temperature : -20 to + 75 centigrade  Power of emitting : 3 dBm  The pins on the module are:  Vcc – Power supply for the module.  GND – Ground of the module.  TX – Transmitter of Bluetooth module.  RX – Receiver of the module.  Key – Used for the module to enter into AT command mode.
  • 38.  The default mode is DATA Mode, and this is the default configuration, that may work fine for many applications: Baud Rate: 9600 bps, Data : 8 bits, Stop Bits: 1 bit, Parity : None, Handshake: None  Passkey: 1234  Device Name: HC-05
  • 39. HC 06  HC-06 is a drop-in replacement for wired serial connection.  This can be used as serial port replacement to establish connection between PC and MCU (Microcontroller).  This is a Slave Mode only Bluetooth device.  HC-06 offers encrypted connection  This module can be configured for baud rates 1200 to 115200 bps
  • 40. Hooking up with ArduinoHooking up with Arduino  The connections are: HC-05 Arduino Vcc -----------> 5V GND -----------> GND TX -----------> RX RX -----------> TX
  • 41.  Let’s control theLet’s control the LED on ArduinoLED on Arduino using a basic code tousing a basic code to send command oversend command over Bluetooth.Bluetooth.  The code is shown:The code is shown: void setup() { Serial.begin(9600); pinMode(13,OUTPUT); } void loop() { if(Serial.available()) { ch=Serial.read(); if(ch=='h') { digitalWrite(13,HIGH); } if(ch=='l') { digitalWrite(13,LOW); } } }
  • 42. Configuring HC-05 withConfiguring HC-05 with AT commandsAT commands  HC-05 can be configured i.e. its name and password can be changed and many more using AT commands.  It can also be configured as either master or slave.  To set the HC-05 into AT command mode the KEY pin of the module is made high i.e. it is connected to either 5V or 3.3V pin of Arduino and TX of Arduino is connected to TX of HC-05 and RX of HC- 05 to RX of Arduino.
  • 43.
  • 44.  To enter the AT commands open up the COM port of the Arduino to which the Bluetooth module is connected and set the baud rate to 38400.  After opening COM port if you enter command “AT” (without quotes) it should return “OK” thus it can be said that HC-05 entered into AT command mode.  Refer following link for detailed AT commands and its descriptions:  http://www.linotux.ch/arduino/HC- 0305_serial_module_AT_commamd_set_201104_revise d.pdf
  • 45. Popular AT commandsPopular AT commands 1. AT 2. AT+RESET 3. AT+VERSION? 4. AT+ORGL 5. AT+ADDR? 6. AT+ ROLE? 7. AT+NAME? 8. AT+PSWD? 9. AT+UART? 10. AT+STATE? 11. AT+DISC 12. AT+BIND? 13. AT+RMAAD? 14. AT+ADCN? 15. AT+MRAD? 16. AT+PAIR
  • 46. access AT commandaccess AT command modemode • Some bluetooth mode does not have KEY pin. • In such module, different approach is considered: • first connect the Bluetooth module to an Arduino (Nano, UNO or whatever) using the following connections… • HC-05 GND –> Gnd • HC-05 VCC –> +5V (initially disconnected)  * • HC-05 TX –> D2 (any pin as required) • HC-05 RX –> D3 (any pin as required) • STATE (output) and EN (input) are not connected
  • 47. • Follow these steps: 1. Disconnect the power to the HC-05 module. 2. Load the sketch to the Arduino 3. Depress the small reset button on the HC-05 module and hold it down while you connect its Vcc pin to +5V. • The red LED on the module (that would otherwise be blinking quickly) will flash slowly indicating it is in AT mode. • Open a serial monitor in the Arduino IDE (or any other terminal software) and set its baud rate to 57600 and ensure that on the IDE serial terminal, ensure “Both NL & CR” is selected. • You should then see the prompt “Enter AT commands: “. • You can then type your AT commands into the terminal input line and have them control the HC-05. 
  • 48. • Here are a few AT commands that I found useful: • To ensure the unit is responding, enter AT. The unit should respond OK • To return the HC-05 to its default settings, enter AT+ORGL • To see the version of your HC-05 enter AT+VERSION? • To change the name of the device to AJCLOCK, for example, enter AT+NAME=AJCLOCK • To change the default security code (1234) to 2332 enter AT+PSWD=2332 • To check baud rate, enter AT+UART? (my unit reset to 38400) • To change baud rate to say, 115200, 1 stop bit, 0 parity, enter AT+UART=115200,1,0
  • 49. CodeCode• #include <SoftwareSerial.h> • SoftwareSerial btSerial(2, 3); // RX | TX • void setup() { • Serial.begin(57600); • Serial.println("Enter AT commands:"); • btSerial.begin(38400); // HC-05 default speed in AT command more • } • void loop() { • if (btSerial.available()) • Serial.write(btSerial.read()); • if (Serial.available()) • btSerial.write(Serial.read()); • }
  • 51. • A servo motor allows a precise control of the angular position, velocity, and acceleration. It’s like you’re at the steering wheel of your car. • You control precisely the speed of the car and the direction. • These servos are essential parts if we need to control the position of objects, rotate sensors, move arms and legs, drive wheels and tracks, and more.
  • 52. • Inside the micro servo, you will find the pieces from the above image. • The top cover hosts the plastic gears while the middle cover hosts a DC motor, a controller, and the potentiometer.
  • 53. • The servo motor has three leads, with one more than a DC motor. • Each lead has a color code. So you have to connect the brown wire from the micro servo to the GND pin on the Arduino. • Connect the red wire from the servo to the +5V on the Arduino. And finally, connect the orange wire from the SG90 servo to a digital pin (pin 9) on the Arduino.
  • 54.
  • 55. SweepSweep #include <Servo.h> Servo myservo; // create servo object to control a servo // twelve servo objects can be created on most boards int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for (pos = 0; pos <= 180; pos += 1) { // goes from 0 degrees to 180 degrees // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for (pos = 180; pos >= 0; pos -= 1) { // goes from 180 degrees to 0 degrees myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } }
  • 56. ProgramProgram •#include <Servo.h> •Servo myservo; // create servo object to control a servo •int potpin = 0; // analog pin used to connect the potentiometer •int val; // variable to read the value from the analog pin •void setup() { • myservo.attach(9); // attaches the servo on pin 9 to the servo object •} •void loop() { • val = analogRead(potpin); // reads the value of the potentiometer (value between 0 and 1023) • val = map(val, 0, 1023, 0, 180); // scale it to use it with the servo (value between 0 and 180) • myservo.write(val); // sets the servo position according to the scaled value • delay(15); // waits for the servo to get there •}