ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel

connecting a microcontroller to a mobile phone

Updated on October 23, 2011

Introduction



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
;******init******
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*****
main
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.
delay
decfsz CounterL,1
goto delay
decfsz CounterH,1
goto delay
return 
end

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,

ATD999999999H;

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.

Comments

    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

    working

    This website uses cookies

    As a user in the EEA, your approval is needed on a few things. To provide a better website experience, hubpages.com uses cookies (and other similar technologies) and may collect, process, and share personal data. Please choose which areas of our service you consent to our doing so.

    For more information on managing or withdrawing consents and how we handle data, visit our Privacy Policy at: https://hubpages.com/privacy-policy#gdpr

    Show Details
    Necessary
    HubPages Device IDThis is used to identify particular browsers or devices when the access the service, and is used for security reasons.
    LoginThis is necessary to sign in to the HubPages Service.
    Google RecaptchaThis is used to prevent bots and spam. (Privacy Policy)
    AkismetThis is used to detect comment spam. (Privacy Policy)
    HubPages Google AnalyticsThis is used to provide data on traffic to our website, all personally identifyable data is anonymized. (Privacy Policy)
    HubPages Traffic PixelThis is used to collect data on traffic to articles and other pages on our site. Unless you are signed in to a HubPages account, all personally identifiable information is anonymized.
    Amazon Web ServicesThis is a cloud services platform that we used to host our service. (Privacy Policy)
    CloudflareThis is a cloud CDN service that we use to efficiently deliver files required for our service to operate such as javascript, cascading style sheets, images, and videos. (Privacy Policy)
    Google Hosted LibrariesJavascript software libraries such as jQuery are loaded at endpoints on the googleapis.com or gstatic.com domains, for performance and efficiency reasons. (Privacy Policy)
    Features
    Google Custom SearchThis is feature allows you to search the site. (Privacy Policy)
    Google MapsSome articles have Google Maps embedded in them. (Privacy Policy)
    Google ChartsThis is used to display charts and graphs on articles and the author center. (Privacy Policy)
    Google AdSense Host APIThis service allows you to sign up for or associate a Google AdSense account with HubPages, so that you can earn money from ads on your articles. No data is shared unless you engage with this feature. (Privacy Policy)
    Google YouTubeSome articles have YouTube videos embedded in them. (Privacy Policy)
    VimeoSome articles have Vimeo videos embedded in them. (Privacy Policy)
    PaypalThis is used for a registered author who enrolls in the HubPages Earnings program and requests to be paid via PayPal. No data is shared with Paypal unless you engage with this feature. (Privacy Policy)
    Facebook LoginYou can use this to streamline signing up for, or signing in to your Hubpages account. No data is shared with Facebook unless you engage with this feature. (Privacy Policy)
    MavenThis supports the Maven widget and search functionality. (Privacy Policy)
    Marketing
    Google AdSenseThis is an ad network. (Privacy Policy)
    Google DoubleClickGoogle provides ad serving technology and runs an ad network. (Privacy Policy)
    Index ExchangeThis is an ad network. (Privacy Policy)
    SovrnThis is an ad network. (Privacy Policy)
    Facebook AdsThis is an ad network. (Privacy Policy)
    Amazon Unified Ad MarketplaceThis is an ad network. (Privacy Policy)
    AppNexusThis is an ad network. (Privacy Policy)
    OpenxThis is an ad network. (Privacy Policy)
    Rubicon ProjectThis is an ad network. (Privacy Policy)
    TripleLiftThis is an ad network. (Privacy Policy)
    Say MediaWe partner with Say Media to deliver ad campaigns on our sites. (Privacy Policy)
    Remarketing PixelsWe may use remarketing pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to advertise the HubPages Service to people that have visited our sites.
    Conversion Tracking PixelsWe may use conversion tracking pixels from advertising networks such as Google AdWords, Bing Ads, and Facebook in order to identify when an advertisement has successfully resulted in the desired action, such as signing up for the HubPages Service or publishing an article on the HubPages Service.
    Statistics
    Author Google AnalyticsThis is used to provide traffic data and reports to the authors of articles on the HubPages Service. (Privacy Policy)
    ComscoreComScore is a media measurement and analytics company providing marketing data and analytics to enterprises, media and advertising agencies, and publishers. Non-consent will result in ComScore only processing obfuscated personal data. (Privacy Policy)
    Amazon Tracking PixelSome articles display amazon products as part of the Amazon Affiliate program, this pixel provides traffic statistics for those products (Privacy Policy)