Arduino GSM Shield Help for Student Robotics Project

Long story short we are trying to develop a cheap solution to help poor rural farmers in Nepal with tracking their cows. We have a device where we want the cows to wear a collar that has a Arduino with the GSM shield to record their GPS location and send the coordinates to a phone.

After many ideas and failures we are back to square one.

Right now we are simply trying to get the GSM Shield 2 SendSMS example code to work. We reach the point where in the serial monitor it asks for the phone number. We type in our cell phone with the country code but nothing happens after that. It just stalls at this point.

Any ideas, suggestions, or help?

Any ideas, suggestions, or help?

Post your code!

/*
SMS sender

This sketch, for the Arduino GSM shield,sends an SMS message
you enter in the serial monitor. Connect your Arduino with the
GSM shield and SIM card, open the serial monitor, and wait for
the "READY" message to appear in the monitor. Next, type a
message to send and press "return". Make sure the serial
monitor is set to send a newline when you press return.

Circuit:

  • GSM shield
  • SIM card that can send SMS

created 25 Feb 2012
by Tom Igoe

This example is in the public domain.

*/

// Include the GSM library
#include <GSM.h>

#define PINNUMBER ""

// initialize the library instance
GSM gsmAccess;
GSM_SMS sms;

void setup() {
// initialize serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}

Serial.println("SMS Messages Sender");

// connection state
boolean notConnected = true;

// Start GSM shield
// If your SIM has PIN, pass it as a parameter of begin() in quotes
while (notConnected) {
if (gsmAccess.begin(PINNUMBER) == GSM_READY) {
notConnected = false;
} else {
Serial.println("Not connected");
delay(1000);
}
}

Serial.println("GSM initialized");
}

void loop() {

Serial.print("Enter a mobile number: ");
char remoteNum[20]; // telephone number to send sms
readSerial(remoteNum);
Serial.println(remoteNum);

// sms text
Serial.print("Now, enter SMS content: ");
char txtMsg[200];
readSerial(txtMsg);
Serial.println("SENDING");
Serial.println();
Serial.println("Message:");
Serial.println(txtMsg);

// send the message
sms.beginSMS(remoteNum);
sms.print(txtMsg);
sms.endSMS();
Serial.println("\nCOMPLETE!\n");
}

/*
Read input serial
*/
int readSerial(char result[]) {
int i = 0;
while (1) {
while (Serial.available() > 0) {
char inChar = Serial.read();
if (inChar == '\n') {
result = '\0';

  • Serial.flush();*
  • return 0;*
  • }*
  • if (inChar != '\r') {*
    _ result = inChar;_
    * i++;*
    * }*
    * }*
    * }*
    }

Does your readSerial() function REALLY look like that? I seriously doubt that it does.

Read the stickies at the top of the forum - the ones that you were supposed to read BEFORE you blundered in here - and try again.

What are you using to enter the data? How is that application configured?

What use is that call to Serial.flush()?

My apologies for my BLUNDERING.

I did read the stickies. Most of it does not make sense to me. I am learning. I am new. I am trying to learn code AND help students who are above me on many levels. I apologize for being ignorant and not as smart.

I have spent hours and hours and more hours with the kids. We have stripped things all the way back to ground zero.

We are starting here with just the shield.

The code provided comes from the examples.

Your questions about things I cannot answer because I don't know what most do or mean. Yes, I have read forums and websites. I did not just come flying in here without doing my homework.

I just wanted to help the kids and see if we could get this working and then we can begin to understand it all.

Sorry for my ignorant post. If I were smarter, then I would not have had to post in the first place.

UPDATE

We are able to receive messages to the Arduino when we run the ReceiveSMS example, but still cannot do the SendSMS