GSM Cellphone (mobile) controller : AT commands

by Fahad Mirza

My Device

My Device

This project is about controlling various appliances without even touching it. Of course I mean on/off for now! And the controlling will be done by a mobile. Just send the instruction through the sms, device will decode it and take action accordingly. The device includes a microcontroller and a GSM modem. Instead of GSM modem you can use any cell phone.

Those who don’t know, any GSM modem or cell phone is based on AT (Attention) commands set. If you google, you can find the complete instruction. I use these instructions:

ATE0 – For turn off echo.
AT+CMGF – For choosing Text Mode.
AT+CNMI – For identification of new sms.
AT+CPMS – For preferred message storage.
AT+CMGD – For delete message.
AT+CMGR – Read message from.
AT+CMGS – For sending message.

Working Principle:

The project controls a light (on/off) through a relay. It also can send back the status of the light (on/off). When you turn on the device it starts to initialize the modem. The GSM modem returns every instruction you give.

So for less traffic I turned it off by ATE0. Then it changes the sms mode in TEXT by AT+CMGF.

Those who don’t know, GSM devices have two types of sms mode TEXT and PDU. PDU is a little bit complicated. Then it configure what will modem do if a new message received by AT+CNMI. By AT+CPMS it set where will be message stored, which is for my project is SIM. That’s it!

Now the device will be waiting for any new messages. The messages I can send are: “Light on” / ”Light off” / “Status”. If you send anything other then these then device will be replied with a message “Invalid”.

Suppose I send the message “Light on” then the modem will send uC a message +CMTI: “SM”, 1. Where SM is where msg is stored and 1 is at what index.

When uC get CMTI, then it knows there is new sms.

So then it will send AT+CMGR to read the message and compare it with some pre-defined string. If it is Light on/off, then it will do so by on/off the relay.

If it is “Status” then it will check either relay is on/off and send sms in a predefined number.

Then it delete the sms by AT+CMGD and again wait for the new sms.

Comments for GSM Cellphone (mobile) controller : AT commands

Average Rating starstarstarstarstar

Click here to add your own comments

Jan 25, 2015
by: zaheer

Dear Asslam o alikum,
i want to make the same system with multiswitching,
like a bulb,oven,ac etc i want to know the code lionk and how to make the uc wait for command i ma in initial study please guide me soon with some link and command ....
whatsapp: 00923007705008

Dec 13, 2014
Could you send me the code please
by: N Khan

I am very desperate for this kind of code as have to submit a project in two days time and still stuck on code so, it will be great help if you could send me yours. My email is hope to hearing from you soon. Thanks

Nov 29, 2014
need help
by: anuz

hello sir,
I'm doing a project somewhat same as yours. but I. have stucked with the sourse code..could you please give me the code. big help!!!
thank you very much

Jul 10, 2014
send me the code
by: Anonymous

Coud you send me the code as well please?
I want to build a system which controlls a door .
my email is

Jun 12, 2014
Nice Project
by: Anonymous

Hello, thanks for sharing your project with us. I am also doing a project like yours and I will like to know if you can send me the source code.
My email address is amoisaac@hotmailcom.

May 23, 2014
help me
by: Nebyu Neri

hi , i want to know how the micro controller store
what it read from gsm modem.

May 22, 2014
sending and reciving sms
by: Anonymous

hi, brother ,how are you? i want to ask about how
the microcontroller store the message read from gsm modem.

Mar 19, 2014
comment on what you have done
by: Anonymous

will done my brother can you send the for lpc2148 micro controller using IAR worke bench

Mar 14, 2014

well don bro
can you send me code
for pic micro controller 16f877a

Mar 14, 2014

well don bro
can you send me code
for pic micro controller 16f877a

Feb 23, 2014
please help me
by: Anonymous

good day FAHAD !!

Thanks for the project. My project is in embedded c, similar to this project. I am using gsm module TC35 for my project on lights.I am facing problem while reading the contents of SMS,and I am also unable to send and receive back messages from the gsm module to my cell phone.

here :
i am the one will text "ON" then the LED will ON


can you help me solve this problem . thanks , i will be waiting for your response

Feb 18, 2014
Requesting for a code
by: Anonymous

hi.. amazing !! can you send me your codes? please help me . thank you so much godbless @
i'll be waiting for your response

Feb 04, 2014
Requesting for code
by: Anonymous

Excellent project sir, can you please share your code with me. I will be very thankful to you Sir.

Feb 04, 2014
Request for code
by: Anonymous

excellent project brother, can you please send me your code at my email id,

Jan 23, 2014
Need coding
by: Anonymous

