The most important piece of information you’ll need is probably your phone
number, if you don’t already know it. You can use the
cell.getPhoneNumber(char * phoneNumber)
function for this purpose. For
example:
// getPhoneNumber requires one parameter
a char array
// with enough space to store a phone number (~15 bytes).
// Upon return, cell.getPhoneNumber(myPhone) will return
// a 1 if successful, and myPhone will contain a char array
// of your module's phone number.
status = cell.getPhoneNumber(myPhone);
if (status > 0)
{ // If the function successfully returned, print the #:
Serial.print("My phone number is: ");
Serial.println(myPhone);
}
Getting the module’s CIMI, ICCID, and other information follows a similar
pattern of passing an array by reference. Consult the comments in the
sketch for help using those functions.
Example 1: Text Messages
The library includes a fun example sketch the demonstrates how to send
and receive text messages. If your cellular plan has SMS-ability, give the
MG2639_SMS_Responder example a try!
With the SFE_MG2639_CellularShield library installed, open the sketch by
going to
File
>
Examples
>
SparkFun MG2639 CellShield
>
MG2639_SMS_Responder
.
You shouldn’t have to change anything here, simply upload the sketch to
your Arduino/shield combo.
Running the Example
The purpose of this example is to demonstrate how to receive text
messages, act upon them, and send an SMS of our own. If the Arduino
receives an expected text message string, it’ll respond with a sensor
reading. For example, if you send a text message saying “Read A0” (like
that, case-sensitive), the Arduino will send a text message back containing
the current analog voltage on A0. “Read D13” will return the digital value of
D13 – 0 or 1.
Page 12 of 22