Introduction: Robo_Room (Room Automation)
I have always wanted to automate my room and have the ability to control lights and fans using my phone.
WARNING:
This project involves tampering with live AC Voltage (220VAC) which can kill you. I take no responsibility for any damage caused by this project and I suggest you only attempt this project if you have experience with electronics.
Lets start the project!
Step 1: The Parts Needed
Not many components are needed for this build and they are all listed below:
1. An Arduino board (I used the Arduino Uno)
2. A Relay module (I used an 12V 8 channel relay module for future expansion, a 5V module will be better)
-------------------------------------------------------------------------------------------------------------------------------------------------
If you have purchased a 12V relay module, you will also need:
1. A PNP transistor (I used a BC557) - 1 for each relay
2. A 1k resistor - 1 for each relay
------------------------------------------------------------------------------------------------------------------------------------------------------
3. A Bluetooth module (I used the HC-05)
4. 3 resistor of any value. These are for the HC-05. (I used 220ohm resistors)
5. A 12V power supply not exceeding the current of 2 9V batteries.
6. The appliances to be included
7. An AC plug
8. Screw terminals
9.Breadboard and connecting wires (the circuit can be soldered as well)
10. Electrical tape (for insulation)
Step 2: The Circuit
As shown above the circuit is quite simple. The transistor circuit and the 12V going to Arduino GND can be removed if you have a 5V relay module.
The Bluetooth module operated at a 3.3V logic level while the arduino operates at a logic level of 5V, thus the 3 resistors form a voltage divider in the circuit.
To Connect the Bluetooth Module.....
Connect the Rx pin to arduino Tx using the Voltage divider shown above
Connect the Tx pin to arduino Rx
Connect the Vcc to arduino 5V
Connect the GND to arduino GND
Step 3: The Arduino Code
In the code we must first define the variables for the connected relays and the data received via Bluetooth.
int relay = 13;
int relay2 = 12;
int state;
Then in the void setup, the pin mode must be defined and the serial communication must be initialized:
void setup()
{
pinMode(relay, OUTPUT);
pinMode(relay2, OUTPUT);
Serial.begin(9600);
}
Next in the void loop, the data must be received and stored in the variable we made earlier:
void loop()
{
if (Serial.available() > 0)
{
state = Serial.read();
}
Continuing with the void loop, the task to be executed for each data byte must be set, an example for one follows:
if (state == '1')
{
digitalWrite(relay, HIGH);
}
End the void loop with a closed curly bracket:
}
That is all for the code. You can add more functions for separate bytes of data.
Step 4: Results
Here are the results of the project. At the moment I am using an application called ArduinoRC on android to control the lights because I am still working on the personalized application.
If you can't view the video here, watch it using this link : https://www.youtube.com/watch?v=LGOTq8bHhm0
Step 5: Future Improvements
In the near future, I wish to connect more appliances to my project such as fans, etc. I would also like to control the room using my own application made using MIT app inventor.
Step 6: Adding IOS Control With an Annikken Andee Shield
Recently, I bought a new shield for my arduino. The Annikken Andee Shield allows me to create a custom app which controls the arduino's outputs and receives inputs from the arduino via Bluetooth. Using the specified library, I created the app for my iPhone and can now control my Room through my iPhone and a custom built app with just the buttons, sliders and display boxes I need.
To learn to create a similar project with the Annikken Andee, visit https://www.annikken.com/learn-more.
I used the same code as with the HC-05 module but tweaked the control sequences to allow virtual buttons to control the relays and virtual display boxes on my phone to display the state of each appliance. The Annikken Andee shield is available for both IOS and Android devices.