You are on page 1of 24

Communication Devices:

Bluetooth, RF433 and WIFI


GMR
Syllabus
• UNIT -II:
• Integration of Sensors and Actuators with Arduino:
• Sensors: Temperature, Compass, Light, Sound, Accelerometer, DHT,
Distance Sensor
• Actuators: Servomotor, Stepper Motor, Solenoid, Relay, DC Motor
• Communication Devices: Bluetooth, RF433, Wi Fi Module
Contents

 IR remote operation (beyond syllabus)


Blue Tooth
 RF 433
Wi-Fi
IR Sensor
IR Sensor
IR Remote interfacing-LED control
Program void loop() {
if (irrecv.decode(&results))
{
#include <IRremote.h> //irrecv.decode(&results) returns true if anything is recieved,
int redLed = 5; //and stores info in varible results
int RECV_PIN = 11; unsigned int value = results.value;
//IR Library stuff //Get the value of results as an unsigned int,
IRrecv irrecv(RECV_PIN); //so we can use switch case
decode_results results; Serial.println(value);
void setup() switch (value) {
{ case 2295:
//Set Led Pins digitalWrite(redLed, HIGH);
pinMode(redLed, OUTPUT); break;
//Enable serial usage and IR signal in case 34935:
Serial.begin(9600); digitalWrite(redLed, LOW);
Serial.println("Enabling IRin"); break;
irrecv.enableIRIn(); }
Serial.println("Enabled IRin"); irrecv.resume(); // Receive the next value
} }
}
IR Remote Interfacing
Program
#include <IRremote.h>
//Define Pins void loop() {
int redLed = 5; if (irrecv.decode(&results)) case 18615:
int yellowLed = 4; {//irrecv.decode(&results) returns true if digitalWrite(greenLed, HIGH);
int greenLed = 3; anything is recieved, and stores info in varible delay(500);
int blueLed = 2; results digitalWrite(greenLed, LOW);
int RECV_PIN = 11; unsigned int value = results.value; break;
//IR Library stuff //Get the value of results as an unsigned int, so
IRrecv irrecv(RECV_PIN); we can use switch case case 10455:
decode_results results; Serial.println(value); digitalWrite(blueLed, HIGH);
void setup() switch (value) { delay(500);
{ case 2295: digitalWrite(blueLed, LOW);
//Set Led Pins digitalWrite(redLed, HIGH); }
pinMode(redLed, OUTPUT); delay(500);
pinMode(yellowLed, OUTPUT); digitalWrite(redLed, LOW);
pinMode(greenLed, OUTPUT); break; irrecv.resume(); // Receive the next value
pinMode(blueLed, OUTPUT); }
case 34935: }
//Enable serial usage and IR signal in digitalWrite(yellowLed, HIGH);
Serial.begin(9600); delay(500);
Serial.println("Enabling IRin"); digitalWrite(yellowLed, LOW);
irrecv.enableIRIn(); break;
Serial.println("Enabled IRin");
}
PIR sensor
PIR based security system which saves the power consumption and the memory
space of the recording system has been proposed. Passive Infrared Radiation
(PIR) sensor detects the change in infrared radiation of warm blooded moving
object in its detection range.
According to the change in infrared radiation, there will be a change in the
voltages generated which was amplified and used to turn ON system through
relay.
Thus the saves power consumption and the memory space of the recording
system as the lamp and webcam will only get turned ON when PIR sensors
detects an object. 
Program Codevoid loop()
{
int x;
int buzer =5; x= digitalRead(3);
int led = 9; Serial.println(x);
int pir =3; if (x == HIGH)
int x=0; {
void setup() digitalWrite(9,HIGH);
{ digitalWrite(5,LOW);
Serial.begin(9600); }
pinMode(5,OUTPUT); else
pinMode(9,OUTPUT); {
pinMode(3,INPUT); digitalWrite(9,LOW);
} digitalWrite(5,HIGH);
}
delay(10); }
Blue Tooth
• Usually, when two electronic devices communicate with each other, they use cables, infrared rays,
WiFi etc. These are some of the various complicated methods used in connecting one device to
another. Bluetooth is a similar technology, which is used to connect one electronic device to another,
without the usage of any wires and cables. It is a wireless technology to send and receive data
between two devices.
• Blue Tooth is wireless protocol to connect devices(which have bluetooth adapter) for data
communication. It uses radio waves and allow short range communication. The blue tooth proto
col operate in 2.402Ghz – 2.280Ghz range.
• Bluetooth works by the simple principle of sending and receiving data in the form of radio waves.
Every Bluetooth enabled device has a card-like attachment known as the Bluetooth adapter. It is this
Bluetooth adapter that sends and receives data. A Bluetooth adapter has a particular range of
connection. One electronic adaptor can notice another Bluetooth device only if the second device is
present within the range of the first device. When they are within the range, they can strike up a
connection between themselves. Striking up of connection between two Bluetooth devices are known
as paring of devices.
• HC-06 is a serial port Bluetooth module. Can be configured with the serial port as well
• HC-06 only works in slave mode so it must be connected to by another device (HC-05 works as either)
• Cheap wireless communication over short distances!
Principle of Operation
 The radio-wave connection between two devices is used to
send and receive data between two Bluetooth devices using
FHSS(frequency Hopping Spread Spectrum). The data send
and received at a time is equal to 720 Kilo bytes per second.
which involves splitting the frequency band of 2.402-2.480
GHz into 79 channels (called hops), each 1MHz wide.
 The data send and received at a time is equal to 720 Kilo
