Controle de eletrodomésticos usando telefone Android

Controlling Home Appliances Using Android Phone

As technology improves, automation has become a necessity, whether at home, in the office or elsewhere. At home we find many appliances, be it fans, AC, TV, lights, etc. What if you could operate them all with the Android phone you're holding in your hand.

Protótipo de sistema de automação residencial controlado por Android Mobile

Figure 1: Home automation system prototype controlled by Android Mobile

This project aims to incorporate Android phone control over electrical appliances. We use Bluetooth communication between the Android phone and a receiver (control unit) that is connected to the devices. Bluetooth is a wireless technology standard for exchanging data over short distances (using short-wavelength UHF radio waves in the 2.4 to 2.485 GHz ISM band) from fixed and mobile devices and building personal area networks (PANs). ). Invented by telecommunications supplier Ericsson in 1994, it was originally designed as a wireless alternative to RS-232 data cables. It can connect multiple devices, overcoming synchronization problems.

The HC-05 module is an easy-to-use Bluetooth SPP (Serial Port Protocol) module designed for transparent wireless serial connection configuration. It contains 6 labeled pins on the back, but most modules only have 4 of them filled with pogo pins. KEY & STATE are not required as KEY is used to flash the device and STATE simply indicates whether the device is active or not. So that leaves just GND, VCC, TXD, RXD.

Imagem típica do Módulo Bluetooth HC-05

Figure 2: Typical image of the HC-05 Bluetooth Module

To connect the module with Arduino we need to use the serial pins (Tx and Rx) provided on the board.

Connections and Work

Making connections with HC-05:

Some modules are labeled VCC for working voltages up to ~6 volts. These modules do NOT like anything except 3.3 volts on the VCC line. We must use a level converter for 3.3V on the RXD line. Use two resistors as a simple voltage divider to convert the TTL level. Connect a 2.2k ohm resistor to ground and another 1k ohm resistor to the TXD line on the MCU. Connect the RXD pin between the two resistors to get an output of approximately 3.4 volts. Connect the module's RXD pin to the Arduino's TXD (Digital Pin 1), using the voltage divider configuration shown below:

Imagem mostrando as conexões do circuito do Arduino Uno e do módulo Bluetooth HC-05

Figure 3: Image showing the circuit connections of the Arduino Uno and the HC-05 Bluetooth Module

Now connect the TXD of the module to the RXD of the Arduino (Digital Pin 0). To operate the devices, we cannot connect them directly to the Arduino. We need something called RELAY, which is driven with the help of a transistor-based driver circuit.

Diagrama de circuito do driver de relé baseado em transistor

Figure 4: Transistor-Based Relay Driver Circuit Diagram

The 'input' is from the Arduino I/O pin. RB is the current limiting resistor at the base of the transistor. Its value is normally 10K Ohm. 'VS' is the supply voltage required to drive the relay coil (depends on the relay rating). A diode is connected in reverse in parallel to the relay. This is done to avoid the back emf generated by the coil which can damage the transistor or the Arduino.

A simplified block diagram of the complete system is shown below:

Diagrama de blocos do sistema de automação residencial controlado por Android Mobile

Figure 5: Block diagram of the home automation system controlled by Android Mobile

After making the above connections, you will see the LED blinking on the module. This just ensures your device is turned on properly. After that choose your Android phone and get the app – “ Arduino Bluetooth Terminal ” from Google Play Store. This application is available for free and is easy to use.

Captura de tela do aplicativo Android usado para controlar eletrodomésticos

Figure 6: Screenshot of the Android application used to control home appliances

After installation, turn on your phone's Bluetooth. Now search for devices until you find HC-05 and then start pairing with it. Enter the password 1234 when asked.

If paired correctly, the blinking LED on the Bluetooth module will stop. If not, check the connections again. Go back to the app you just downloaded. It will automatically find the device, match the displayed key, and start a conversation. Make sure your phone's Bluetooth stays on.

Protótipo de sistema de automação residencial controlado por Android Mobile

Figure 7: Image showing the complete prototype of the Arduino-based Android phone controlled home automation system

System Operation:

When we send '1' to Arduino, device 1 connected to Arduino turns on and when '2' is sent, device 2 turns on. The serial data is read by the Arduino, through the Serial.read function and is stored in the state of the variable of the integer type declared in the program. After that in the loop, we just compare state value with 1, 2, 3 and so on up to 8 to check the ON condition of 8 Household Appliances. Then we compare state value with a, b, c and so on until h to check the OFF state of the devices and perform the respective operation.

Furthermore, we can also monitor the physical state such as temperature, pressure, etc., through the Android phone. Let's say we need to monitor the temperature in the room. We connect the LM35 temperature sensor to the Arduino. Now read the value from the sensor and send it to the phone via the serial link established via Bluetooth between the phone and the Arduino.

