You are on page 1of 14

8051 HOW-TO GUIDE

Interfacing GSM with 8051

......................................8 Testing the GSM with 8051 ......6 Pin Assignment with 8051 ..............................................................................net ..3 Interfacing GSM ...............4 Interfacing GSM with 8051.....................Contents at a Glance 8051 Primer Board ...................................................3 GSM (Global System for Mobile Communication) ..................... 10 General Information .............6 Circuit Diagram to Interface GSM with 8051 ........pantechsolutions................................................................................... 12 Join the Technical Community Today! http://www...........................................................................7 Source Code ...7 C Program to send a message from 8051 ................................

net . each in its own time slot. Join the Technical Community Today! http://www. The kit supports in system programming (ISP) which is done through serial port.pantechsolutions. GSM (Global System for Mobile Communication) GSM is a digital mobile telephony system. GSM digitizes and compresses data. It operates at either the 900 MHz or 1800 MHz frequency band. NXP’s 8051 (89V51RD2). then sends it down a channel with two other streams of user data.8051 Primer Board The 8051 Primer board is specifically designed to help students to master the required skills in the area of embedded systems. The kit is designed in such way that all the possible features of the microcontroller will be easily used by the students. 8051 Primer Kit is proposed to smooth the progress of developing and debugging of various designs encompassing of High speed 8-bit Microcontrollers.

To communicate over UART or USART. The sending SMS through GSM modem when interfaced with microcontroller or PC is much simpler as compared with sending SMS through UART. The GSM module is communicate the microcontroller with mobile phones through UART.Interfacing GSM Fig.e. we just need three basic signals which are namely.pantechsolutions.net . Text message may be sent through the modem by interfacing only three signals of the serial interface of modem with microcontroller i. Join the Technical Community Today! http://www. RxD and GND. RXD (receive). GND (common ground). In this scheme RTS and CTS signals of serial port interface of GSM Modem are connected with each other. 1 shows how to interface the GSM with microcontroller.. TxD. TXD (transmit). GSM modem interfacing with microcontroller for SMS control of industrial equipments.

pantechsolutions.net .The transmit signal of serial port of microcontroller is connected with transmit signal (TxD) of the serial interface of GSM Modem while receive signal of microcontroller serial port is connected with receive signal (RxD) of serial interface of GSM Modem. 1 Interfacing UART to Microcontroller Join the Technical Community Today! http://www. It depends upon the amount of information collected from GPS Engine that you need at the base station for tracking vehicle or person. Fig. The SMS message in text mode can contain only 140 characters at the most.

Interfacing GSM with 8051 We now want to display a text in mobile from 8051 Primer Board by using GSM module through UART.2 P1.3 Join the Technical Community Today! http://www.1 Serial Port Section ISP PGM TXD-0 RXD-0 TXD-1 RXD-1 8051 MAX 3232 UART1 (P2) P1. Here we are using UART0.0 P3.net . The SMS can be sending and receiving for the data sharing and situation information and control. In 8051 Primer Board contains two serial interfaces that are UART0 & UART1. The GSM modem is being interfaced with the microcontroller 8051 Primer Board for SMS communication.pantechsolutions. Pin Assignment with 8051 UART DB-9 Connector UART0(P1) 8051 Lines P3.

C programs are written in Keil software.pantechsolutions. The baud rate of microcontroller is 9600. Join the Technical Community Today! http://www.net . which send a message to mobiles from 8051 Primer Board through GSM module by using UART0. Some delay is occurring when a single data is sent to mobile through UART.Circuit Diagram to Interface GSM with 8051 Source Code The Interfacing GSM module with 8051 program is very simple and straight forward.

