GSM-based device monitoring and control systems are becoming popular these days. Here I am introducing a system that will make home appliances controlling using mobile phones possible from anywhere in the world. It’s a PIC microcontroller-based system that connects with the GSM module to receive SMS for smart home control. The message is then processed by the microcontroller and output is given through PORTD of the PIC microcontroller. All the devices are connected on PORTD through the relay.
Home Appliances Controlling Using Mobile Phone Circuit
- GSM Module
- LCD (2X16)
- Transistor (BC548)
- Resistor (1K, 10K, 470×8, 10K(POT))
- Crystal (4MHz)
- Capacitor (22pfx2, 10uF)
- LED x8
Working of the circuit
- The serial pin of the PIC Microchip (RX and TX) is connected to the GSM module to control it via AT commands so as to receive SMS and set the mode.
- When the system is ON, PIC will initialize the GSM module and wait to receive an SMS.
- 2×16 LCD display is connected to PORTB of PIC, it will display the status of the system (i.e. it will display what the system is doing).
- Initially, the GSM module is switched to Text mode by sending the AT command “AT+CMGF=1”. Here “1” indicates text mode and “0” is used to indicate PDU mode.
- After this setting, PIC will display that it’s waiting for SMS and will wait to receive SMS.
- The reception of SMS is detected by checking the received character; it will send all information about the SMS which starts with”+CMT”. Message text content will start after sending”\n” and end with”\n”. This is the logic I have used here to receive SMS.
- I have used an infinite loop that continuously checks if a ‘+’ is received, followed by ‘C’, ‘M’, and ‘T’.
- Then the system understands that a massage is going to be received and waits for a $ (dollar sign), if done it will store the entire message on a buffer of size 33 named INFO. It’s again split and stored on two separate buffers for further processing.
- After this, PIC will display “SMS IS RECEIVED” in the first row and “DEVICE SWITCHING” in the second row. It also enables a buzzer for 2 seconds as an audio indication of SMS reception.
- A variable “count” is initiated as “1” and the received SMS information is now on the buffer named line1, the letter on line1 is skipped and takes line1 because the message for ON and OFF is sent as “$ON ABCDEFGH$” and “$OFF ABCDEFGH$”; in both cases Zeroth letter (“O”) is common, so I skipped it.
- The first letter indicates that the message is for ON or OFF. Here I have used two ‘for’ loops, one to set PORTD bits (ON the devices) and another one to reset the PORTD bits(turning OFF the devices).
- ON and OFF detection is done by checking the first character (line1) of the message, “N” for ON and “F” for OFF.
- After detecting the message it will enter into the corresponding loop of SET or RESET pins. Then the relays connected to these pins activate or deactivate.
- For demonstration purposes, I have used LEDs and in the circuit diagram, I have mentioned how to connect a relay in order to connect high current devices.
- To switch ON the devices, you may send SMS as “$ON ABC$” to ON A, B, and C; “$OFF B$” to switch OFF B.
- We have designed this system to switch 8 individual devices and you can improve it through simple modification of the program and hardware.
SMS-based device control is a cool modern project now a day You can easily make your own using a GSM modem and PIC16F877A.