//
If
there's
data
returned
sent
to
the
cell
module:
if (gprs.available())
{
//
it
to
the
serial
port:
Serial.write(gprs.read());
}
Because the Arduino’s memory is very limited, the receive buffer is
relatively small (64 bytes). If you’re not checking the response often, you’ll
most likely lose data to buffer overrun.
Example 3: Phone Calls
Remember when cell phones were used to make and receive phone calls?
When you would actually
speak
and
listen
to the person you were
communicating with? They can still do that! The MG2639 Cell Shield can do
that! If you’re longing for the good old days, or want to create your own
version of the Port-o-Rotary, here’s an example that turns your MG2639
into a phone.
Before proceeding with this example, you’ll need to connect a microphone
and speaker to your shield. You’ll also need to make sure your cell plan
includes the ability to make and receive voice calls.
If you’re using a passive microphone and speaker, you can simply connect
them to the differential pins on the audio port. Connect the microphone pins
to MIC+ and MIC- and speaker wires to SPK+ and SPK-. Or you can come
up with a more elegant, amplified solution using the single ended inputs.
Full-size breadboards are perfect for creating a breadboard handset.
It is important to remember which pair of audio channels you use, the
MG2639 can only interact with one at a time.
Running the Example
To load up the MG2639_Phone example, go to File > Examples >
SparkFun MG2639 CellShield > MG2639_Phone.
Depending on which audio channel you use, you may need to alter the
phone.setAudioChannel(AUDIO_CHANNEL_DIFFERENTIAL)
line to
phone.setAudioChannel(AUDIO_CHANNEL_SINGLE)
. Then click upload.
As with every other sketch, send any character in the serial monitor to
make it run. Next, either try calling your MG2639 from another phone, or
type D1234567890X to dial a phone number (“D” indicates the beginning of
a phone number, “X” indicates the end, they’re case-sensitive).
Page 18 of 22