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.

[Moved] very urgent, Receiving SMS by SIM300 (GSM Modem)

Status
Not open for further replies.

torana

Member level 2
Joined
Sep 11, 2011
Messages
51
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,683
hii every body,

i am using SIM 300 with 89c51. i am able to send text sms from 8051 and sim300.

but now i am in problem with receive sms and show it on lcd. not even a single ....
i am using interrupt for receive.

now i dont have any problem for send sms from MCU.

but problem with receiving sms.

i am using following commands. (from PC it is working)

at+cmgf=1

at+cnmi=2,1,0,0,0

at+cmgr=1

thax a lot
 

entering the lion's lair is a matter and exiting is another matter :)

anyway, for receiving an SMS you shoud use a certain pin called (ring) which gives an interrupt when there is a call or an SMS

to make the task easier delete all the messages on the sim card and use the command (AT+CMGR=1) always

the problem is the message is not read directly, the module sends several over head data like the date, the sender , bla bla bla

an easy way to avoid that is to send a header in the message and search for it

example: you want to send (HELLO)

just send ($$HELLO) and use the command (AT+CMGR=1) and check the received data unitil you find a $ char followed by another one, when this is done you can start saving the followin characters in an array of string and show it on an LCD

Hope that helps
 

how to store received sms in array to send it again on other no.?
 

Read the whole data (response for AT+CMGR=1) given by GSM SIM300 into a buffer and parse and extract the actual message and put this message into another string and then use this while sending the message to another number.
 
can you please provide the code for reading sms in bufffer parse it ? Please help me i am unable to do it

- - - Updated - - -

plz provide me the code for it
 

What MCU and clock are you using ? Which Compiler are you using ?
 

I am using ATmega32 at 8Mhz on AVR studio compiler
 

This is the code for AVR USART. https://www.kanda.com/AVR-C-Code-UART.php

Now create an array of char type and use it in ISR as shown below. Then in while(1) {...} use strstr() function to check if usart buffer contains OK\r\n when some GSM data is received.

Do that much and zip and attach your AVR Stidio + WinAVR project ere. I will add the remaining code.


Code C - [expand]
1
2
3
4
5
6
char uart_buff[200];
 
void ISR() {
       uart_buff[i++] = UDR;
       uart_buff[i] = '\0';
}

 

I am still unable to do it please add the contents
 

Attachments

  • GSMTESTING - Copy (2).rar
    20.1 KB · Views: 91

There is some problem with the project you have attached. If I choose Build All it gives error message. I have modified the code but it is not building.
 

I am still unable to do it please add the contents

***I am not familiar with AVR.

Your code looks wrong.

1. ISR will be executed by the system when interrupt occurred and NOT by "User", if corresponding interrupt bit set and enabled. You called ISR() in while(1) loop.

2. What you do in ISR()? Whenever you receive first character you append '\0', then it becomes a string. GSM String contains "<CR><LF>MSG<CR><LF>". So, when you receive <CR>, you convert it as a string. What is the use and how can you display?

Recommendation: as of now, don't use interrupt. Just check RCIF in while(1) loop in main(). Keep in mind the GSM Output format, i.e "<CR><LF>MSG<CR><LF>". This will help to find the end of the string and make parsing/manipulating the string and displaying to LCD or other necessary things you want.

don't set Receive interrupt***. This is the code for PIC MCU. You can modify to your uC:


Code C - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
char GSM_String[80];
int count = 0;
int i = 0;
 
main(){
.
.
 
  while(1){
      char GSM_Char = getch(); // if char received
      
      if (i < 80){
        GSM_String[i] = GSM_Char; // store in to GSM_String
        
        if (GSM_Char == '\r'){ // to check the end of the GSM String
          count++;
          if (count > 1){ // 2nd <CR> means end of String
             GSM_String[i] = '\0'; // append NULL to convert to string
             i = 0;
             // you can display this string to LCD or wherever you want
          }
        }
        i++;
      }
  }
}



***getch() function in PIC MCU is receiving USART Character.

Try this flow. You can easily use interrupts once you can understand the function.

Note: You should use circular buffer for error free GSM code. But I can give you later. It will take some more energy. but could be simple.

pmk

edited: use USART_Receive() at the place of getch() for your AVR uC.

pmk
 
Last edited:

Can somebody tell me how to setup AVR Studio 4.19 and WinAVR and set proper configurations for a ATMega32 project. I want to know what all setup I have to do in project configuration properties.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top