bytes per second. When two devices are trying to be paired,
they are actually searching for a common frequency through
which they can send and receive data.
 When such a frequency is discovered, the devices are
"found". The connecting of two devices does not hamper the
connecting of two other devices because they usually use
different channels of frequency and hence do not overlap.
void loop() {
#include "BluetoothSerial.h“
//Header File for Serial Bluetooth, will be if (ESP_BT.available())
added //by default into Arduino //Check if we receive anything from Bluetooth
{
BluetoothSerial ESP_BT; //Object for Bluetooth incoming = ESP_BT.read(); //Read what we recevive
Serial.print("Received:");
int incoming; Serial.println(incoming);
int LED_PIN = 2; if (incoming == 49)
{
void setup() { digitalWrite(LED_BUILTIN, HIGH);
Serial.begin(115200); ESP_BT.println("LED turned ON");
//Start Serial monitor in 9600 for arduino }
ESP_BT.begin("gmrbluetooth"); if (incoming == 48)
//Name of your Bluetooth Signal {
Serial.println("Bluetooth Device is Ready to Pair"); digitalWrite(LED_BUILTIN, LOW);
pinMode (LED_PIN, OUTPUT); ESP_BT.println("LED turned OFF");
//Specify that LED pin is output }
} }
delay(20);
1 (ASCII code 49 decimal: ON LED }
0:ASCII code 48 decimal: OFF LED
Example – Bluetooth module
RF433
RF433 system support wireless serial communication over radio waves. If contain
Transmitter for sending the data and Receiver for receiving data. They operate at 433MHz.
The antenna height will decide the range of communication.
Transmitter :The main module of the transmitter is the SAW resonator (tuned for 433.xx
MHz operation) along with switching transistor and a few passive components. When the
Data Input is logic HIGH the oscillator runs producing a constant RF output carrier wave at
433.xx MHz while it is logic LOW, the oscillator stops. This technique is known as Amplitude
Shift Keying.
RF433
Receiver: It consists of a RF tuned circuit and a couple of OP Amps to amplify the
received carrier wave from the transmitter. The amplified signal is further fed to a
PLL (Phase Lock Loop) which enables the decoder to “lock” onto a stream of
digital bits which gives better decoded output and noise immunity.
RF433
In Amplitude Shift Keying the amplitude (i.e. the level) of the carrier wave (in
our case it’s a 433MHz signal) is changed in response to the incoming data
signal.

Advantage : It is simple and occupies less bandwidth compared to others.


Dis Advantage: It is susceptible with other radio waves.
The RadioHead Packet is made up as follows: A 36 bit stream of “1” and “0” bit pairs, called a
“Training Preamble”, is sent at the start of every transmission. These bits are necessary for the
receiver to adjust its gain prior to getting the actual data. Followed by this, a 12 bit “Start
Symbol” and then the actual data (payload) is added.
TRANSMITTER #include <RH_ASK.h>
// Include RadioHead Amplitude Shift Keying Library #include <SPI.h>
#include <RH_ASK.h> / Create Amplitude Shift Keying Object
// Include dependant SPI Library RH_ASK rf_driver;
#include <SPI.h> void setup()
{
// Create Amplitude Shift Keying Object // Initialize ASK Object
RH_ASK rf_driver; rf_driver.init();
Serial.begin(9600);
void setup() }
{ void loop()
// Initialize ASK Object {
rf_driver.init(); // Set buffer to size of expected message
} uint8_t buf[11];
uint8_t buflen = sizeof(buf);
void loop() // Check if received packet is correct size
{ if (rf_driver.recv(buf, &buflen))
const char *msg = "Hello World"; {
rf_driver.send((uint8_t *)msg, strlen(msg)); // Message received with valid checksum
rf_driver.waitPacketSent(); Serial.print("Message Received: ");
delay(1000); Serial.println((char*)buf);
} }
}
Wi-Fi: ESP8266
• ESP8266 is a low-cost WiFi module that belongs to ESP's family. It has
an in-built microcontroller and a 1MB flash allowing it to connect to a
WiFi.
• The TCP/IP protocol stack allows the module to communicate with WiFi
signals. The maximum working voltage of the module is 3.3v.
• Let's take an example of controlling an LED light using ESP8266 by
smartphone. The ESP8266 acts as an interpreter between the LED and
the smartphone. Since we are using the Blynk app to control the LED
further explanations will be based on it.
• ESP8266 is connected to the nearby WiFi hotspot that allows it to
access the internet and sends data to the Blynk server along with
authentication code
WiFi

• An authentication code is then sent to the app that has the same authentication code and
then, the app receives the data to create a secure connection between the app and the
ESP8266.
• The data(instructions to control LED) from the Blynk app is sent to the Blynk server along
with the authentication code and since the ESP8266 has already the same authentication
code which is connected with the Blynk server, the server identifies the matching code and
data is sent to the corresponding ESP8266. Then the ESP8266 microcontroller turns ON the
LED.
#define BLYNK_PRINT Serial
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.


char auth[] = "your auth token code from blynk app";

// Your WiFi credentials. Set password to "" for open networks.


char ssid[] = "your wifi name";
char pass[] = "your wifi password";

void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
// You can also specify server: , Blynk.begin(auth, ssid, pass, "blynk-cloud.com", 80);
//Blynk.begin(auth, ssid, pass, IPAddress(192,168,1,100), 8080);
}

void loop()
{
Blynk.run();
// You can inject your own code or combine it with other sketches.
// how to communicate with Blynk. Remember to avoid delay() function!
}

You might also like