The Assignment was to make an arduino project that can be controlled through out a Bluetooth module whether it is working with a mobile phone App or PC GUI....
The project should have atleast two action components but single coloured LEDs are not counted...
My project was a tiny simulation for a simple room which has a light bulb and a fan which can be controlled using Bluetooth and a mobile phone GUI. The user can control both the light and the fan by using virtual buttons on the app or by using Vocal command through the app also.
The final out come ^^
I used:
For wiring and designing: Tinkercad
For coding: Arduino IDE
For Bluetooth controlling as GUI: Arduino Bluetooth control App (you can download from here)
Components:
HC-05 Bluetooth module
2x 1 channel relay module
5V DC fan
DC light bulb
5V regulator
LCD screen with I2C module
Arduino Uno R3
breadboard
Jumpers
3x 1kohms resistors
9-12V power supply
The preparation process has three parts:
Understanding how the project works.
Hardware connections (circuit design).
Coding
Understanding how the project works:
The project is quite simple:
The user powers up the project (the Arduino)
pair his mobile phone with the Bluetooth module (you can see how in this) and then using the GUI app to connect to the blue tooth module to sent the data or receive..
The user has two ways to control the outputs:
Using virtual buttons (which are in the app)
To turn on the fan the user should Press (1)
To turn off the fan the user should Press (2)
To turn on the light the user should Press (3)
To turn off the light the user should Press (4)
Using Vocal commands through out the app
To turn on the fan the user should say LOUD and CLEAR "fan on"
To turn off the fan the user should say LOUD and CLEAR "fan off"
To turn on the light the user should say LOUD and CLEAR "light on"
To turn off the light the user should say LOUD and CLEAR "light off"
The LCD Screen shows if the user is connected and shows what is turned on and what is turned off..
Preparing the GUI to Start:
This video will show you how to prepare your GUI and sync it with the code you write....
Hardware connections:
The connection of the Bluetooth module
The connection of the LCD screen
The connection of the 5V regulator
The connection of the DC light bulb and one of the relays
The connection of the DC fan and the other relay
The colour code and connections is EXPLAIND but it will destroy your eye sight HAVE FUN ^^.
Hardware connections:
(1) The connection of the Bluetooth module:
the Bluetooth module has 6 pin, we will use 5 pins:
STATE (the green jumper is connected to pin 7 on the Arduino)
RXD (is connected with a terminal of one of the 1k ohms resistors and the other terminal is considered as a node and the pic here will show the details )
TXD (the orange jumper is connected to pin 0 on the Arduino)
GND (the black jumper is connected to the ground rail on the breadboard which is connected to the GND pin of the Arduino next to the 5V pin through a blue jumper)
VCC (the red jumper is connected to the 5V rail on the breadboard which is connected to the 5V pin on the Arduino through a red jumper)
(2) The connection of the LCD screen
the LCD with the I2C module has 4 pins :
GND (the orange jumper is connected to the ground rail on the breadboard)
VCC (the yellow jumper is connected to the 5V rail on the breadboard)
SDA (the green jumper is connected to A4 pin on the Arduino)
SCL (the blue jumper is connected to A5 pin on the Arduino)
(3) The connection of the 5V regulator:
the regulator has 3 pins:
IN (node 1) (is connected to the positive terminal of the power supply through a white jumper)
GND (node 2)(is connected to the negative terminal of the power supply through a black jumper) (is connected to the ground of the Arduino through a blue jumper connecting it to the ground rail)
OUT (is connected to the positive terminal of the DC fan through a brown jumper)
(4) The connection of the DC light bulb and one of the relays:
The relay has 6 pins we will use 5:
CM (is connected to node 2 with a black jumper)
NO (is connected to one terminal of the light bulb through a brown jumper connected to a black crocodile)
(The other terminal of the light bulb is connected to node 1 through a white crocodile and a grey jumper)
VIN (is connected to the 5V rail on the breadboard through an orange jumper)
GND (is connected to the ground rail on the breadboard through a grey jumper)
IN (is connected to a yellow jumper connected to the breadboard where an orange jumper connect it to pin 9)
(5) The connection of the DC fan and the other relay:
As said before the relay has 6 pins and we will use 5:
CM (is connected to node 2 with a grey jumper)
NO (is connected to the negative terminal of the DC fan through a brown jumper)
(The positive terminal of DC fan is connected to the output pin of the 5V regulator through a brown jumper)
VIN (is connected to the 5V rail on the breadboard through a white jumper)
GND (is connected to the ground rail on the breadboard through black jumper)
IN (is connected to a yellow jumper connected to pin 8)
A full view of the connections
Coding:
Here you will find the actual used code and to understand it you will have these comments to guide your way through.....
As for the LCD screen I used the Library in this Tutorial..
/* This is a Simple room controlled by bluetooth through a mobile phone GUI
the user acn use virtual buttons or Vocal commands to control a DC lamp and a DC fan*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h> // installing or using a library to make coding LCD easier..
LiquidCrystal_I2C lcd(0x27, 16, 2);
char input = '0'; // a variable to store the input data from the Bluetooth module
int x = 0; // avriable to store the state of the Bluetooth module whether it is connected or not
int fan = 8;
int light = 9;
void setup() {
Serial.begin (9600);
pinMode(7, INPUT);
pinMode(fan, OUTPUT);
pinMode(light, OUTPUT);
/// Preparing the LCD
lcd.begin();
lcd.backlight();
lcd.clear();
lcd.setCursor(1, 0);
//Checking if the Blutooth module is connected or not
while (x == 0)
{
x = digitalRead(7);
}
if (x == 1)
{
Serial.println ("Coneccted !!");
lcd.setCursor(1, 0);
lcd.print ("Connected !!");
}
// put your setup code here, to run once:
}
void loop() {
//Importing data through serial connection
while (Serial.available() == 0);
input = Serial.read();
Serial.println(input);
lcd.clear();
lcd.setCursor(7, 0);
lcd.print(input);
////////fan control
if (input == '1')
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Fan is ON!");
digitalWrite(fan, HIGH);
}
if (input == '2')
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Fan is OFF!");
digitalWrite(fan, LOW);
}
//////////////Light control
if (input == '3')
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Light is ON!");
digitalWrite(light, HIGH);
}
if (input == '4')
{
lcd.clear();
lcd.setCursor(3, 0);
lcd.print("Light is OFF!");
digitalWrite(light, LOW);
}
// put your main code here, to run repeatedly:
}
Controlling using Virtual buttons
Controlling using Vocal commands
Things I've learnt:
I learnt from people on slack that I should remove the jumpers which are connected to the RX and TX pins in the Arduino before uploading the code.
I learnt while working with My team through out the hackathon that an unstable structure can cause some components to carry loads that would result in deflection or damage to the component....
Challenges I faced:
After I finished writing the code and uploading it to the Arduino I saw that the relay controlling the light bulb is not working so I summoned the multimeter and checked the out voltage of the Arduino pin and it was 1.7V -3.5V I didn't know why this value appeared until I took a glimpse of a mistake in the code where I didn't pinMode this pin as OUTPUT pin ... I pinModed it and it worked ....
After I am done with the code and rewired the circuit I sensed a strange behaviour and that was because a mistake in the wiring I DIDN'T make the ground common for all the components .
Title of Media
Title of Media