This week, we have to use Arduino and a Bluetooth module to control an input component and an output component. In order to move forward and work on my final project, I finalized all features of the project and all that remains is to integrate the Bluetooth module into the project to control it wirelessly. Therefore, this week I will work on connecting the Bluetooth module to the circuit to control the lamp via an Android mobile phone.
Components
The medium size to be suitable for the enclosure.
For the arduino.
To control the project (relay, bluetooth,...etc)
To connect the project to android smart phone which will give the arduino the input that the user will make.
Arduino can't control more than 12v device, but by the relay we can control any DC device which need 220v or 110v.
To control the project through waving our hand or by using the remote control.
An example for 220v device which the project can control.
To supply the lamp with the power.
To supply the lamp with the power.
To connect the components all together.
To connect the bulb or any other device to it which connected to the relay.
Software
To design the circuit and test it on it.
To code Arduino to do the functions of the project.
To create the android app which will send the signals to the Bluetooth module.
To create flowcharts before starting to organize and simplify the idea to me.
To upload the code on it to be open source.
To find answers to my questions during the work.
Input/action components: IR, Bluetooth, and switch.
Output components: Relay and bulb
Inserting breadboard and Arduino
Inserting relay, power source, bulb, and push-button to be the input of instead of ir sensor to see the result
GND to 220V power source.
GND to Arduino.
Power to pin 3.
Power to the bulb.
Connect the bulb to the power source.
Inserting the push-button and connect it as an input component.
Remote control: to control the IR in tinkercad.
Inserting IR sensor and connect it to pin 2 instead of the push-button and connect GND and the power and inserting IR remote control. Using the IR sensor as an additional feature to the project.
Inserting Bluetooth module and connect it to the Arduino.
GND to Arduino.
Power to Arduino.
RX to TX pin in Arduino.
TX to RX pin in Arduino.
First, I defined 3 vars {
Relay: connected to pin 6;
IR: connected to pin 7;
Bluetooth: give him a '0' value;
}
Second, I setup 3 things:
The serial communication to connect between the Arduino and the Bluetooth and the android phone. The speed is 9600.
I defined the relay as an OUTPUT component.
I defined the IR as an INPUT component.
The first part in the loop is the IR:
First, I let the arduino to get the signal of the IR, then to "Read" it.
"If" the value of the IR is (0) the relay will turn on which will let the connected device to the project (the bulb) turn on.
Then I ordered arduino to print "on" when it gets (0) value.
In the second part of the "If" condition I ordered arduino to turn off the relay if it gets any other value and print "off".
The second part of the loop is the Bluetooth:
I let Arduino to read the signal from the BT module.
Then I used "if" condition with "or" to set charterer "a" OR "o" which is the first button in the android app and the first vocal command to turn on the relay.
In "else if", I set "b" OR "z" which is the second button in the android app and the second vocal command to turn off the relay.
At the end, I tell the Arduino to turn off the relay if it gets any other input or signal.
I used the serial print to see the value of the IR and to show "Done BT" when it gets a signal from the Bluetooth.
I open the app and select the Bluetooth which I found its name on the back of the module. Then I opened the buttons and slider.
I selected "Command buttons configuration" and type 'a' for the first and 'b' for the second.
I went to voice control from the main interface of the app and entered to "Vocal commands configuration" and selected the first one.
I typed 'open' in the "vocal command" and 'o' in "data to send" for the first one. I typed 'close' in the "vocal command" and 'z' in "data to send" for the second.
Connecting the 5v pin and the gnd to the breadboard
Connecting the 2 wires to the bareeza
Connecting the power cable to the bareeza
Relay Wiring ..
Connecting the power cable to NO and CM ports
Connecting the relay to the Arduino by jumper wires: Vin to 5v pin, gnd in the relay to the gnd in arduino, and in to pin 6
Total view to relay wiring
Connecting the ir to the arduino: vcc to 5v pin, gnd in the ir to the gnd pin in the arduino, and out to pin 7
Connecting the bluetooth module: rx to tx, tx to rx, gnd to gnd, and vcc to 5v
The connected rx and tx pins in the arduino
Videos
After connecting the mobile application with the Bluetooth module, the setting should be edited by adding the initials of the words that will be used in making the orders. so it was edited with letter O for the order "open" and C for the order "close". Then, when saying "open" the Bluetooth take the order and reacts by making the lamp opens, while saying close the lamp closes.
After connecting the mobile application with the Bluetooth module, while pressing number 1 the Bluetooth take the order and reacts by making the lamp opens, while pressing 2 the lamp closes.
I tried many times to upload the code to arduino but I couldn't. I checked with my instructor Asmaa and I found that I need to disconnect rxd and txd of the bluetooth module before uploading and after that I can connect them to use the bluetooth. I tried and it worked.
The Arduino don't allow us to upload the code because there is a miscommunication happens and Arduino can't determine the sender and receiver component between the BT and the laptop. So we have to disconnect rxd and txd till uploading the code and reconnect them.
Actually, this is my Final Project without the Bluetooth module and other some features. So this the beta project :)
I loved more the idea of DIY (Do It Yourself) after this experience and I hope to do many ideas for my home and my family :)
It was the most wonderful moment in maker diploma when we created the RC car using h-bridge. I really loved this project and I loved more the competetion that we experienced, specially after wining of my team :)