Professional Documents
Culture Documents
Interfacing GSM With 8051: 8051 How-To Guide
Interfacing GSM With 8051: 8051 How-To Guide
Contents at a Glance
8051 Primer Board ...........................................................3
GSM (Global System for Mobile Communication) .............3
Interfacing GSM ...............................................................4
Interfacing GSM with 8051...............................................6
Pin Assignment with 8051 ................................................6
Circuit Diagram to Interface GSM with 8051 .....................7
Source Code ....................................................................7
C Program to send a message from 8051 ..........................8
Testing the GSM with 8051 ............................................ 10
General Information ...................................................... 12
Interfacing GSM
Fig. 1 shows how to interface the GSM with
microcontroller. The GSM module is communicate the
microcontroller with mobile phones through UART. To
communicate over UART or USART, we just need three basic
signals which are namely, RXD (receive), TXD (transmit),
GND (common ground).
GSM modem interfacing with microcontroller for SMS
control of industrial equipments. The sending SMS through
GSM modem when interfaced with microcontroller or PC is
much simpler as compared with sending SMS through
UART.
Text message may be sent through the modem by
interfacing only three signals of the serial interface of
modem with microcontroller i.e., TxD, RxD and GND. In this
scheme RTS and CTS signals of serial port interface of GSM
Modem are connected with each other.
ISP PGM
UART0(P1)
8051
Lines
TXD-0
P3.0
RXD-0
P3.1
TXD-1
P1.2
(P2)
UART1
8051
MAX
3232
RXD-1
P1.3
Source Code
The Interfacing GSM module with 8051 program is very
simple and straight forward, 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. C programs are written in Keil
software. The baud rate of microcontroller is 9600.
void serial_init(void);
unsigned int j;
//Setup the serial port for 9600 baud at 11.0592MHz.
//------------------------------------------------void serial_init(void)
{
SCON = 0x50;
/* SCON: mode 1, 8-bit UART, enable rcvr
*/
TMOD |= 0x20;
/* TMOD: timer 1, mode 2, 8-bit reload
*/
TH1 = 0xFD;
/* TH1: reload value for 9600 baud @ 11.0592MHz*/
TR1 = 1;
/* TR1: timer 1 run
*/
TI = 1;
/* TI: set TI to send first char of UART
*/
}
for(i=0;i<n;i++)
delay1(1000);
}
void led_left()
{
for (j=0x01; j<=0x80; j<<=1)
{
LED = j;
delay1(1000);
}
}
//------------------------------------//
Main program starts here
//------------------------------------void main(void)
{
serial_init();
//serial initialization
LED = 0x00;
printf("AT+CMGF=1%c",13);
delay2(20); //Text Mode
| hex
value of 13 is 0x0D (CR )
printf("AT+CMGS=\"9600292363\"%c",13); delay2(20); //Type your mobile number Eg
: "9884467058"
led_left();
//scroll left
delay1(20);
printf("Hi :-) GSM Modem Test");
delay2(20); //Type text as u want
printf("%c",0x1A);
delay2(20); //line feed command
while(1);
}
If you not reading any text from UART0, then you just
check the jumper connections & just check the serial cable
is working. 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.
How to Create & Debug a Project in Keil.
General Information
For proper working use the components of exact values
as shown in Circuit file. Wherever possible use new
components.
Solder everything in a clean way. A major problem
arises due to improper soldering, solder jumps and
loose joints.
Use the exact value crystal shown in schematic.
More instructions are available in following articles,
User Manual of 8051 Primer Board.
Tutorial of how to create & Debug a project in KEIL.
What do we sell?
Our products range from Various Microcontroller
development boards, DSP Boards, FPGA/CPLD boards,
Communication Kits, Power electronics, Basic electronics,
Robotics, Sensors, Electronic components and much more . 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.