how to send sms from gsm sim900d to mobile

1k views Asked by At

I am doing project. I want to send sms form gsm to mobile. I have code the AT commands of gsm modem in atmega16L controller using avr compiler. But have a problem it does not send sms. Please help me. My code is here.

           #include <avr/io.h>
           #define F_CPU 4000000UL

         #include<stdlib.h>
           #include<stdio.h>
        #include<avr/io.h>
        #include<util/delay.h>

         #define USART_BAUDRATE 4800
         #define BAUD_PRESCALE ((F_CPU / (USART_BAUDRATE * 16UL)) - 1)
         #define LCD_Data PORTB
        #define LCD_Control PORTD
        #define en PD5
        #define rw PD6 
        #define rs PD7
        void LCD_cmd(unsigned char cmd); 
        void LCD_init();
        void LCD_write(unsigned char data);
       void lcd_data1(char *string);
         void LCD_goto(unsigned char y, unsigned char x);



    void usart_send(unsigned char ch); 
      void usart_init();
         unsigned int usart_getch()
      unsigned char value,value0,i,j, longi_value[15]={"ok"};
       unsigned char text[]={"AT+CMGF=1\r"},numcmd[]={"AT+CMGS=\"03349565360\"\r"}, ctrlz=0x1A ;

       void usart_init()
         {

        UCSRB|= (1 << RXEN) | (1 << TXEN);   // Turn on the transmission and reception circuitry
          UCSRC|= (1<<URSEL)|(1 << UCSZ0) | (1 << UCSZ1); // Use 8-bit character sizes

    UBRRL = BAUD_PRESCALE; 
  UBRRH =(BAUD_PRESCALE >> 8); 
   UCSRC = UCSRC & 0b11110111; //stop bit
   }

 unsigned int usart_getch()
  { 

     while (!(UCSRA & (1 << RXC))); 
 return(UDR); // return the byte
  }

  void usart_send(unsigned char ch)
  {
   while(!(UCSRA&(1<<UDRE)));
  UDR=ch;   
 }

  int main(void) 
   {
   DDRD=0b11100000;         // control port of LCD
   DDRB=0xff;   
   DDRA = 0x00;
    DDRC=0xff;
    int i = 1;
    LCD_init(); //initialization of LCD
   lcd_data1("GPS & GSM SYSTEM ");
 _delay_ms(1000);
  usart_init();
  LCD_cmd(0x01);
  lcd_data1(" GSM SYSTEM ");// initialization of USART
   value=text[0];
    for(i=0;value!='\0';i++)
     {
      value=text[i];
      usart_send(value);
     _delay_ms(100);
   }
  _delay_ms(500);
  lcd_data1("1");
 value=numcmd[0];

    for(i=0;value!='\0';i++)
    {
    value=numcmd[i];  
    usart_send(value);
    _delay_ms(100);
    }  
    _delay_ms(500);
    lcd_data1("2");

  _delay_ms(1000);      
  usart_send('k');
  usart_send(0x1A);
  lcd_data1("3");
  LCD_cmd(0x01);
  _delay_ms(500);
   lcd_data1("send");
   // SMS send after this

  while(1);
 }  
0

There are 0 answers