SMART Switch

by ganeevs in Circuits > Microcontrollers

9648 Views, 53 Favorites, 0 Comments

SMART Switch

Untitled1.png
2 way switch

The world has changed so rapidly and it’s all due technology and science. Things have enhanced, new era has arrived of a better and a smart world. But according to me there’s one thing that hasn't changed yet...... A switch!!! Yes an electrical switch which we use daily in our lives. A switch is one of the most important and significant invention which plays its role in almost every part of our work. Be it home or office these switches are always there to serve you. But aren't they boring!!!

We live in a smart world but still we have these boring and typical switches. Now it’s the time to introduce them to our new technologies. Therefore I have come up with a solution which could revolutionize the switching world.

I have made a smart switch which looks similar to what we have seen so far but work with the combination of embedded electronics. This switch allows you to switch thing on/off with just a touch on your smart phones or laptops via Bluetooth communication. It can also work as normal switch.

I have used the concept of two way switching but with a twist. I have replaced one switch of the system with a Smartphone or a laptop. This makes our life hell lot easier and why to get up from one place to another to switch off /on things when your Smartphone can do so.

I came across this idea, in my mind, the day when I found it too lazy to switch the lights off after watching a movie in my bed. I felt for the need of a device which could do that for me and then I suddenly realised why not our phones. We keep them with us almost all the time.

This devise is something like; you have the whole switchboard in your mobile.

REQUIREMENTS:

download (1).jpg
download (2).jpg
download (3).jpg
images (1).jpg
images.jpg

1. AtMega 16 IC

2. 7805 voltage regulator IC

3. Bluetooth module (HC_05)

4. NPN transistor (BC _549)

5. Relay(5V DC), to handle 220V AC

6. A normal two way switch(SPDT switch)

CIRCUIT DIAGRAM and CONNECTIONS:

Untitled.png
LightSwitchWiring.GIF

· RX and TX pin of HC_05 are connected to TX and RX pin of MCU respectively.

· Base of BC 549 is connected to PA0.

· Collector of BC 549 is pulled down

· Emitter of BC 549 is connected to +5V

DESCRIPTION:

IMG_20140910_090201695.jpg
Untitled2.png
IMG_20140910_090209437.jpg

This project works on the basic and simple concept of two way switches. The idea of two way switch has made our life much easier. A two-way switch is nothing but a SPDT switch. When two of these kinds of switches are combined, this combination is known as two way switching. You might have seen this concept in staircase, gallery etc. where you can switch on/off a light or any device using two switches.

Now coming back to my project, what I have done is that I have replaced one of the SPDT switch, in a two way combination, with my cell phone. The HC_05 Bluetooth module helps me to do so.

When this Bluetooth module receives a data from my cell phone, via Bluetooth communication, which I send, using a terminal application (BLUE TERM: available over android app store), HC_05 communicates with the MCU using UART (Universal Asynchronous Receiver Transmitter) concept to check whether the data matches the stored password or not. If it gives a yes, the PA0 pin becomes high which further switches on the relay. This relay is basically my second SPDT switch.

In the coding part, getchar_uart(); returns me the 8 bit data very time it receives it. This data is stored in an array until user presses ‘space bar’. This array is then compared with my stores password i.e. “123”. If everything goes right, MCU toggles the state of PA0 pin on every successful compare. This further operates a 5V DC relay via a BC549 NPN transistor.

The main motive to make such a device was to control appliances from a switch as well as from your mobile.

CODE: (with the Header Files Used in It)

#include <avr/io.h>

#include <util/delay.h>

#include <uart.h> //provides with all UART related functions

void main()

{

char c=0,arr[4];

int i,on=1;

enable_uart(9600); //baud rate set at 9600

DDRA=0x01; //PA0 declared as output

PORTA=0x00; //PA0 status: low

while(1)

{

i=0;

c=getchar_uart(); //getting input from HC_05

while(c!=' ')

{

arr[i++]=c;

c=getchar_uart();

}

arr[i]='\0';

if(strcmp(arr,"123")==0) //comparing the array

{

if(on)

{PORTA|=(1<<0);on=0;}

else

{PORTA&=~(1<<0);on=1;}

}

}

}

Downloads