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.

[AVR] receiving sms algooritm via sim900

Status
Not open for further replies.

mohammad.habibi

Newbie level 6
Joined
Apr 9, 2015
Messages
11
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
94
hello
i want to receive sms via sim900a with atmega 32
whats at command need to recieving sms?
is this correct?

HTML:
AT+CMGF=1\r
AT+CMGDA=”DEL ALL”
AT+CNMI=0,0
AT+CMGR=1
AT+CMGL=”REC UNREAD”

tnx freinds
 

Code:
"AT\r";
"AT+IPR=9600\r";
"AT+CMGF=1\r";
"AT+CPMS="SM","SM","SM"\r";
"AT+CNMI=2,1,0,0,0\r";

above commands once during GSM initialization.

Then when new SMS is received it gives +CMTI: "SM",x response where x is SMS index

you have to then issue "AT+CMGR=x\r"; to read the SMS at index x.
 

i worked with avr microcontroller and codevision compler
as you say my code is similar to :
Code:
/*******************************************************
AVR Core external Clock frequency: 11.059200 MHz
*******************************************************/
#include <mega16a.h>
#include <alcd.h>
#include <delay.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ctrl_z 0x1a
#define enter 0x0d
char Masseg[255]={'\0'};
void main(void)
{
char ch;
int i=0,j=0,p=1;
DDRB=0XFF;                      
PORTB=0X00;
DDRA=(1<<DDC7) | (1<<DDC6) | (1<<DDC5) | (1<<DDC4) | (1<<DDC3) | (1<<DDC2) | (1<<DDC1) | (1<<DDC0);
PORTA=(0<<PORTC7) | (0<<PORTC6) | (0<<PORTC5) | (0<<PORTC4) | (0<<PORTC3) | (0<<PORTC2) | (0<<PORTC1) | (0<<PORTC0);
DDRD=(0<<DDD7) | (0<<DDD6) | (0<<DDD5) | (0<<DDD4) | (0<<DDD3) | (0<<DDD2) | (1<<DDD1) | (0<<DDD0);
PORTD=(0<<PORTD7) | (0<<PORTD6) | (0<<PORTD5) | (0<<PORTD4) | (0<<PORTD3) | (0<<PORTD2) | (0<<PORTD1) | (0<<PORTD0);
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=(0<<RXC) | (0<<TXC) | (0<<UDRE) | (0<<FE) | (0<<DOR) | (0<<UPE) | (0<<U2X) | (0<<MPCM);
UCSRB=(0<<RXCIE) | (0<<TXCIE) | (0<<UDRIE) | (1<<RXEN) | (1<<TXEN) | (0<<UCSZ2) | (0<<RXB8) | (0<<TXB8);
UCSRC=(1<<URSEL) | (0<<UMSEL) | (0<<UPM1) | (0<<UPM0) | (0<<USBS) | (1<<UCSZ1) | (1<<UCSZ0) | (0<<UCPOL);
UBRRH=0x00;
UBRRL=0x47;
lcd_init(20);
// *****************************************
printf("AT\r");
delay_ms(600);
printf("AT+IPR=9600\r");
delay_ms(600);
printf("AT+CMGF=1\r");
delay_ms(600);
printf("AT+CPMS="SM","SM","S,"\r");
delay_ms(600);
printf("AT+CNMI=2,1,0,0,0\r");
delay_ms(600);
while(1)
{       
       printf("AT+CMGD=0,4\r\n");
       p=0;
       ch=getchar();
       if( (ch == enter) && ( j==0 || j==1 ))
          j++;
       if( ch == enter && j==2)
        {   
            ch=getchar();
            i=0;
            while(1)
                {
                 ch=getchar();
                 if(ch==enter)
                    {   
                     j=0;  
                     p=1;
                     Masseg[i]='\0';
                     break;
                    }
                 //lcd_putchar(ch);
                 Masseg[i]=ch;
                 i++;
                }        
        }
// ****************  my Masseg is +CMTI: "SM",x ***********************
// now i must decode the x? and write "AT+CMGR=x\r"; ?


}
}
is it right?
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top