Receiving/Sending SMS

Hi, I try to make an autoresponder and using Arduino Mega 2560 and a-gsm v2.064 GSM Shield. I managed to send SMS to different phones, but can not receive messages. I used SendSMS and ReceiveSMS from Arduino examples. I mention that if I run the example ReceiveSMS does not work as well. It is a problem in cpde or the shield has a problem?

My receive/send code :

#include <GSM.h>
#define PINNUMBER ""

GSM gsmAccess;
GSM_SMS sms;

char senderNumber[20];

void setup() {
Serial.begin(9600);
boolean notConnected = true;
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}
Serial.println("GSM initialized");
}

void loop() {
char c;
if (sms.available()) {
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);
}
String txtMsg("test");

sms.beginSMS(senderNumber);
sms.print(txtMsg);
sms.endSMS();
delay(500);
}

The code that you posted does something. You failed to say exactly what it does. "It does not work" doesn't tell us anything.

You expect it to do something, based on something you do. You failed to tell us what you do, or what you expect the code to do.

The GSM library examples are ONLY provided for use on the GSM shields that Arduino sells. That does not appear to be what you are using.

I want to make an autoresponder. To be more specific, when someone sends me a SMS I want to identify the number using the following code :

if (sms.available()) {
sms.remoteNumber(senderNumber, 20);
Serial.println(senderNumber);

After I extracted the number, with the following code I want to send a SMS back :

String txtMsg("test");

sms.beginSMS(senderNumber);
sms.print(txtMsg);
sms.endSMS();
delay(500);

But it does not work.
However if I delete from code the part which identifies the number from receiving SMS and instead of

sms.beginSMS(senderNumber);

I use

int remoteNum("072+++++++");
sms.beginSMS(remoteNum);

It works.
And I want to reply back to any person who sent me SMS , not just to a number declared in code.

But it does not work.

There's that useless lame phrase, again.

The code either receives an SMS, or it doesn't. Which is it?

The code either properly extracts the phone number, or it doesn't. Which is it?

The code either sends an SMS to that number, or it doesn't. It's clear that this answer will be that it doesn't, but we are no closer to understanding why.

Anonymous printing sucks. Print the phone number in a more intelligent fashion:

   Serial.print("Get a text message from: [");
   Serial.print(senderNumber);
   Serial.println("]");

and maybe a clue-by-four will present itself.

I apologize for the misunderstanding but like I said the first time

I managed to send messages, but can not receive messages

Therefore I do not know if it's a problem with the code or with the GSM module. As you said

The GSM library examples are ONLY provided for use on the GSM shields that Arduino sells

Even if I upload ReceiveSMS code from the example, unchanged, shield does not receive SMS.

I attached a picture where I uploaded ReceiveSMS example, I can send as many messages I wish and nothing happens. It is a problem with receiving.

(SendSMS example works and others)

And to create an autoresponder I need to be able to receive a SMS.

123.png

Do you have an official GSM shield? If not, what makes you think code written for one kind of hardware will work with yours? Have you looked for a library written specifically for yours?