I am interfacing 8051 and sim900 for my project purpose. I am able to send message from my sim900 when interfaced with PC in hyperterminal using AT Commands. After programming using Keil in 8051 board i am able to get the same AT commands in hyperterminal when checked from the board output, But still when i connect both of them 8051 and sim900 ,the modem(sim900) is not sending any sms Can any one help me by sending me the complete source code for reading and sending sms using sim900 and 8051?
This is generally a case of getting the right pins wired up, using the right voltages, and the right baud rate.
I had checked that too but still i am not able to make it up. Please do help me with the necessary c coding for interfacing sim900 with 8051
this code is an easy sample that i wrote for LPC2368 but it is independent from hardware.
/* turning on SIM900 */ /****************************************************************************** ** Function name: GSM_ON ** ** Descriptions: turning on SIM900. ** parameters: None ** Returned value: None ** ******************************************************************************/ BYTE GSM_on (void) { BYTE get_temp[80]={0}; BYTE i,j=0; BYTE Enter = 13; FIO1SET |= GSM_POWER; delayMs (1500); FIO1CLR |= GSM_POWER; delayMs(4000); // for (i = 0;i < 75;i++) // SIM900 after powering On Get lots of info about itself -_-' // { // get_temp[i] = getkey(); // if( ( get_temp[i] == 0x0D ) && (i > 58 ) ) // break; // } f_uart = 2; printf("AT+CMGD=1,4%c",Enter); // for deleting all previous messages from SIM Memory // for( i = 0;i < 20;i++ ) // { // get_temp[i] = getkey(); // if( ( get_temp[i] == 0x0D ) && ( i > 15 ) ) // break; // j = i; // } if( get_temp[j] == 'K' ) // cheking recieved OK from SIM900 { LCD_gotoxy( 0,1 );LCD_cls(); LCD_puts( "GSM Ready" );delayMs(2000); return ( TRUE ); } return ( FALSE ); } /****************************************************************************** ** Function name: send_SMS ** ** Descriptions: Sending SMS to desired Phone Number. ** parameters: None ** Returned value: None ** ******************************************************************************/ BYTE send_SMS ( BYTE *phone_number , BYTE *text ) { BYTE Enter=13; BYTE double_quote=34; BYTE Ctrlz=26; LCD_gotoxy(0,0); LCD_puts("Sending SMS..."); f_uart = 2; printf("AT+CMGF=1%c",Enter); // Selecting "Text" Format for sending Message delayMs(500); f_uart = 2; printf("at+cmgs=%c0%s%c%c",double_quote,phone_number,double_quote,Enter); //give the phone number delayMs(500); f_uart = 2; printf("%s%s%c",sms_warning,text,Ctrlz); // sending a message delayMs(500); LCD_gotoxy(0,0); LCD_puts("message sent "); interrupt_f |= RTC_F; return( TRUE ); }
Have you not heard of "\r", then?
en.wikipedia.org/.../Escape_sequences_in_C
It's always preferable to used named constants (enum or #define) instead of variables to avoid having the compiler creating extra auto variables.
BYTE Enter=13; BYTE double_quote=34; BYTE Ctrlz=26;
And as noted - printf() is quote good at handling the full range of non-nil characters.
sir,
have you got the solution? i am facing same problem. can you help me out?