Project source code

 ###



 int led1 = 2;
 int led2 = 3;
 int led3 = 4;
 int led4 = 5;
 int led5 = 6;
 int led6 = 7;
 int led7 = 8;
 int led8 = 9;
 int state;
 int flag=0;
 void setup
 {
 pinMode(led1, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(led4, OUTPUT);
 pinMode(led5, OUTPUT);
 pinMode(led6, OUTPUT);
 pinMode(led7, OUTPUT);
 pinMode(led8, OUTPUT);
 Serial.begin(9600);
 }
 void loop {
 if(Serial.available > 0)
 {
 state = Serial.read;
 flag=0;
 }
 if (state == '1')
 {
 digitalWrite(led1, HIGH);
 if(flag == 0){
 Serial.println("Appliance 1 is ON");
 flag=1;
 }
 }
   
else if (state == '2')
 {
 digitalWrite(led2, HIGH);
 if(flag == 0){
 Serial.println("Appliance 2 is ON");
 flag=1;
 }
 }
 else if (state == '3')
 {
 digitalWrite(led3, HIGH);
 if(flag == 0){
 Serial.println("Appliance 3 is ON");
 flag=1;
 }
 }
 else if (state == '4')
 {
 digitalWrite(led4, HIGH);
 if(flag == 0){
 Serial.println("Appliance 4 is ON");
 flag=1;
 }
 }
 else if (state == '5')
 {
 digitalWrite(led5, HIGH);
 if(flag == 0){
 Serial.println("Appliance 5 is ON");
 flag=1;
 }
 }

 else if (state == '6')
 {

 digitalWrite(led6, HIGH);
 if(flag == 0){
 Serial.println("Appliance 6 is ON");
 flag=1;
 }
 }
 else if (state == '7')
 {
 digitalWrite(led7, HIGH);
 if(flag == 0){
 Serial.println("Appliance 7 is ON");
 flag=1;
 }
 }
 else if (state == '8')
 { 
digitalWrite(led8, HIGH);
 if(flag == 0){
 Serial.println("Appliance 8 is ON");
 flag=1;
 }
 }
 else if (state == 'a')
 {
 digitalWrite(led1, LOW);
 if(flag == 0){
 Serial.println("Appliance 1 is OFF");
 flag=1;
 }
 }
 else if (state == 'b')
 {
 digitalWrite(led2, LOW);
 if(flag == 0){
 Serial.println("Appliance 2 is OFF");
 flag=1;
 }
 }
 else if (state == 'c')
 {
 digitalWrite(led3, LOW);
 if(flag == 0){
 Serial.println("Appliance 3 is OFF");
 flag=1;
 }
 }
 else if (state == 'd')
 {
 digitalWrite(led4, LOW);
 if(flag == 0){
 Serial.println("Appliance 4 is OFF");
 flag=1;
 }
 }
 else if (state == 'e')
 {
 digitalWrite(led5, LOW);
 if(flag == 0){
 Serial.println("Appliance 5 is OFF");
 flag=1;
 }
 }
 else if (state == 'f')
 {
 digitalWrite(led6, LOW);
 if(flag == 0){ 
Serial.println("Appliance 6 is OFF");
 flag=1;

 }
 }
 else if (state == 'g')
 {
 digitalWrite(led7, LOW);
 if(flag == 0){
 Serial.println("Appliance 7 is OFF");
 flag=1;
 }
 }
 else if (state == 'h')
 {
 digitalWrite(led8, LOW);
 if(flag == 0){
 Serial.println("Appliance 8 is OFF");
 flag=1;
 }
 }
 }

 ###

Circuit diagrams

Circuit Diagram-Arduino Based Android Controlled Home Automation System

Project video

https://www.youtube.com/watch?v=gJ3twZvrUCA

Conteúdo Relacionado

ESP32-CAM is a compact camera module that combines the...
A network of sensors is embedded in every vehicle,...
The motor controller is one of the most important...
A evolução dos padrões USB foi fundamental para moldar...
A SCHURTER anuncia um aprimoramento para sua conhecida série...
A Sealevel Systems anuncia o lançamento da Interface Serial...
A STMicroelectronics introduziu Diodos retificadores Schottky de trincheira de...
Determinar uma localização precisa é necessário em várias indústrias...
O novo VIPerGaN50 da STMicroelectronics simplifica a construção de...
A Samsung Electronics, fornecedora de tecnologia de memória avançada,...
O mercado embarcado tem uma necessidade de soluções de...
You have probably come across the term ' drag...
You probably have a support insulator if you've noticed...
You've probably seen stand an insulator sit on power...
You've probably seen shackle insulators enthroned on electricity poles,...
You have probably experienced situations where controlling a circuit...
Back to blog

Leave a comment

Please note, comments need to be approved before they are published.