0% found this document useful (0 votes)
63 views

Bluetooth Based Monitoring & Control System

This document describes the steps to create a Bluetooth-controlled room temperature monitoring and control system with automatic and manual modes. It uses an LDR sensor to detect light levels and control an LED automatically based on dawn and dusk. A temperature sensor measures room temperature and controls blue and red LEDs as well as a buzzer based on temperature thresholds. The system can be controlled manually via the sensor readings or automatically using a Bluetooth module connected to an app.

Uploaded by

Towsif
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
63 views

Bluetooth Based Monitoring & Control System

This document describes the steps to create a Bluetooth-controlled room temperature monitoring and control system with automatic and manual modes. It uses an LDR sensor to detect light levels and control an LED automatically based on dawn and dusk. A temperature sensor measures room temperature and controls blue and red LEDs as well as a buzzer based on temperature thresholds. The system can be controlled manually via the sensor readings or automatically using a Bluetooth module connected to an app.

Uploaded by

Towsif
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Bluetooth Based Monitoring & Control

System
Automatic Dawn to Dusk Light with manual override
Step 1 : Usage of LDR
LDR means Light Dependent Resistor. LDR is a sensor which detects light intensity in the
environment. Attaching a 10K Ohm resistor with one of the legs of LDR is a must. So in the
breadboard, an LDR was connected to a 10K Ohm resistor attaching to the ground and the other
leg was connected to A3 pin, as the LDR gives out an analog voltage as output.

Step 2 : Analyzing LDR Output


Portraying the output of LDR, a threshold value 200 is selected as the differentiator of day and
night , which detect the change in dawn and dusk. So the code is constructed as,

const int ldrPin = A0;


void setup() {
Serial.begin(9600);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 200) { //night
}
else { //day
}
}

Step 3 : Lighting a White LED


LED stands for Light Emitting Diode which creates light if there is a voltage difference in
between the two legs of the LED. The voltage difference controls the light intensity but it
requires a forward operating voltage of between approximately 1.2 to 3.6 volts. It is attached to
the pin 2, as it needs a digital input, 1/high to on and 0/low to off.
So after connecting the LED and setting it on at night and off at day, the code looks like,

const int ldrPin = A0;


const int ledPin = 2;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
pinMode(ldrPin, INPUT);
}
void loop() {
int ldrStatus = analogRead(ldrPin);
if (ldrStatus <= 200) {
digitalWrite(ledPin, HIGH); }
else {
digitalWrite(ledPin, LOW); }
}

Step 4 : Connecting Bluetooth module


The bluetooth module works on serial communication. Bluetooth Electronics Android app is
designed to send serial data to the Arduino Bluetooth module when a button is pressed on the
app. The Arduino Bluetooth module at the other end receives the data and sends it to the Arduino
through the TX pin of the Bluetooth module (connected to RX pin of Arduino). In the
breadboard , RX (Pin 0) of arduino is connected to the bluetooth module’s TX pin. Likewise
arduino’s TX (Pin 1) is connected to the module's RX pin. VCC is connected to 5v and GND
pin is connected to the ground.
From the code, Arduino checks the received data and compares it. If the received data is 1, the
LED turns ON. The LED turns OFF when the received data is 0.

const int ledPin = 2;


char data = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
if(Serial.available() > 0)
{
data = Serial.read();
Serial.print(data);
Serial.print("\n");
if(data == '1') //Checks whether value of data is equal to 1
digitalWrite(ledPin, HIGH); //If value is 1 then LED turns ON
else if(data == '0') //Checks whether value of data is equal to 0
digitalWrite(ledPin, LOW); //If value is 0 then LED turns OFF
}
else
{ //manually control by ldr
}
}

Room temperature controller with manual override and high


temperature alarm

Step 5 : Temperature sensor


The temperature sensor can measure a fairly wide range of temperature (-50°C to 125°C) which
is precise up to 1 decimal point (0.1°C resolution). Pin1 of the sensor is VCC and pin3 is GND.
So pin1 is connected to 5v of the arduino and pin3 is connected to ground. Pin2 of the sensor
gives analog voltage as output. So it is connected to A3.