It seems to very good support material for my new project. Can u pls send me the code to my eamil.This is my emailid:

Dec 04, 2013
Please visit this page...
by: Fahad

All the details are provided there. I changed it a lil bit. Also Its like more then 3 years, so I guess you guys can do better then me.

Dec 01, 2013
Thank you.
by: Anonymous

Sir can u also send me the code and the circuit diagram. Your work is great and it would be a great help for my project. Thank you so much and God bless you.

Here's my email

Nov 11, 2013
by: Anonymous

can you please send me the code and the circuit diagram
my email is
thank you

Oct 27, 2013
code pls
by: Anonymous

sir Can you pls send me the code

Oct 27, 2013
Can you sendme the code
by: Ntim

Can you sendme the code at

Oct 01, 2013
Help me
by: Anonymous

Sir, Can you please send me the code to me @ Thank you Sir.

Sep 25, 2013
GSM Cellphone (mobile) controller
by: Anonymous

Dear Sir, with due respect. I will be glad if you will pls. send me the circuit and code of this design. I want to learn your way. my email is Best regards

Sep 25, 2013
help me
by: jatin jotangia

can u please send me the code and circuit i can get exact idea aboutsending and receiving of msg from mobile

Jul 25, 2013
by: Anonymous

hello sir..could you please provide the source code and schematic diagram of your project?it would be a great reference for our car alarm system with sms.. pls email it here

May 22, 2013
by: ishu

can anyone send me the above code..
i have little confusion for the code.
so plz send me code for checking the message by microcontroller..

May 03, 2013
Request for the code and circuit
by: Anonymous

I'm doing a similar kind of project and i'm finding it quite difficult in following the AT commands. So i request you to please mail me the code and the circuit at
Thank you :-)

Apr 04, 2013
The coding pls.
by: Anonymous


Pls. Help me with the source code and the circuit through my email

Mu'azu Musa Jibrin

Apr 04, 2013
by: Anonymous

can u please send me the code ? my id is

Mar 17, 2013
by: Anonymous

sir can you mail me the code n details of this project. mail id

Jan 06, 2013
Very excellent explanation
by: Engr. Muazu Jibrin Musa

Salam Fahad,
My name is Muazu from Africa Nigeria.

To be Frank with you, your design is a grate achievement. May I pls have the schematic and source code to learn from your steps?

My email is

I will be glad to read from you.

Engr. Muazu Jibrin Musa

Nov 29, 2012
code and circuit
by: henne

Hey there

could you send me the code and a drawing of the ciruit as well?

Hope its not to hard to produce


Nov 29, 2012
code for the project
by: henne

Hey There

Coud you send me the code as well please?
I want to build a system which controlls a door of a garage. Hope its not to hard to program.


Jul 09, 2012
Problem in reading contents of SMS
by: Joy

Hi Fahad,
Thanks for the project. I am doing M.Sc (Comp Sc) and my project is in embedded c, similar to this project. I am using gsm module SIM900 for my project on home automation.I am facing problem while reading the contents of SMS,and I am also unable to send back message from the gsm module to my cell phone.Can you please help with the coding of your project. Please mail me the code on

Dec 17, 2011
for Tanzeel
by: Fahad

Hi tanzeel,
Give me your mail address, i'll send my code. ALso u can send your code. I'll look over it and find the pitfall.

Fahad Mirza

Dec 17, 2011
prblm in recivng end
by: Tanzeel

I interfaced gsm 300dz gsm module with pic microcontroller 16f887A.i used at commands. i easily sent msgs 4rm microcontroller through gsm,, but i have prblm in reciving end... the received data are not display on lcd .can u shaare with me ur code ....and can u plz help me..

Apr 06, 2011
GSM Regarding
by: Anand Rathod

I m Anand Rathod doing M.Tech thesis based on embedded system, write now i doing a project based on Embedded DAM controlling using wireless media. In that project i used gsm modem.
The device indication as well as controlling the device using gsm mode via sms, so, pls sir / madam help me because i complete my project almost done only problem in the gsm part.

Pls help me.
Thank you

Anand Rathod

Mar 23, 2011
by: Fahad

U r welcome! Thanx for the appreciation. If any help nedded, I will glad to help.

Mar 23, 2011
Code and circuit
by: vivek

thanks its nice project and also details well of AT commands but i did find its circuit and code
i tried on google and find this another project with circuit and coding

Click here to add your own comments

Join in and write your own page! It's easy to do. How? Simply click here to return to Project Showcase.

Privacy Policy | Contact | About Me

Site Map | Terms of Use