Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

GSM Modem respond with weird character

Status
Not open for further replies.

lockman_akim

Advanced Member level 1
Joined
Jul 12, 2010
Messages
466
Helped
76
Reputation
152
Reaction score
68
Trophy points
1,308
Location
Malaysia
Activity points
3,523
Hi all,

i already spent almost a week to figure it out this problem. I try to communicate between pic with gsm modem. PIC seem likes sending the correct AT command to GSM modem. but it not received properly by the gsm modem. watch the simulation below. in the schematic, the DB9 connector is the virtual serial port which have a link to real physical GSM modem. please check my code also which written in Mikro-C.


Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

//Declare Function
void read_sensor();
void send_msg();

//Declare Variable
int analog_data;

void main()
{
   Uart1_init(9600);
   delay_ms(100);

   ADCON1=0b10000010;
   TRISA=0b111111;
   ADC_Init();

   Lcd_Init();                     // Initialize LCD
   Lcd_Cmd(_LCD_CURSOR_OFF);
   Lcd_Cmd(_LCD_CLEAR);


   analog_data = 0;

   do
   {
         Lcd_Out(1,1,"Smart Detection");
         Lcd_Out(2,1,"System");
         read_sensor();
   }
   while (1);
}


void read_sensor()
{
 analog_data = ADC_Read(0);
 if (analog_data > 700)
 {
  send_msg();
 }

}

void send_msg()
{
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1,1,"Sending Report");
 Uart1_Write_Text("AT+CMGS=");
 delay_ms(100);
 Uart1_write(0x22);
 delay_ms(100);
 Uart1_Write_Text("0176052241");
 delay_ms(100);
 Uart1_write(0x22);
 delay_ms(100);
 Uart1_Write(0x0D);
 delay_ms(100);

 Uart1_write_Text("9 Jln Tasek Barat 9, Taman Anda 31400, Ipoh Perak");
 delay_ms(100);
 Uart1_Write(0x0D);
 delay_ms(100);
 Uart1_Write(26);
 delay_ms(100);
 Uart1_Write(0x0D);
 delay_ms(100);
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1,1,"Report Sent");
 delay_ms(60000);

}
 

Perhaps you don't wait for ">" , coming from Modem before sending Message-Text in SMS.
(I don't remember where I have read this in some Forum)
Taxod
 

i viewed ur code superficially and noticed these two errors

first of all the command to send an sms is AT+cmgs="xxxxxxxxxx"\r

and to include these "" you have to use \" so
instead of this
Code:
 Uart1_Write_Text("0176052241");
it should be
Code:
 Uart1_Write_Text("\"0176052241\"");

second when u send this command you have to wait for ">" as taxod said,

so you should first wait until u recieve this character and then send your message


Hope this helped!
 

hi guys.. tanx for help. i do what like u guys said. but it still not working. i change the code with sending "AT". gsm should reply "OK". gsm still reply with this AAAAAAAAERR.. i tried using hyperterminal.. GSM working. here the code.

Code:
// LCD module connections
sbit LCD_RS at RB4_bit;
sbit LCD_EN at RB5_bit;
sbit LCD_D4 at RD4_bit;
sbit LCD_D5 at RD5_bit;
sbit LCD_D6 at RD6_bit;
sbit LCD_D7 at RD7_bit;

sbit LCD_RS_Direction at TRISB4_bit;
sbit LCD_EN_Direction at TRISB5_bit;
sbit LCD_D4_Direction at TRISD4_bit;
sbit LCD_D5_Direction at TRISD5_bit;
sbit LCD_D6_Direction at TRISD6_bit;
sbit LCD_D7_Direction at TRISD7_bit;
// End LCD module connections

//Declare Function
void read_sensor();
void send_msg();

//Declare Variable
int analog_data;
char ser_in;

void main()
{
   Uart1_init(9600);
   delay_ms(100);

   ADCON1=0b10000010;
   TRISA=0b111111;
   ADC_Init();

   Lcd_Init();                     // Initialize LCD
   Lcd_Cmd(_LCD_CURSOR_OFF);
   Lcd_Cmd(_LCD_CLEAR);


   analog_data = 0;

   do
   {
         Lcd_Out(1,1,"Smart Detection");
         Lcd_Out(2,1,"System");
         read_sensor();
   }
   while (1);
}


void read_sensor()
{
 analog_data = ADC_Read(0);
 if (analog_data > 700)
 {
  send_msg();
 }

}

void send_msg()
{
 Lcd_Cmd(_LCD_CLEAR);
 Lcd_Out(1,1,"Sending AT");
 Uart1_Write_Text("AT\r");
 delay_ms(10);
 Uart1_Write (10);
 delay_ms(10);
 Uart1_Write (13);
 delay_ms(100);
 }

gsm.png
 

OK diconnect the rx of db9 from ur microcontroller, and connect that to the virtual terminal directly and show us the results , also after you send any commnad atleast wiat for 500ms
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top