/* TMOD: timer 1. //Setup the serial port for 9600 baud at 11.H> #include <stdio. unsigned int j. /* TR1: timer 1 run */ TI = 1. 8-bit UART. /* TI: set TI to send first char of UART */ } /* special function register declarations */ /* prototype declarations for I/O functions */ //define prot P0 for LED //Delay Routine start here void delay1(int n) { int i.C Program to send a message from 8051 *************************************************************************************** Title : Program to send a message from 8051 to mobile through GSM *************************************************************************************** #include <REG51. Join the Technical Community Today! http://www. /* TH1: reload value for 9600 baud @ 11. /* SCON: mode 1. //------------------------------------------------void serial_init(void) { SCON = 0x50.i<n.pantechsolutions. enable rcvr */ TMOD |= 0x20.i++).net . } void delay2(int n) { int i.0592MHz.0592MHz*/ TR1 = 1. 8-bit reload */ TH1 = 0xFD. mode 2. for(i=0.h> #define LED P0 void serial_init(void).

} void led_left() { for (j=0x01. //scroll left delay1(20). delay1(1000). printf("AT+CMGF=1%c". delay2(20). } } //------------------------------------// Main program starts here //------------------------------------void main(void) { serial_init(). printf("Hi :-) GSM Modem Test"). j<<=1) { LED = j.for(i=0. //line feed command while(1). delay2(20). } Join the Technical Community Today! http://www. j<=0x80. delay2(20).pantechsolutions.i++) delay1(1000). //Type your mobile number Eg : "9884467058" led_left().i<n.13).0x1A). delay2(20). //Type text as u want printf("%c". //Text Mode | hex value of 13 is 0x0D (CR ) printf("AT+CMGS=\"9600292363\"%c".net . //serial initialization LED = 0x00.13).

They must be properly set up and a project with correct settings must be created in order to compile the code. To compile the above code. Open the Hyper Terminal screen. the C file must be added to the project. You must compile the code for generating HEX file. you want to develop or debug the project without any hardware setup. Now the screen should show some text messages. connect the +9V adapter with GSM module which is connected with 8051 Primer Board through UART0. you want to check the port output without 8051 Primer Board. In Keil. In debugging Mode. select which port you are using and set the default settings.pantechsolutions. The Flash Magic software is used to download the hex file into your microcontroller IC 8051 through UART0.net . Testing the GSM with 8051 Give +5V power supply to 8051 Primer Board. Join the Technical Community Today! http://www.To compile the above C code you need the KEIL software.

After message string has been sent to the modem. 2. send CTRL+Z to the micro-controller. First select the text mode for SMS by sending the following AT Command to GSM Modem : AT+CMGF = 1 .net . Send the following AT Command for sending SMS message in text mode along with mobile number to the GSM Modem : AT+CMGS =+923005281046 . 4.pantechsolutions. which is equivalent to 0x1A (ASCII value).The following Commands and sequence of events performed for sending text message to a mobile phone through GSM Modem interfaced with microcontroller: 1. This command configures the GSM modem in text mode. 0x1A to GSM Modem to transmit the message to mobile phone. Join the Technical Community Today! http://www.e. This command sends the mobile number of the recipient mobile to the GSM modem. Send ASCII code for CTRL+Z i.. 3. Send the text message string ("GSM Modem Test") to the GSM Modem This is a test message from UART".

Otherwise you just check the code with debugging mode in Keil. If you want to see more details about debugging just see the videos in below link. Use the exact value crystal shown in schematic. More instructions are available in following articles. Wherever possible use new components.pantechsolutions.net . then you just check the jumper connections & just check the serial cable is working. solder jumps and loose joints. General Information For proper working use the components of exact values as shown in Circuit file.  User Manual of 8051 Primer Board. A major problem arises due to improper soldering. Join the Technical Community Today! http://www.If you not reading any text from UART0. Solder everything in a clean way.  Tutorial of how to create & Debug a project in KEIL.  How to Create & Debug a Project in Keil.

And our website is a rich and trusted resource used by a vibrant online community of more than 1.Did you enjoy the read? Pantech solutions creates information packed technical documents like this one every month.pantechsolutions.net . Join the Technical Community Today! http://www. 00.000 members from organization of all shapes and sizes.

Sensors. Robotics.pantechsolutions. Join the Technical Community Today! http://www.net . Power electronics. DSP Boards. FPGA/CPLD boards. Electronic components and much more .What do we sell? Our products range from Various Microcontroller development boards. Basic electronics. Our goal is to make finding the parts and information you need easier and affordable so you can create awesome projects and training from Basic to Cutting edge technology. Communication Kits.