Adafruit FONA 808 Help!

My group and I are trying to create a device to send a message to a cell phone… that is it.

So far we have a hologram SIM card, and the adafruit FONA 808 – our code is attached.

The problem we encounter is:

a) The device sometimes connects to the network but most of the time it is searching for service, so it is not a steady connection.

b) The device does not send to my phone number. When it should send, it doesn’t. I don’t know what the problem is. is it the format I put my phone number in or what?

c) Finally, my input to the serial monitor doesn’t work. I should be able to input 'i" into the serial monitor and it should return a signal status, but “i” doesn’t even get inputted into the serial monitor.

Thank you

v3.ino (3.09 KB)

OP’s unedited code:

#include <Adafruit_FONA.h>

/*
 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.

 http://www.arduino.cc/en/Tutorial/GSMExamplesSendSMS

 */

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

#define PINNUMBER ""


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

// char array of the telephone number to send SMS to:
char remoteNumber[20]= "2166450596";

// Switch LCD out for status LEDS? Makes the code easier
// GPS lock, Message sent, etc


void setup() {
  // Connect to PC:
  // 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) {
    Serial.println("Test");
    delay(1000);
    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);

// Calculate GPS position:
// https://learn.adafruit.com/adafruit-fona-808-cellular-plus-gps-breakout/gps-fona808
// if GPS fix:
// GPS LED = on
// query location time data
// take the latitude and longitude out of the gps string

// CAUTION: The data is in degrees and minutes in the following format: Latitude: 
// DDMM.MMMM (The first two characters are the degrees.) Longitude: DDDMM.MMMM (The first three 
// characters are the degrees.) You may need to convert to decimal degrees, but that can be added later.

// Make the data into a text message:
// test string:
String str = "4043.576433,7400.316980";
int str_len = str.length() + 1;
char gpsMsg[str_len];
str.toCharArray(gpsMsg, str_len);

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

  // send the message
  sms.beginSMS(remoteNumber);
  sms.print(gpsMsg);
  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[i] = '\0';
        Serial.flush();
        return 0;
      }
      if (inChar != '\r') {
        result[i] = inChar;
        i++;
      }
    }
  }
}