This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Problem with interfacing 8051 and sim900

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?

Parents
  • 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 );
    }
    

Reply
  • 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 );
    }
    

Children