SlideShare a Scribd company logo
1 of 8
GSM Modem Interfacing with PIC
Microcontroller
Hi to all...
I am doing a project in which i will be interfacing a gsm modem with PIC
microcontroller(16f877).. when i connect the gsm modem with PC i can able to send and
read the messages in the sim using AT commands in hyperterminal...Then i iniatized UART
in PIC send and received data to PC through hyperterminal its working properly...
When i interfaced PIC with GSM Modem i can able to send AT command to GSM modem but
the reply "OK " from GSM modem to PIC is not received by PIC...
Example:
AT (Enter)-----In Hyperterminal
OK ------Message from GSM Modem
Compiler:MikroC
Baud Rate:9600 bps
GSM MOdem:Wavecom HT-W2101
I can able to send AT and Enter command from UART to PIC... But i cant able see the reply
from GSM modem... but it works well when i interface GSM modem with PC hyperterminal...
Help me...
/*Header*****************************************************
Microcontroller=16f877
Clock=10 Mhz
Project Title:Air Pollution Control Using GSM/GPRS
Developed By:Sathiesh Kumar.V
Date:31/01/2010*/
void Calculation(unsigned int ) ;
void Gsm_SMS_Init();
void Gsm_SMS_Read();
void Gsm_SMS_Send();
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned char ch; //
char Receive;
unsigned int adc_rd; // Declare variables
char *text; //
long tlong; //
unsigned int i,j;
char return_gsm[2];
char Gsm_Receive[100];
char Gsm_Msg[10];
char uart_rd[]="AT";
char uart_rd1[]="AT +CMGF=1";
char uart_rd2[]="AT +CMGR=1" ;
char uart_rd3[]="AT +CMGS=";
char Mobile_No[]="+919444721638" ;
char Send_Msg[]="@ON";
void main()
{
INTCON = 0; // All interrupts disabled
ADCON1 = 0x82; // A/D voltage reference is VCC
TRISA = 0xFF; // All port A pins are configured as inputs
TRISC=0x01;
Delay_ms(2000); // Rest of pins are configured as digital
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
Lcd_Init(); // LCD display initialization
Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)
text = "Air Pollution "; // Define the first message
Lcd_Out(1,1,text); // Write the first message in the first line
delay_ms(500);
text = "Sensor Value"; // Define the second message
Lcd_Out(2,1,text); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
text = "GSM"; // Define the third message
while (1)
{
Lcd_Out(1,1,text); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Gsm_SMS_Init();
}
}
void Gsm_SMS_Init()
{
if (UART1_Tx_Idle() == 1)
{
for(i=0;i<=1;i++)
{
UART1_Write(uart_rd); //AT
}
UART1_Write(0x0D); //Enter
Lcd_Out(2,1,"AT"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
//delay_ms(5000);
while(1)
{
if (UART1_Data_Ready())
{ // If data is received,
for(i=0;i<=1;i++)
{
return_gsm = UART1_Read(); // read the received data, Received OK
}
Lcd_Out(2,1,"OK"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
/* UART1_Write(return_gsm[0]);
Lcd_Out(2,1,"OK RESEND"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR); */
// UART1_Write(return_gsm[1]);
}
}
/*if(return_gsm[0]==0x4F && return_gsm[1]==0x4B)
{
if (UART1_Tx_Idle() == 1)
{
for(i=0;i<=8;i++)
{
UART1_Write(uart_rd1); //AT+CMGF=1
}
UART1_Write(0x0D); //Enter
Lcd_Out(1,1,"AT+CMGF=1");
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
}
if (UART1_Data_Ready())
{ // If data is received,
for(i=0;i<=1;i++)
{
return_gsm = UART1_Read(); // read the received data,OK
}
Lcd_Out(2,1,"Received OK");
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
}
} */
}
}
Code (text):
/*Header*****************************************************
Microcontroller=16f877
Clock=10 Mhz
Project Title:Air Pollution Control Using GSM/GPRS
Developed By:Sathiesh Kumar.V
Date:31/01/2010*/
void Calculation(unsigned int ) ;
void Gsm_SMS_Init();
void Gsm_SMS_Read();
void Gsm_SMS_Send();
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RB0_bit;
sbit LCD_D5 at RB1_bit;
sbit LCD_D6 at RB2_bit;
sbit LCD_D7 at RB3_bit;
sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISB0_bit;
sbit LCD_D5_Direction at TRISB1_bit;
sbit LCD_D6_Direction at TRISB2_bit;
sbit LCD_D7_Direction at TRISB3_bit;
// End LCD module connections
unsigned char ch; //
char Receive;
unsigned int adc_rd; // Declare variables
char *text; //
long tlong; //
unsigned int i,j;
char return_gsm[2];
char Gsm_Receive[100];
char Gsm_Msg[10];
char uart_rd[]="AT";
char uart_rd1[]="AT+CMGF=1";
char uart_rd2[]="AT+CMGR=1" ;
char uart_rd3[]="AT+CMGS=";
char Mobile_No[]="+919444721638" ;
char Send_Msg[]="@ON";
void main()
{
INTCON = 0; // All interrupts disabled
ADCON1 = 0x82; // A/D voltage reference is VCC
TRISA = 0xFF; // All port A pins are configured as inputs
TRISC=0x80;
Delay_ms(2000); // Rest of pins are configured as digital
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
Lcd_Init(); // LCD display initialization
Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off)
Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD)
text = "Air Pollution "; // Define the first message
Lcd_Out(1,1,text); // Write the first message in the first line
delay_ms(500);
text = "Sensor Value"; // Define the second message
Lcd_Out(2,1,text); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
text = "GSM"; // Define the third message
while (1)
{
Lcd_Out(1,1,text); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
Gsm_SMS_Init();
}
}
void Gsm_SMS_Init()
{
if (UART1_Tx_Idle() == 1)
{
Lcd_Out(2,1,"AT"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
for(i=0;i<=1;i++)
{
UART1_Write(uart_rd[i]); //AT
}
UART1_Write(0x0D); //Enter
//delay_ms(5000);
while(1)
{
Lcd_Out(2,1,"In while"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
if (UART1_Data_Ready())
{ // If data is received,
Lcd_Out(2,1,"In IF"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
for(i=0;i<=1;i++)
{
return_gsm[i] = UART1_Read(); // read the received data, Received
OK
}
Lcd_Out(2,1,"OK"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
/* UART1_Write(return_gsm[0]);
Lcd_Out(2,1,"OK RESEND"); // Define the first message
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR); */
// UART1_Write(return_gsm[1]);
}
}
/*if(return_gsm[0]==0x4F && return_gsm[1]==0x4B)
{
if (UART1_Tx_Idle() == 1)
{
for(i=0;i<=8;i++)
{
UART1_Write(uart_rd1[i]); //AT+CMGF=1
}
UART1_Write(0x0D); //Enter
Lcd_Out(1,1,"AT+CMGF=1");
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
}
if (UART1_Data_Ready())
{ // If data is received,
for(i=0;i<=1;i++)
{
return_gsm[i] = UART1_Read(); // read the received data,OK
}
Lcd_Out(2,1,"Received OK");
delay_ms(500);
Lcd_Cmd(_LCD_CLEAR);
}
} */
}
}
Code (text):
void sms_send();
void sms_del();
void sms_read();
char sms[11];
char output[65];
unsigned char* MSG4 = "AT+CNMI=2,1,0,0,0";
void main() {
UART1_Init(9600); // Initialize UART module at 9600 bps
Delay_ms(100); // Wait for UART module to stabilize
// sms_del();
sms_read();
}
void sms_send()
{
int i;
/*UART1_Write_Text("ATnr");
delay_ms(500);
UART1_Write_Text("AT+CMGF=1nr");
delay_ms(500); */
UART1_Write_Text("AT+CMGS=");
UART1_Write(0x22);
UART1_Write_Text("+919444721638");
UART1_Write(0x22);
UART1_Write_Text("nr");
delay_ms(500);
for(i=0;i<64;i++)
{
if(output[i]=='0') break;//ask for null character of sms vector when find it go out
of for() loop
UART1_Write(sms[i]);
}
delay_ms(500);
UART1_Write(26);// send ctrl + Z
return;
}
void sms_del()
{
UART1_Write_Text("AT+CMGD=1nr");
delay_ms(500);
}
void sms_read()
{
int i;
//char sms[11];
UART1_Write_Text("ATnr");
delay_ms(500);
UART1_Write_Text(MSG4); //cpms
Delay_ms(1000);
UART1_Write(0X0D); // ENTER
Delay_ms(1000);
UART1_Write_Text("AT+CMGF=1nr");
delay_ms(500);
UART1_Write_Text("AT+CMGR=7nr");
//delay_ms(500);
while (UART1_Data_Ready() != 1);
UART1_Read_Text(output, "OK", 65); // reads text until 'OK' is found
sms_send();
//return;
}

More Related Content

What's hot

伺服馬達控制
伺服馬達控制伺服馬達控制
伺服馬達控制艾鍗科技
 
Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control Uday Wankar
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Omkar Rane
 
Introduction to Vortex86EX Motion Control Modules
Introduction to Vortex86EX Motion Control ModulesIntroduction to Vortex86EX Motion Control Modules
Introduction to Vortex86EX Motion Control Modulesroboard
 
Arm7 document
Arm7  documentArm7  document
Arm7 documentN Harisha
 
Fun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksFun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksRitesh Kanjee
 
ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4NOWAY
 
Wireless UART Controller: XR18W750
Wireless UART Controller: XR18W750Wireless UART Controller: XR18W750
Wireless UART Controller: XR18W750Premier Farnell
 
PSC9131UG_C4_FD
PSC9131UG_C4_FDPSC9131UG_C4_FD
PSC9131UG_C4_FDHaim Amir
 
moving message display of lcd
 moving message display of lcd moving message display of lcd
moving message display of lcdabhishek upadhyay
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Aarav Soni
 
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50Ruthvik Vaila
 

What's hot (20)

伺服馬達控制
伺服馬達控制伺服馬達控制
伺服馬達控制
 
Ec8791 lpc2148 pwm
Ec8791 lpc2148 pwmEc8791 lpc2148 pwm
Ec8791 lpc2148 pwm
 
Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control Arm cortex ( lpc 2148 ) based motor speed control
Arm cortex ( lpc 2148 ) based motor speed control
 
Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148Analog To Digital Conversion (ADC) Programming in LPC2148
Analog To Digital Conversion (ADC) Programming in LPC2148
 
Dc40 d mk3
Dc40 d mk3Dc40 d mk3
Dc40 d mk3
 
Introduction to Vortex86EX Motion Control Modules
Introduction to Vortex86EX Motion Control ModulesIntroduction to Vortex86EX Motion Control Modules
Introduction to Vortex86EX Motion Control Modules
 
06 mgw data configuration issue1.10
06 mgw data configuration issue1.1006 mgw data configuration issue1.10
06 mgw data configuration issue1.10
 
Arm7 document
Arm7  documentArm7  document
Arm7 document
 
Ppt
PptPpt
Ppt
 
Fun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol WorksFun and Easy UART - How the UART Protocol Works
Fun and Easy UART - How the UART Protocol Works
 
ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4ARM COMPLETE DETAIL PART 4
ARM COMPLETE DETAIL PART 4
 
Pdf tp3076 national
Pdf tp3076 nationalPdf tp3076 national
Pdf tp3076 national
 
Wireless UART Controller: XR18W750
Wireless UART Controller: XR18W750Wireless UART Controller: XR18W750
Wireless UART Controller: XR18W750
 
PSC9131UG_C4_FD
PSC9131UG_C4_FDPSC9131UG_C4_FD
PSC9131UG_C4_FD
 
Uart
UartUart
Uart
 
moving message display of lcd
 moving message display of lcd moving message display of lcd
moving message display of lcd
 
Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)Timer counter in arm7(lpc2148)
Timer counter in arm7(lpc2148)
 
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
MEASUREMENT AND DISPLAY OF THE MAINS FREQUENCY USING PIC18F4520/50
 
Xilinxaxi uart16550
Xilinxaxi uart16550Xilinxaxi uart16550
Xilinxaxi uart16550
 
Fx2 n spec
Fx2 n specFx2 n spec
Fx2 n spec
 

Similar to Gsm modem interfacing with pic microcontroller

Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfforwardcom41
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleAarya Technologies
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver艾鍗科技
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Svet Ivantchev
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileABHISHEK MAURYA
 
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)Omkar Rane
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prognikhil dixit
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controllerSyed Ghufran Hassan
 
Home automation and securty using wireless networks
Home automation and securty using wireless networksHome automation and securty using wireless networks
Home automation and securty using wireless networksArun Kumar
 
gsm based Notice board
gsm based Notice boardgsm based Notice board
gsm based Notice boardASHIRVAD KUMAR
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-programDimz I
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisitionazhar557
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for recordG Lemuel George
 
Project report on gsm based digital notice board
Project report on gsm based digital notice boardProject report on gsm based digital notice board
Project report on gsm based digital notice boardmanish katara
 

Similar to Gsm modem interfacing with pic microcontroller (20)

131080111003 mci
131080111003 mci131080111003 mci
131080111003 mci
 
Vehicle tracting system
Vehicle tracting systemVehicle tracting system
Vehicle tracting system
 
Combine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdfCombine the keypad and LCD codes in compliance to the following requ.pdf
Combine the keypad and LCD codes in compliance to the following requ.pdf
 
Product catlog
Product catlogProduct catlog
Product catlog
 
CC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver ModuleCC2500 Wireless Trans-receiver Module
CC2500 Wireless Trans-receiver Module
 
Linux Serial Driver
Linux Serial DriverLinux Serial Driver
Linux Serial Driver
 
Intel Quark HSUART
Intel Quark HSUARTIntel Quark HSUART
Intel Quark HSUART
 
Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016Gaztea Tech Robotica 2016
Gaztea Tech Robotica 2016
 
Atmega lcd programing_with_header_file
Atmega lcd programing_with_header_fileAtmega lcd programing_with_header_file
Atmega lcd programing_with_header_file
 
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
CAN interfacing on LPC1768 (ARM Cortex M3 based Micro controller)
 
Dam gate open close lpc prog
Dam gate open close lpc progDam gate open close lpc prog
Dam gate open close lpc prog
 
codings related to avr micro controller
codings related to avr micro controllercodings related to avr micro controller
codings related to avr micro controller
 
Home automation and securty using wireless networks
Home automation and securty using wireless networksHome automation and securty using wireless networks
Home automation and securty using wireless networks
 
gsm based Notice board
gsm based Notice boardgsm based Notice board
gsm based Notice board
 
(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program(381877808) 102054282 5-listing-program
(381877808) 102054282 5-listing-program
 
PIC and LCD
PIC and LCDPIC and LCD
PIC and LCD
 
Data Acquisition
Data AcquisitionData Acquisition
Data Acquisition
 
LCD_Example.pptx
LCD_Example.pptxLCD_Example.pptx
LCD_Example.pptx
 
m.tech esd lab manual for record
m.tech esd lab manual for recordm.tech esd lab manual for record
m.tech esd lab manual for record
 
Project report on gsm based digital notice board
Project report on gsm based digital notice boardProject report on gsm based digital notice board
Project report on gsm based digital notice board
 

Recently uploaded

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝soniya singh
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningVitsRangannavar
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 

Recently uploaded (20)

BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
Call Girls in Naraina Delhi 💯Call Us 🔝8264348440🔝
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
cybersecurity notes for mca students for learning
cybersecurity notes for mca students for learningcybersecurity notes for mca students for learning
cybersecurity notes for mca students for learning
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 

Gsm modem interfacing with pic microcontroller

  • 1. GSM Modem Interfacing with PIC Microcontroller Hi to all... I am doing a project in which i will be interfacing a gsm modem with PIC microcontroller(16f877).. when i connect the gsm modem with PC i can able to send and read the messages in the sim using AT commands in hyperterminal...Then i iniatized UART in PIC send and received data to PC through hyperterminal its working properly... When i interfaced PIC with GSM Modem i can able to send AT command to GSM modem but the reply "OK " from GSM modem to PIC is not received by PIC... Example: AT (Enter)-----In Hyperterminal OK ------Message from GSM Modem Compiler:MikroC Baud Rate:9600 bps GSM MOdem:Wavecom HT-W2101 I can able to send AT and Enter command from UART to PIC... But i cant able see the reply from GSM modem... but it works well when i interface GSM modem with PC hyperterminal... Help me... /*Header***************************************************** Microcontroller=16f877 Clock=10 Mhz Project Title:Air Pollution Control Using GSM/GPRS Developed By:Sathiesh Kumar.V Date:31/01/2010*/ void Calculation(unsigned int ) ; void Gsm_SMS_Init(); void Gsm_SMS_Read(); void Gsm_SMS_Send(); // LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit;
  • 2. sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD module connections unsigned char ch; // char Receive; unsigned int adc_rd; // Declare variables char *text; // long tlong; // unsigned int i,j; char return_gsm[2]; char Gsm_Receive[100]; char Gsm_Msg[10]; char uart_rd[]="AT"; char uart_rd1[]="AT +CMGF=1"; char uart_rd2[]="AT +CMGR=1" ; char uart_rd3[]="AT +CMGS="; char Mobile_No[]="+919444721638" ; char Send_Msg[]="@ON"; void main() { INTCON = 0; // All interrupts disabled ADCON1 = 0x82; // A/D voltage reference is VCC TRISA = 0xFF; // All port A pins are configured as inputs TRISC=0x01; Delay_ms(2000); // Rest of pins are configured as digital UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize Lcd_Init(); // LCD display initialization Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off) Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD) text = "Air Pollution "; // Define the first message Lcd_Out(1,1,text); // Write the first message in the first line delay_ms(500); text = "Sensor Value"; // Define the second message Lcd_Out(2,1,text); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); text = "GSM"; // Define the third message while (1) {
  • 3. Lcd_Out(1,1,text); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); Gsm_SMS_Init(); } } void Gsm_SMS_Init() { if (UART1_Tx_Idle() == 1) { for(i=0;i<=1;i++) { UART1_Write(uart_rd); //AT } UART1_Write(0x0D); //Enter Lcd_Out(2,1,"AT"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); //delay_ms(5000); while(1) { if (UART1_Data_Ready()) { // If data is received, for(i=0;i<=1;i++) { return_gsm = UART1_Read(); // read the received data, Received OK } Lcd_Out(2,1,"OK"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); /* UART1_Write(return_gsm[0]); Lcd_Out(2,1,"OK RESEND"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); */ // UART1_Write(return_gsm[1]); } } /*if(return_gsm[0]==0x4F && return_gsm[1]==0x4B) { if (UART1_Tx_Idle() == 1) { for(i=0;i<=8;i++)
  • 4. { UART1_Write(uart_rd1); //AT+CMGF=1 } UART1_Write(0x0D); //Enter Lcd_Out(1,1,"AT+CMGF=1"); delay_ms(500); Lcd_Cmd(_LCD_CLEAR); } if (UART1_Data_Ready()) { // If data is received, for(i=0;i<=1;i++) { return_gsm = UART1_Read(); // read the received data,OK } Lcd_Out(2,1,"Received OK"); delay_ms(500); Lcd_Cmd(_LCD_CLEAR); } } */ } } Code (text): /*Header***************************************************** Microcontroller=16f877 Clock=10 Mhz Project Title:Air Pollution Control Using GSM/GPRS Developed By:Sathiesh Kumar.V Date:31/01/2010*/ void Calculation(unsigned int ) ; void Gsm_SMS_Init(); void Gsm_SMS_Read(); void Gsm_SMS_Send(); // LCD module connections sbit LCD_RS at RB4_bit; sbit LCD_EN at RB5_bit; sbit LCD_D4 at RB0_bit; sbit LCD_D5 at RB1_bit; sbit LCD_D6 at RB2_bit; sbit LCD_D7 at RB3_bit; sbit LCD_RS_Direction at TRISB4_bit; sbit LCD_EN_Direction at TRISB5_bit; sbit LCD_D4_Direction at TRISB0_bit; sbit LCD_D5_Direction at TRISB1_bit; sbit LCD_D6_Direction at TRISB2_bit; sbit LCD_D7_Direction at TRISB3_bit; // End LCD module connections
  • 5. unsigned char ch; // char Receive; unsigned int adc_rd; // Declare variables char *text; // long tlong; // unsigned int i,j; char return_gsm[2]; char Gsm_Receive[100]; char Gsm_Msg[10]; char uart_rd[]="AT"; char uart_rd1[]="AT+CMGF=1"; char uart_rd2[]="AT+CMGR=1" ; char uart_rd3[]="AT+CMGS="; char Mobile_No[]="+919444721638" ; char Send_Msg[]="@ON"; void main() { INTCON = 0; // All interrupts disabled ADCON1 = 0x82; // A/D voltage reference is VCC TRISA = 0xFF; // All port A pins are configured as inputs TRISC=0x80; Delay_ms(2000); // Rest of pins are configured as digital UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize Lcd_Init(); // LCD display initialization Lcd_Cmd(_LCD_CURSOR_OFF); // LCD command (cursor off) Lcd_Cmd(_LCD_CLEAR); // LCD command (clear LCD) text = "Air Pollution "; // Define the first message Lcd_Out(1,1,text); // Write the first message in the first line delay_ms(500); text = "Sensor Value"; // Define the second message Lcd_Out(2,1,text); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); text = "GSM"; // Define the third message while (1) { Lcd_Out(1,1,text); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); Gsm_SMS_Init(); } } void Gsm_SMS_Init() { if (UART1_Tx_Idle() == 1) { Lcd_Out(2,1,"AT"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR);
  • 6. for(i=0;i<=1;i++) { UART1_Write(uart_rd[i]); //AT } UART1_Write(0x0D); //Enter //delay_ms(5000); while(1) { Lcd_Out(2,1,"In while"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); if (UART1_Data_Ready()) { // If data is received, Lcd_Out(2,1,"In IF"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); for(i=0;i<=1;i++) { return_gsm[i] = UART1_Read(); // read the received data, Received OK } Lcd_Out(2,1,"OK"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); /* UART1_Write(return_gsm[0]); Lcd_Out(2,1,"OK RESEND"); // Define the first message delay_ms(500); Lcd_Cmd(_LCD_CLEAR); */ // UART1_Write(return_gsm[1]); } } /*if(return_gsm[0]==0x4F && return_gsm[1]==0x4B) { if (UART1_Tx_Idle() == 1) { for(i=0;i<=8;i++) { UART1_Write(uart_rd1[i]); //AT+CMGF=1 } UART1_Write(0x0D); //Enter Lcd_Out(1,1,"AT+CMGF=1"); delay_ms(500); Lcd_Cmd(_LCD_CLEAR); } if (UART1_Data_Ready()) { // If data is received, for(i=0;i<=1;i++) { return_gsm[i] = UART1_Read(); // read the received data,OK
  • 7. } Lcd_Out(2,1,"Received OK"); delay_ms(500); Lcd_Cmd(_LCD_CLEAR); } } */ } } Code (text): void sms_send(); void sms_del(); void sms_read(); char sms[11]; char output[65]; unsigned char* MSG4 = "AT+CNMI=2,1,0,0,0"; void main() { UART1_Init(9600); // Initialize UART module at 9600 bps Delay_ms(100); // Wait for UART module to stabilize // sms_del(); sms_read(); } void sms_send() { int i; /*UART1_Write_Text("ATnr"); delay_ms(500); UART1_Write_Text("AT+CMGF=1nr"); delay_ms(500); */ UART1_Write_Text("AT+CMGS="); UART1_Write(0x22); UART1_Write_Text("+919444721638"); UART1_Write(0x22); UART1_Write_Text("nr"); delay_ms(500); for(i=0;i<64;i++) { if(output[i]=='0') break;//ask for null character of sms vector when find it go out of for() loop UART1_Write(sms[i]); } delay_ms(500); UART1_Write(26);// send ctrl + Z return; } void sms_del() { UART1_Write_Text("AT+CMGD=1nr"); delay_ms(500); }
  • 8. void sms_read() { int i; //char sms[11]; UART1_Write_Text("ATnr"); delay_ms(500); UART1_Write_Text(MSG4); //cpms Delay_ms(1000); UART1_Write(0X0D); // ENTER Delay_ms(1000); UART1_Write_Text("AT+CMGF=1nr"); delay_ms(500); UART1_Write_Text("AT+CMGR=7nr"); //delay_ms(500); while (UART1_Data_Ready() != 1); UART1_Read_Text(output, "OK", 65); // reads text until 'OK' is found sms_send(); //return; }