Arduino UNO Smart Home Lighting Simulation w/LEDs, HC-05 Bluetooth Module + mBlock 3 [Tutorial]
Summary
TLDRThis tutorial guides viewers on creating a smart home lighting system using Arduino components and an Android phone. It covers wiring the Arduino Uno board with LEDs, resistors, and an HC-05 Bluetooth module. The process involves connecting the setup to an Android device using the Arduino Bluetooth controller app, programming the system with Mblock software, and controlling the lights via Bluetooth commands. The video concludes with a demonstration of the system's functionality, showcasing how to turn lights on and off remotely.
Takeaways
- 🔧 The tutorial is about creating a smart home lighting system using Arduino components and an Android phone.
- 📱 An Android app called Arduino Bluetooth Controller is used to control the system, demonstrated with a Samsung phone.
- 💡 The main components include an Arduino Uno R3 board, breadboard, 3 LEDs, resistors, jump wires, and an HC-05 Bluetooth module.
- 🛠 The wiring involves connecting the Arduino to the breadboard, LEDs, resistors, and Bluetooth module as per the Fritzing diagram.
- 🔌 The Bluetooth module HC-05 connects with the Arduino board using TXD and RXD pins for communication.
- 📶 The Bluetooth module is powered up and tested by pairing it with an Android phone, using password 1234.
- 💻 MBlock software (version 3) is used to program the Arduino and control the system. Custom extensions for Bluetooth programming are required.
- 🔢 The system is programmed to respond to specific numeric inputs (e.g., 4 to turn on the living room light, 1 to turn it off).
- 🛑 The RX pin must be disconnected while uploading the program to the Arduino board to avoid upload failure.
- 🖱 Once programmed, the Android app can control the lights using buttons instead of typing commands, providing a user-friendly interface.
Q & A
What components are required to build the smart home lighting system using Arduino?
-The required components include an Arduino Uno R3 board, a breadboard, three LED lights, three 220-ohm or 1k-ohm resistors, nine jumper wires, an HC-05 Bluetooth module, and an Android phone with the Arduino Bluetooth controller app.
How do you connect the Arduino Uno board to the breadboard?
-You start by connecting the ground wire from the Arduino to the negative rail on the breadboard, and the 5V wire from the Arduino to the positive rail.
What is the role of the HC-05 Bluetooth module in the project?
-The HC-05 Bluetooth module enables wireless communication between the Arduino setup and the Android phone, allowing the user to control the LEDs remotely via Bluetooth.
How do you ensure proper wiring of the Bluetooth module to the Arduino board?
-You connect the TXD (transmit) pin on the Bluetooth module to the RX (receive) pin on the Arduino and the RXD pin on the Bluetooth module to the TX pin on the Arduino. Additionally, the module is powered by connecting GND to ground and VCC to the 5V rail.
What is the purpose of the resistors in the circuit?
-The resistors, connected to the negative (short) legs of the LEDs, are used to limit the current flowing through the LEDs to prevent damage.
How are the LEDs controlled using the Arduino code?
-The LEDs are connected to digital pins 5, 6, and 7 of the Arduino. By receiving specific commands (numbers) via Bluetooth, the Arduino code turns the LEDs on or off by setting the corresponding pins high or low.
What steps are involved in setting up the Arduino Bluetooth controller app on the Android phone?
-First, download the Arduino Bluetooth controller app from the Play Store. Then, pair the phone with the HC-05 Bluetooth module by entering the default password (1234). Once paired, the app can send commands to the Arduino to control the LEDs.
How do you configure the buttons in the Arduino Bluetooth controller app?
-Within the app, you assign different buttons to send specific numbers (commands) corresponding to each LED’s on/off state. For example, button 1 sends '4' to turn on the living room light, and button 2 sends '1' to turn it off.
What does the code do when the 'all lights on' command is received?
-When the 'all lights on' command (number 9) is received via Bluetooth, the code sets all the LED pins (living room, bedroom, and dining room) to HIGH, turning on all the lights.
How do you upload the Arduino program to the board and ensure the Bluetooth module doesn't interfere?
-Before uploading the program, the RX pin on the Bluetooth module must be disconnected from the Arduino board. After the upload is complete, the RX pin can be reconnected to allow Bluetooth communication.
Outlines
🔧 Setting Up the Smart Home Lighting System
In this introductory section, the host explains that the project is about creating a smart home lighting system using Arduino components and an Android phone. The app used for the project is the Arduino Bluetooth controller. A Fritzing diagram is introduced to guide the wiring setup. Components include an Arduino Uno R3 board, breadboard, LEDs, resistors, and a Bluetooth module (HC-05). Step-by-step instructions on how to connect these components are provided, including wiring the Arduino board to the breadboard and setting up the LEDs.
🔌 Connecting the Bluetooth Module
This paragraph focuses on wiring the HC-05 Bluetooth module to the Arduino. The HC-05 is used because it has six pins, differentiating it from the HC-06, which has four. Detailed instructions on wiring the module to the Arduino, including connecting the ground, VCC, TXD, and RXD pins, are given. A power test is demonstrated to confirm the Bluetooth module is functioning. Additionally, the host explains how to set up the Arduino to communicate with the module, ensuring correct connections between TX and RX pins.
📱 Pairing the Phone and the Bluetooth Module
The host moves on to pairing the Android phone with the HC-05 module. After downloading the app from the Play Store, they search for the Bluetooth device in the phone's settings, selecting HC-05 and entering the default password (1234) to pair. Once connected, attention shifts to writing the code for the Arduino, which will allow the system to control the lights. The host explains how to connect the Arduino to a computer and set up Mblock for coding, emphasizing that the correct port and board settings are crucial.
💻 Coding the Bluetooth-Controlled Lighting System
In this section, the host explains the process of writing the Arduino code. Using Mblock software, the code assigns specific pins (5, 6, 7) for each LED (living room, bedroom, dining room) and sets up a Bluetooth extension. The program uses conditional statements to turn on or off the lights based on Bluetooth signals received from the phone. The host details how to program each room’s light to respond to specific commands (e.g., typing '4' turns on the living room light).
💡 Controlling Multiple Lights Simultaneously
Here, the focus is on adding more functionality to the program. The host explains how to create commands that can turn on or off all the lights at once. The host also introduces feedback functionality, where the phone receives a message each time a light is turned on or off. This ensures the user is aware of the current status of the lights. The code is written to send a message to the phone when individual or all lights are toggled.
📲 Configuring the App for Button Controls
The host demonstrates how to configure the Arduino Bluetooth controller app, setting up buttons to control the lights through the phone. Each button is programmed to correspond with specific light commands (e.g., button 4 turns on the living room light, button 1 turns it off). The host goes through the process of customizing the button names and assigning the correct numbers to match the Arduino code. They test the app, ensuring it works as expected, allowing easy control of the lights using just the phone’s buttons instead of typing commands.
Mindmap
Keywords
💡Arduino Uno R3
💡Breadboard
💡LED
💡HC-05 Bluetooth Module
💡Resistor
💡Jump wires
💡Fritzing diagram
💡Arduino Bluetooth Controller app
💡MBlock
💡Digital input pins
Highlights
Introduction to creating a smart home lighting system using Arduino and Android components.
Components needed: Arduino Uno R3 board, breadboard, three LEDs, three resistors, jump wires, and an HC-05 Bluetooth module.
Explanation of the Fritzing diagram to help wire up the Arduino components for the lighting system.
Demonstrating how to connect the ground and 5V power from the Arduino to the breadboard.
Guidelines on how to properly position LEDs on the breadboard and distinguish between the positive (long) and negative (short) legs of the LEDs.
Instructions for wiring resistors between the LED negative legs and the ground rail to limit current and protect the LEDs.
How to wire the LEDs to digital pins 5, 6, and 7 on the Arduino, assigning each LED to a pin for control.
Introduction to the HC-05 Bluetooth module, including how to connect it to the Arduino for communication with the Android phone.
Explanation of the RX and TX pins on the HC-05 module, ensuring proper communication with the Arduino board.
Instructions to power the Bluetooth module using the VCC and ground connections from the Arduino board.
Steps to download and install the Arduino Bluetooth Controller app from the Android Play Store.
Pairing the Android phone with the HC-05 Bluetooth module, including using the default password '1234' for pairing.
Programming the Arduino in MBlock (version 3) to control the lighting system using Bluetooth commands sent from the Android phone.
Setting up variables to map each room (living room, bedroom, dining room) to specific Arduino pins controlling the LEDs.
Final testing of the Bluetooth app buttons, allowing the user to turn lights on and off remotely via the Android app.
Transcripts
hey guys in this tutorial we are going
to create a smart home lighting system
using Arduino components as well as an
Android phone so this is a Samsung phone
and we need to use an app called the
Arduino Bluetooth controller which we'll
show you in just a moment now I want you
to take a look at this Fritzing diagram
this is how we are going to wire up the
entire contraption right just for the
Arduino components so now we're gonna
start wiring this thing up now let's go
through the components together so we
have an Arduino Uno r3 board we've got a
little breadboard three LED lights you
can use any color you want I'm using red
for this example you need three 220 ohm
or 1k ohm resistors one resistor for
each of the LEDs you will need nine jump
wires these are for the Bluetooth module
and this is going to be for powering up
the five volt and the ground to the
breadboard and these cables were going
to use to plug the LEDs into the digital
in ports now speaking of Bluetooth this
is an hc-05 bluetooth module and we are
going to use that to interface this with
the sense Samsung Android phone or any
Android phone for that matter okay let's
get started so the first thing we're
going to do is we're going to plug the
Arduino board to the breadboard so I'm
going to start with the ground wire so
plug that into the negative and plug the
five volt
just right there put that into the
positive rail just like that okay that's
great okay so now once we've got that we
can space it out a little bit that's
fine
so now what we want to do is get the
LEDs plugged in so we want now keep in
mind when you work with these the
positive if we have a look the positive
is the long leg and the negative is the
short leg so we want it we want the
positive leg to be facing left so let's
say I'm gonna put this here and we'll do
the same with all the others
just follow basically what's on the
Fritzing diagram and you should have no
problems so let's get this done I think
that's okay all right I've got three
LEDs all plugged in and now let's go for
these resistors so now for the resistors
so we don't need more of these black
wires for the negative we can simply
just plug the resistor from the negative
the short leg into the negative rail so
all we have to do is just plug one there
okay we need another one so negative
rail short leg
let's just get that in it'll be quite
careful with this you might want to
straighten this out a little bit so
let's try that again so we'll plug that
in okay I think that's good enough all
right do the same for this one so plug
that in and good all right so we have
the resistors now what we want to do now
we want to plug each of these LEDs into
a respective digital input which is here
so I could just fold this cable down a
little bit so you can see it better okay
so we are going to plug the yellow cable
you can use any color cable you like but
it's fine so we're gonna plug the yellow
cable in to the long leg so we plug that
into number five we plug the gray cable
in the two number six and so we just put
that in we're also going to put the blue
cable into number seven so blue cable
into number seven
all right doesn't matter if he can't if
these cables cover up the lights it
doesn't matter too much just as long as
the lights work and then it's fine now
next thing is we want to hook up the
Arduino Bluetooth module hc-05 and you
know it's hc-05 because it has six pins
and not four pins if it's four pins it's
HC zero six now what we're going to do
is we're going to insert this into here
like that okay so it remains in place
now you can see on your Bluetooth module
you have txt and rxd txt means sending
so if the Bluetooth module is going to
send something to the Arduino board the
t XD has to be plugged into the rx okay
and the TX here when the Arduino board
is sending something to the bluetooth
module
similarly the TX has to send and receive
on the Rx or our XD TX d to Rx and the
TX here to our XD so we have to make
sure that the opposites are connected
right now first we want to power this
bluetooth module up so we connect the
one to the ground so we can put it there
and one to VCC VCC is positive so we
plug that in to the positive sorry it's
just that when I plug this in it's going
to conceal the labels as long as you
followed the diagram like I said you
should have little problems all right
now txd we're going to use the orange
cable
oh yeah if you're not sure whether this
is actually powering up or not all you
have to do is just turn it over now if I
get a power USB cable and plug it in
right see it actually lights up right so
that is providing power from the it's
getting power from the Arduino board
let's pull it out just to make sure it's
working okay now we want to plug the
orange cable in to txd and we want the
green cable into the rxd so the t XD has
to be plugged into our X on the Arduino
board so our X normally is 0 and the our
XD has to plug in to TX
just like that's a bit messy but it will
work hopefully so let's just make sure
we have all the cabling we seem to have
everything so that seems to be
everything plugged in so we've got all
the cabling we've got the resistors the
lights and we also have the Bluetooth
module we turn it around okay that's
what it looks like from one side and
this is what it looks like from the
other side so for the second part of the
tutorial we are going to download the
app for Android so that we can interface
with the Bluetooth module okay so what
we'll do is we're gonna power up the
board so we use the USB cable you can
use a battery as well but we're gonna
use a USB cable right we know it is on
because the light is actually flashing
so if I turn this around just like that
you should be able to see sorry this
board's tilted somewhat but that's okay
just make sure the cables not coming out
okay that's I think that will do right
so what we need to do is we need to get
this phone on so if we just turn this on
let's get out of this sorry I'm just
gonna punch in my passcode all right so
what we want to do is we want to go to
the Play Store or you can if you want
scan the QR code on I mean we do have a
QR code for the app but otherwise simply
go here and go to arduino bluetooth
search for our teen arduino bluetooth
you want the essay tech app also not
this one there are loads of arduino
bluetooth but we're gonna use the SI
tech app so we're gonna install this
remember this is only for Android this
does not work on iPhone and the reason
why is because iPhone is incompatible
with this there's some security issues
so you have to use Android
right so we'll just wait for that okay
once it's done you press open what we
would like to be able to do is we'd like
to be able to connect to this to the
Bluetooth module all right and if you're
not sure if it's connected what you do
is you go to your Bluetooth and you I
need to stir to search for this
Bluetooth device
right you might have to refresh the
screen so you can see the Bluetooth
device it should be called hc-05 if you
can't find it you might have to switch
off the Bluetooth switch it on and try
to rescan but eventually you should be
able to find it but if you oh yeah okay
there you go there's hc-05 you might
have to press the reset button there is
a little button here I think you can
press that so right
it's hc-05 and it's gonna ask you for a
password set the password is 1 1 2 3 4
so 1 2 3 4 then press ok and once it
says pair device you know you've done it
correctly now the next thing we're going
to do is we're going to write the code
to make this whole system work now what
we do is we want to make sure that the
Arduino board is connected to the
computer via USB cable so make sure that
it is connected and that the end of the
cable is plugged in to the computer and
on M block you go to oh and by the way
we are using M blocked version 3 this is
on Mac OS so we're gonna connect the
serial port because I'm using Mac OS the
port comes out as USB modem if you're
using a Windows computer it will be calm
and then followed by a number as in c om
so connect it you know it's connected
when the light goes from red to green
and it says ok but you also want to make
sure that you choose the right board
otherwise the program will not work so
make sure you go to boards large we know
who no and you get the Arduino blocks
for your programmer and for your board
we also need to download some extensions
because if we want to program the
Bluetooth module we need a special
extension which I have written myself
so what we do is we go to extensions
manage extensions your computer might
have this already but if not or if you
just want to check go to manage
extensions and type in P see M it will
go online and it will find three modules
that I have created myself all three
extensions actually so I download the
Bluetooth hc-05 extension okay it's
right there now I can close that I know
it's installed because now I have these
blocks for doing Bluetooth okay without
further ado we're gonna start coding I
make this bigger so you can see it a
little better
so it's let's increase the size then a
right click and upload once we are ready
to get this program we're gonna press
this upload button now if you remember
from the Fritzing diagram we have
connected three lights to digital pin
five six and seven
instead of saying five six and seven
we're going to use bedroom names okay so
we're gonna make a variable so let's say
the first light could be living room so
that's that now we need another variable
it could be bedroom so let's spell that
right this variable could be called
bedroom and then we want another one
called
let's say dining room you can call it
anything you want it really doesn't
matter right now let's say the living
room is going to be the light that's
connected to pin five so we say set the
living room to five bedroom could be six
and dining room could be seven whatever
you like just make sure you get the
right pin numbers okay these names can
be anything but you've got to get the
right pin numbers okay now the next
thing we want to check we want to set up
the Bluetooth now you want to make sure
that the port is correct
so the TX port should be connected to
zero it should actually be zero and rx
should be connected to one leave the
baud rate as it is it should be zero and
one so you need to swap the numbers
around go to control we need a forever
loop because because we want to keep
checking the Bluetooth module needs to
keep checking so what we do now what we
want to do is we want to say if we press
let's say if we type the number four if
we use the phone and we send the number
four then we won't say I don't know the
living room like to turn on or if we
type the number one then the light will
turn off okay that might sound a bit
complicated but let's give it a try
so we need an if we are using
conditional statements here so we also
need let's see what else do we need
let's go to robots let's let's focus on
living room first
so if we say if the living if the living
room okay wait right so if we get the
number four and we want this light to
turn on okay so if we receive the number
four on the phone then or it actually
yeah okay fine then we want to set the
digital pin on the Arduino board and
remember it's living room so go to data
and blocks set the living room as hi-hi
means turn at the light on the living
room on we also need another block read
data from hc-05
so we need to check what numbers coming
through the Bluetooth system and if it
gets a number four then we make it high
for the living room okay we're gonna
copy this if we want to say okay if it's
a number one then set the living room as
low okay so you do exactly the same
thing for the bedroom and the dining
room now if it helps just all you have
to do is just right click here and
duplicate duplicate means copy right so
what you have to do is just swap these
out and do it for the dining room and
for the living room but to remember you
want to have a different number for each
room so let's say I think we want four
one five two let's make that smaller
because we need to fit we need to fit
all this on so four one five two and
then we want so now we want to do the is
it the bedroom I think so so let's do
the bedroom
all right so four four and one is four
living room of five and two is four
dining room so it should be six and
three for the bedroom okay
now we're also going to make it so that
we can we want to make a button that we
press that turns on all the lights and a
button that turns off all the lights so
we're gonna make let me see how do we do
this okay so we need to copy this we'll
just copy this one so we're gonna make
it so that if we type the number nine if
we receive the number nine then we want
all the well we want all the lights
actually it's not like this we want all
the lights to be on sorry it should be
bedroom a dining room living room okay
we want all the lights to be on if it
receives the number nine and if it
receives the number zero then we want
all the lights off so in other words all
the lights set to low right
and also what we'll also do as well is
every time we turn a light off and turn
a light on we're going to send a message
to the phone to say if a certain light
is on if a certain light is off just a
double check so what we do is we say
send so we use this every time we have a
light on so let's say for the living
room so I'll just quickly type this and
so living room light on I have to do
this quickly and if you don't want to do
this part you don't need to but I
it just helps it helps me a lot it takes
a bit of time as well but I think it's
worth it so dining room light on dining
room light off and bedroom bedroom light
on and the bedroom light off hangs so we
get all those and then we want one for
all lights on and all lights off will do
this in capital letters so all lights
off and all lights on make sure you put
the right message with the right light
and the right number so let's see living
room light on it will also tell you what
this is for as well it will remind you
so it's very very useful living room
light on dining room light on and this
is where it gets really really long so
just bear with me dining room light on
bedroom light on bedroom light off it's
getting quite long I know all lights on
all lights off okay now I think we're
ready to save so what I'll do is I'll
just call it
just all that lights PCM you can call it
anything you like and now what we want
to do is we want to upload this to our
Arduino contraption so what we have to
do I do have to say that if you want to
upload a program to your Arduino board
you have to make sure that this part is
disconnected so the rx has to be taken
out otherwise you can't upload so you
must take this out and then after you
put the program in then you can put this
back you can try it but it will not
upload you have to take this out so
let's make sure it's connected right and
let's upload
and there we go and we can simply just
put this back great so we have the
contraption we have the program on the
board and now we're ready for the next
part which is to get the phone turning
these lights on now for the final part
we're going to get this phone connected
with the buttons to these lights now if
you remember we installed the Arduino
Bluetooth controller and we have
connected to the Bluetooth module if not
you'll have to get it connected okay now
so what we're gonna do just to make sure
that it actually is working we have to
go to terminal
right now we said that if we type the
number for the bedroom light or sorry
the living room light is going to turn
on so if we put in a number 4 yep this
living room light will turn on I thought
it was this light but now I've got it
wrong but it's okay I mean that's fine
all right and if we want to turn it off
we put type the number 1 and it actually
says on the screen living room light on
living room light off
so you know which light is turning on in
which light is turning off so look
living room light on living room light
off now let's test the other lights
let's try this is dining room light we
can also turn on the other light this is
the bedroom light and this is the living
room light on okay and we can also test
very useful to do testing okay living
room light off dining room light off and
bedroom light off what about all lights
on and all lights off let's give that a
try so if we type number nine it will
say all lights on all three lights light
up if we type zero all lights off
perfect but of course we are not going
to be using the terminal because it's
very cumbersome to have to keep typing
numbers you want to be able to just
press
buttons and have this thing work nobody
wants to use terminal so what we have to
do is we have to use the buttons we have
to program some buttons on this app so
that it corresponds with different
numbers now let me show you so what we
do is first we have to go back okay we
go back to here the button part is see
where it says on/off we have to click on
this one and you've got all of these
buttons okay now let's say for example I
want to I'm sorry right so let's say
we're going to what did we say for this
one we said living room so you can
change the name to living room so on is
number four off is number one so that is
correct if the name is wrong you can
rename it you just hold down the button
and you can you can change the name so
right now it says bedroom 1 it says 6
and 3 now for that one we want to say
this is 4 bedroom no this is the bedroom
actually so let's just we better type it
again
we'll just excuse me so we'll put
bedroom one word and 6 is on and sixes
off so that's good and for this one
because this is not bedroom 2 we want to
change that to dining room so we're
going to type dining room so D I n I and
excuse me not typing it properly so di
ni ng R double O M all right check your
code and just make sure yep dining room
light on dining room light off 5 and 2
respectively all right and here all on
and all office in just a double check
the names right all on is 9 of is 0 ok
now the moment of truth let's see if
this works so alright so let's say ok
I'm in the living room I want the light
on yep it's on great ok I'm in the
living room and I want to turn on the
light in the bedroom and I don't
want to go to the bedroom so I'm going
to get my phone and press bedroom yep it
works I'm not gonna leave I'm gonna
block it a turn it off I'm going to turn
on the dining room well there we go good
okay I can have different combinations
right I could do this this this this
this this and of course I could just do
that and have all lights on or lights
off and so forth
brilliant so that is your smart home
lighting system using Arduino Android
phone brilliant so give it a try and see
how far you get
remember you need to download em block
three it is free just google it and you
can use my extensions online to do the
Bluetooth module programming okay I'm
gonna have to stop it there this video
is long enough so thank you so much for
watching and all the best good luck and
see you soon take care and good bye
Посмотреть больше похожих видео
GSM Based Smart Dustbin | कचरा भरते ही मोबाइल पर मेसेज आ जाता है
Membuat Kipas Otomatis Berdasarkan Suhu Berbasis Arduino || Sensor Suhu DHT-11
DIY | Smartphone (Bluetooth) controlled Robot Arm using Arduino | HC-05
CANGGIH!!! Cara buat Kunci pintu Pakai PASSWORD
Making Traffic Lights with Arduino Uno - Beginner Level (algorithm, coding, circuit design)
Arduino To ESP32: How to Get Started!
5.0 / 5 (0 votes)