int tempPin = A0;


int tempIn;
double temp;

void setup() {
Serial.begin(9600);
}
void loop() {
tempIn = analogRead(tempPin);
temp = (double)tempIn / 1024; //find percentage of input reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5; //Subtract the offset
temp = temp * 100; //Convert to degrees celsius
}

Step 6 : Connecting Blue and Red LED


The Blue LED is connected to pin5 and red to pin6. Now if the room temperature is low then the
Red light will be on and if the temperature is high then the blue light will be on. So the code will
be,

int tempPin = A0;


const int redledPin = 6;
const int blueledPin = 5;
int tempIn;
double temp;

void setup() {
Serial.begin(9600);
pinMode(redledPin, OUTPUT);
pinMode(blueledPin, OUTPUT);
}
void loop() {
tempIn = analogRead(tempPin);
temp = (double)tempIn / 1024; //find percentage of input reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5;
temp = temp * 100; //Convert to degrees celsius
if (temp < 23.0) { //room temp is low
digitalWrite(redledPin, HIGH);
digitalWrite(blueledPin, LOW);
}
else if (temp > 28.0) { //room temp is high
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, HIGH);
}
}

Step 7 : Adding Buzzer


A resistor(100 Ohm) or transistor is needed to connect in between buzzer and arduino. The
buzzer is connected to the pin2 and the ground of the buzzer is connected to ground.
Heat sensors use 58 degree celsius as the threshold value to sound fire alarms. So here for fire
alarms the temperature is considered to be 58 degree celsius or higher.
So the code will be,

int tempPin = A0;


const int redledPin = 6;
const int blueledPin = 5;
const int buzzer = 2;
int tempIn;
double temp;

void setup() {
Serial.begin(9600);
pinMode(redledPin, OUTPUT);
pinMode(blueledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
tempIn = analogRead(tempPin);
temp = (double)tempIn / 1024; //find percentage of input reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5;
temp = temp * 100; //Convert to degrees celsius
if (temp < 23.0) { //room temp is low
digitalWrite(redledPin, HIGH);
digitalWrite(blueledPin, LOW);
noTone(buzzer);
}
else if (temp > 28.0 and temp < 58.0) { //room temp is high
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, HIGH);
noTone(buzzer);
}
else if (temp >= 58.0) { //fire alarm
tone(buzzer, 1000);
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, LOW);
}
}

Step 8 : Control Blue and Red LED through Bluetooth


So, the bluetooth module will be used again here to control the two LED lights.
There will be an automatic mode where the LED switches on and off based on user input and
manual mode where it works through sensor output. And also print temperature value through a
gauge.

int tempPin = A0;


const int redledPin = 6;
const int blueledPin = 5;
const int buzzer = 2;
int tempIn;
double temp;

void setup() {
Serial.begin(9600);
pinMode(redledPin, OUTPUT);
pinMode(blueledPin, OUTPUT);
pinMode(buzzer, OUTPUT);
}
void loop() {
tempIn = analogRead(tempPin);
temp = (double)tempIn / 1024; //find percentage of input reading
temp = temp * 5; //multiply by 5V to get voltage
temp = temp - 0.5;
temp = temp * 100; //Convert to degrees celsius
if(Serial.available() > 0) { //automatic
data = Serial.read();
if(data == '1') {
digitalWrite(redledPin, HIGH);
digitalWrite(blueledPin, LOW);
noTone(buzzer);
}
else if(data == '0'){
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, HIGH);
noTone(buzzer);
}
}
else { //manual
if (temp < 23.0) { //room temp is low
digitalWrite(redledPin, HIGH);
digitalWrite(blueledPin, LOW);
noTone(buzzer);
}
else if (temp > 28.0 and temp < 58.0) {
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, HIGH);
noTone(buzzer);
}
}
if (temp >= 58.0) {
tone(buzzer, 1000);
digitalWrite(redledPin, LOW);
digitalWrite(blueledPin, LOW);
}
Serial.print("*T"+String(temp)+"*");
}

You might also like