Go Down

Topic: [HELP] Arduino MEGA 2560 + SIM900A module ?? Problem ?? (Read 1 time) previous topic - next topic

nameless1305

May 24, 2015, 06:52 pm Last Edit: May 24, 2015, 07:09 pm by nameless1305
Hi everyone!

I'm using sim900a library v305 from gsmlib.org (http://www.gsmlib.org/download.html)

It worked well with arduino UNO. (sms sending and receiving)

But when I use arduino MEGA 2560. I only can send the message from my arduino to my phone, and can't receive message from my phone. (I used pin 18, 19)

This library require arduino v1.0.6 or earlier with arduino MEGA.

This is the instruction when using library:

Quote
[1]    How to switch between Arduino Mega and Arduino Uno?
   
   1)
   Open GSM.h and comment-decomment the appropriate lines like below
   e.g. for Arduino Mega
   //#define UNO
   #define MEGA
   
   2)
   If you use Arduino Uno comment the line in HWSerial.h or decomment if
   you are using Arduino Mega
   e.g. for Arduino Mega
   #define MEGA

   3)
   Save and compile

[2]   How to switch between the old shield (that uses 4 and 5 pins for
   SoftwareSerial and the new (that used 2 and 3 pins)?

   1)
   Open GSM.cpp and comment-decomment the appropriate lines like below
   e.g. for the new one

   //#define _GSM_TXPIN_ 4
   //#define _GSM_RXPIN_ 5
   #define _GSM_TXPIN_ 2
   #define _GSM_RXPIN_ 3
   
   2)
   Save and compile
Here is my code:

Quote
#include "SIM900.h"
 
#include <SoftwareSerial.h>
 
#include "sms.h"
 
#define but 7


SMSGSM sms;
 

char number[20];
 
 
char message[180];
 
char pos;
 
char *p;
byte i;
 
 
 
void setup()
 
{
  pinMode(but,INPUT_PULLUP);
 
 Serial.begin(9600);
 
 if (gsm.begin(9600))
 
   Serial.println("\nstatus=READY");
 
 else Serial.println("\nstatus=IDLE");
 
 
};
 
void loop()
 
{
 if (digitalRead(but) == 0){
 Serial.println("pressed");
 if (sms.SendSMS("xxxxxxxxxxxxx", "Arduino SMS"))
 Serial.println("\nSMS sent OK");
 }
 

 pos=sms.IsSMSPresent(SMS_UNREAD);
 Serial.println((int)pos);
 

 if((int)pos>0&&(int)pos<=20)
 {
   Serial.print("NUOVO MESSAGGIO, POS=");
   Serial.println((int)pos);
   message[0]='\0';
   sms.GetSMS((int)pos,number,message,180);
   Serial.println(number);
   Serial.println(message);
 
   //p=strstr(message,"test");
 
   if((String)message == "test")
   {
     Serial.println("PSWD IS RIGHT");
   }
 
   else
   {
     Serial.println("PSWD IS WRONG");
   }
     
   }
 
   sms.DeleteSMS((int)pos);
   delay(2000);
 
};
Here is debug: (arduino MEGA)
Quote
0
ATT: OK
RIC: NO STRING RCVDATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
+CMGL: 4,"
ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
+CMGL: 4,"REC UNREAD","+84932311611","CONG DANH","15/05/25,00:01:19+28"

ATT: OK
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
+CMGL: 4,"REC UNREAD","+84932311611","CONG DANH","15/05/25,00:01:19+28"

OK

ATT: +CMGL:
RIC:
+CMT: "+84932311611","CONG DANH","15/05/25,00:01:19+28"
Hell
+CMGL: 4,"REC UNREAD","+84932311611","CONG DANH","15/05/25,00:01:19+28"
As you see: "REC UNREAD" at the bottom line  ???? For arduino UNO it is "REC READ"




Like this: (for arduino UNO)
Quote
+CMGL: 1,"REC UNREAD","+84932311611","CO
ATT: OK
RIC:
+CMGL: 1,"REC UNREAD","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

ATT: OK
RIC:
+CMGL: 1,"REC UNREAD","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

OK

ATT: +CMGL:
RIC:
+CMGL: 1,"REC UNREAD","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

OK

1
NUOVO MESSAGGIO, POS=1
ATT: +CMGR
RIC:
+CMGR: "REC READ","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

OK

ATT: "REC UNREAD"
RIC:
+CMGR: "REC READ","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

OK

ATT: "REC READ"
RIC:
+CMGR: "REC READ","+84932311611","CONG DANH","15/05/24,20:57:35+28"
Okkkkkkk

OK

+84932311611
Okkkkkkk
PSWD IS WRONG
ATT: OK
RIC:
OK
Hoping your advises :) Thanks all !!

Go Up