CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

Problem in sending sms with sim300

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
hoangkhuong



Joined: 16 Mar 2012
Posts: 31

View user's profile Send private message

Problem in sending sms with sim300
PostPosted: Mon May 21, 2012 10:06 am     Reply with quote

Hello everyone, I am trying to send sms using SIM300. Here is my code:
Code:
#include <30F4011.h>
#DEVICE ADC=10
#FUSES NOWDT, NOPUT, NOPROTECT, NODEBUG, BROWNOUT, NOWRT
#FUSES XT_PLL4
#use delay(clock=4000000)
#include "LCD.h"
#use rs232(baud=2400,parity=N,xmit=pin_f5,rcv=pin_f4,bits=8,errors)

void main()
{
   char c;
   char s = 0x1A;
   set_tris_b(0x00);
   lcd_init();
   delay_ms(20);
   printf("AT\r");
   delay_ms(100);
   printf("ATE0\r");
   delay_ms(100);
   printf("AT+CMGF=1\r");
   delay_ms(100);
   printf("AT+CMGS=+80934525189\r");
   delay_ms(100);
   printf("hello\r");
   putc(s);
   lcd_gotoxy(1,2);
   while (true)
   { 
      c = getc();
      printf(lcd_putc,"%c",c);
   }
}

My problem is: sometimes I receive the right message "hello" but sometimes I receive a message like this:
Code:
AT
ATE0
AT+CMGF=1
AT+CMGS=+80934525189
hello

Can somebody please help me figure out what is wrong in my code?.
Thank you very much.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 21, 2012 10:58 am     Reply with quote

Hi,

A couple of things. You really should be making some attempt to read the responses from the SIM300 to see what is going on during the SMS sending process. That might help you to determine why your code is behaving the way it is?

Also, an SMS message is sent by sending a Cntl-Z to the modem. I don't know what you are sending, but it doesn't look right. Do it like this:

Code:

putc(26);   //send the msg with a CNTL-Z   


John
hoangkhuong



Joined: 16 Mar 2012
Posts: 31

View user's profile Send private message

PostPosted: Mon May 21, 2012 11:02 am     Reply with quote

Thanks for your response. First of all, I did sent a CTRL+Z character at the end of the sending message command, it is 0x1A which is in decimal is 26 as you suggest. Secondly, I did used PC to check the response from SIM300 and things work fine. Problem arises when I try to communicate between mcu and sim300 :(
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Mon May 21, 2012 12:29 pm     Reply with quote

Hi,

Sorry, I didn't read your code closely enough to see that you are in fact sending the Cntl-Z.

I realize that problems arise when you communicate between the PIC and the SIM300, and that is why I recommended that you actually read the modem response with the PIC. At the very least, connect the Tx line from the modem to your PC (via a MAX232) to aid in your diagnosis.

I'd also recommend that you try some longer delays after setting the phone number, and setting the message text. I would try something like 2 seconds as a start. If that helps, you can reduce the delays until it fails.

John
hoangkhuong



Joined: 16 Mar 2012
Posts: 31

View user's profile Send private message

PostPosted: Tue May 22, 2012 10:41 am     Reply with quote

Yes, I've solved my problem by increasing the delay time after AT+CMGS command to 3 seconds.
Thanks very much.
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Tue May 22, 2012 1:15 pm     Reply with quote

Hi,

Great! I'm using 2 seconds with a different GSM module (ADH8066), and it's always worked great!

Glad I could help!

John
savotech



Joined: 13 Dec 2012
Posts: 12

View user's profile Send private message Send e-mail Visit poster's website

PostPosted: Fri Apr 25, 2014 3:25 pm     Reply with quote

Hi, please help me out.
I am using SIM908 modem, i tried the code hungkuoung used buy couldnt get any sms on the phone.
Do i need to set sms centre number?
Do i need to add country phone code
And the baud that i used is 9600 since i read that the module is autobaud by default.
I didnt use pc to monitor reply cos my laptop didnt have serial port.

So please anybody with useful info
ezflyr



Joined: 25 Oct 2010
Posts: 1019
Location: Tewksbury, MA

View user's profile Send private message

PostPosted: Fri Apr 25, 2014 6:10 pm     Reply with quote

Hi,

Post a link to the SIM908 module you are using so that we can start by evaluating your hardware interface. I'm using a bare SIM900 module, so I should be able to help!

John
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group