Appliances Control using GSM through Atmel Microcontrollers

Appliances Control using GSM

If you want to make a professional product which is more than a proto-type project then you have to take care of some other things as well. In this article you are going to study that how to make a GSM based professional product which you can implement on your room as well.

 

I am not going to explain the basics of GSM and other stuff which I have already explained in the articles present below:
Basics of GSM Module
LED control Using GSM based on Atmel AVR Microcontrollers
Fan speed control using GSM based on Atmel AVR Microcontrollers

Here, I will explain only those parts which are additional in this project and don’t worry I will give you complete code of the project in the end of the article.

 

Specifications:

  • Can control any three appliances
  • Any phone number can send the message
  • Reply message will be send to user
  • Can control from button and GSM both
  • Respond in 3-4 Seconds

Hardware Part:

Electrical Appliances Control Using GSM
Figure 1: Implemented with one 100watt Bulb

I used Atmega8 Microcontroller which is from Atmel AVR Microcontrollers to implement this project. Atmega8 microcontroller is best microcontroller due to its lot of features and cheap size.

 Components required for the project:

  • Atmega8
  • GSM Module
  • 3 x SPDT relays
  • 3 x SPDT Switches
  • 3 x BC547 Transistors
  • 6 x Diodes (1N4001)
  • 6 x 1k resistors
  • 3 x 100k resistors
  • 1 x 220ohm resistor
  • 1 LED
Appliance Control Using GSM
Figure 2: Control Circuitry

 

As I told in the specifications that you can control appliances from button and GSM module both but the question is how it is possible. Because whenever a relay will cut off the supply, the switch present in the series will be not able to turn on the appliances at that time. To overcome this problem, look at the figure below:

Relay Circuity For GSM Module
Figure 3: Cotrol Circuit for one Appliance

 

If you are able to understand the above figure then you can easily implement this project. The base of BC547 transistor is connected with the PINB1 of Atmega8 microcontroller through a 1k resistor to limit the current. Whenever the microcontroller Atmega8 will send High (1) command to PINB1 the relay will be energized. If you carefully look at the circuit diagram you will understand that whenever the switch or relay will change their position, the other switching device will again turn on the appliances. But keep in mind that the switch presents here is not a simple switch. It is SPDT switch as shown in figure below.

SPDT Swtich
Figure 4: SPDT Switch

Why is a voltage divider present in circuit?

If you carefully look in the  figure 3 you will notice that a voltage divider is present above the load. This voltage divider is basically a feedback loop going towards the microcontroller (you will see in the complete circuit diagram).  The reason behind using this feedback is, when you apply a relay and a switch at the same time, the microcontroller will not able to understand the present state of load. But when we apply a feedback through this voltage divider the microcontroller will sense the voltage immediately and thus can work properly. I will explain more with details in coding part. Here, have a look on complete circuit diagram.

Complete Circuit Diagram of GSM Project
Figure 5: Complete Circuit Diagram

Coding Part:

Coding to turn on the Load:

The outputs of voltage dividers which I discussed are connected with ADC port of Atmega8 (Look on the above circuit diagram). The input parts of all three voltage dividers are connected with the loads. Whenever the load will turn on, some voltage will be there at ADC pin of microcontroller. So whenever a “Bulbon” command will be send to GSM module, first of all it will check that that voltage is present at the pin or not. If the voltage is already present it will reply that bulb is already on. Have a look on the code below:

if(strncmp(data2,"Bulbon",6)==0){
                                if(adc_read(5) < 400){
                                 PORTB ^= (1 << 1);
                                send();
                                string_transmit("Bulb is on .. Have Fun dude!!");
                                uart_transmit(26);
                }
                else{            
                      send();
                                string_transmit("Bulb is already on bro");
                                uart_transmit(26);
                                }
                                } 

Coding to turn off the bulb:

This is also same as above method. Whenever a “Bulboff” message will be send to GSM module, it will check the voltage . If voltage is present it will turn off the bulb otherwise just reply that bulb is already off.

 

if(strncmp(data2,"Bulboff",7)==0){
            if(adc_read(5)>400){ 
                PORTB ^= (1 << 1);
              send();
               string_transmit("Bulb is off now :(");
                  uart_transmit(26);
         }
    else{
                 send();
                  string_transmit("Bulb is already off bro");
                   uart_transmit(26);
                        }
                                }

If need more help feel free to comment below and don't forget to like our facebookpage. 🙂

To download complete code click the button below:

Complete Code

Ismail Sarwar

Electrical engineering is my profession, my hobby and my passion. I completed bachelors of electrical engineering in 2015. Currently I am working with an Electric Utility Company. Power Electronics, Embedded Systems and Energy Metering are my fields of specialization. In free time I listen music and watch movies.

What do you think?