ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

connecting a microcontroller to a mobile phone

Updated on October 23, 2011


we can do lots of things using mobile phones. The most useful thing, is the communication. We can either get a voice call or message. If we can automate the communication process using the mobile phone, we can use this as a remote sensing unit, a remote controller... or something you or me has never thought of. Here, the word remote means, not from a remote distance as we use the TV remote. But this remote might be the distance between two continents of the world. To do this, we must create some electronic circuitry which can communicate with the mobile phone. The circuitry does the work of connecting the mobile to the outer world.

My Experiment
My first experiment was connecting a microcontroller with a mobile phone. The phone has a serial port. I used a microcontroller with usart module-the module to do serial communication.(I used a pic uc) So, the mobile phone can communicate with the uc through the serial port. There are a certain set of commands which are given to GSM modems. Using these commands, we can get a call, send sms...and a whole lot of things using a gsm modem. These commands are called AT commands. In my case, the AT commands are given to the phone using the uc. Uc sends these commands through the serial port to the mobile as ASCII characters. The mobile examines the characters and understands the commands given. Then it acts accordingly.

Then the task is to connect the mobile phone to the microcontroler.

The things we are going to need are
1. A microcontroller build on a circuit board which is up and running when given the power. That is, all required additional circuitry for the microcontroller is provided for it.(like oscillator, memory reset resistors...etc)

2.A mobile phone with a built in GSM modem. It is better to have a mobile phone which has it’s data ports in an easily accessible place.

3.Data cable for the mobile phone. More information on this 2. and 3. will be given below.

Getting to Work
Gsm modem is a device that is capable of communication through a mobile network. That is, it can get calls, send sms , some might be able to brows the www....etc. Most of the mobile phones have an built in gsm modem to do these things. The commands given to a gsm modem by some external controller (a computer or an electronic circuit) are the AT commands. These AT commands will be discussed later.

Most mobile phones have a serial port. This is situated in their back or under the battery pack. You can brows the Internet to find where your Mobile's serial pins are situated. These serial pins are usually comes among a number of pins such as GND pin,charge + pin, Rx and Tx (Rx and Tx usually are the serial pins),headphone pin....etc. You can easily know the pinout of your mobile phone by simply googling “pinout of yourPhoneModel”.

I used a Sony Ericsson T300 mobile phone. It was easy to do the job with that mobile because it’s pins are situated outside of the phone(as almost all sony ericsson mobile phones) and it has a gsm modem that accepts AT commands. But I found that Some Nokia phones doesn’t support AT commands even if they have an inbuilt gsm modem. This is because, Nokia has implemented some their own protocol on the commands that can be given to the gsm modem. They are called MBus (the older version) or FBus (the new version). The Nokia keeps these protocols a secret. There are web sites of people who has reversed engineered these protocols and has found the commands the gsm modem to do the things we require. But I used the more easier approach of using a sony ericsson mobile phone. sony ericsson mobiles that has an inbuilt gsm modem directly accepts the AT commands.

Among the pins of the mobile phone, there are pins called Rx, Tx and GND. You can brows the internet to find which pin is the Rx, which pin is the Tx... To give mobile phone at commands, we only need the Rx pin and the GND pin of the mobile phone.
We should connect the Tx pin of the uc to the phone’s Rx pin. The uc’s ground should be connected to the mobile phone’s GND pin as shown in the below picture.

The voltage of the signal input to the Rx pin of the mobile phone should be less then 5v for this particular phone model. But the voltage is about 3.3v for the newer models. So by using rectifiers, I have reduced the input voltages to about 2.9 v. This is of reasonable low voltage to protect the Rx circuitry of the mobile phones of 5v input mode and 3.3v modes. I used this in case I tend to try the AT commands later on a newer version mobile phone.

Then we move on to how to connect the data pins of the mobile to the uc physicaly.

To slove this problem, I bought a data cable for the T300 mobile phone. Then cut the cable. Then I figured out which wire is connected to which pin of the mobile. Then I connected the Tx and GND terminals of the uc to the relevant wires of the data cable and connected it to the phone.

When buying a data cable, one should be aware that some data cables have some electronic circuitry before the wires connect to the mobile phone. fortunately, some don’t. If there is an electronic circuit before the wires gets to the pins of the data cable. you should skip them as the uc should directly connect to the pins of the mobile phone. I soldered the GND and the Rx wires directly to the interior pins of the mobile. But I advice you to use the data cable method.

After connecting the relevant wires to the mobile phone, then is to programe the microcontroller to send AT commands to the mobile phone. Here I put the code I used. It is coded in assembly.

;****define registers*****
STATUS equ 03h
TXREG equ 19h
TXSTA equ 98h
SPBRG equ 99h
RCSTA equ 18h
TRISC equ 87h
CounterL equ 20h
CounterH equ 21h
bsf STATUS,5;to bank 1
movlw b'00000001'
movwf TRISC
movlw b'00100110'
movwf TXSTA
movlw b'00011001'
movwf SPBRG
bcf STATUS,5
movlw b'10010000'
movwf RCSTA
;*****start Tx*****
movlw "A"
movwf TXREG
call delay
call delay
call delay
movlw "T"
movwf TXREG
call delay
call delay
call delay
; Here put the characters in the AT command you want to give to the phone as given  above one by one. First the character "A"...then "T"...then characters of your commands. The RXREG do the conversion of the character into the ASCII code. You don't have to worry about it.
decfsz CounterL,1
goto delay
decfsz CounterH,1
goto delay

You can find reference of AT commands very easily on the web. Much of the AT commands for a vast majority of mobile phones are the same except at some rare cases, some tiny differences. You don't have to worry about these at this level.

As an example, to dial a voice call to the number 9999999999, you should give the AT command,


after entering this characters, you should enter the carriage return character. That is the decimal value 13.

After connecting the microcontroller circuit to the mobile phone and then turning the circuit on results the mobile phone to dial the number 999999999 .

Like this, you can give any AT command to the mobile phone and automate the process you require.


    0 of 8192 characters used
    Post Comment

    • profile image

      Omar 5 years ago

      Thank you... simple, ilustrative and great content.!

    • profile image

      ash 5 years ago

      thank youuuuuuu pleas more