The cellphone module.

Pin Reference

The cellphone module breaks out many pins of the microcontroller, allowing you to use them with standard Arduino commands like pinMode(), digitalWrite(), digitalRead() etc. The special functions of the pins are as follows.

PWM (analogWrite())
Pins 12, 13, 14, 15.
Analog Inputs
Pins 24 (A0) through 31 (A7). Note: use analogRead(A0), not analogRead(24), and so on. (Using analogRead(24) will actually read from pin 31, analogRead(25) from pin 30, etc.)
SPI
Pins 5 (MOSI), 6 (MISO), 7 (SCK).
I2C / TWI (Wire library)
Pins 16 (SCL) and 17 (SDA).
Audio
MIC and SPK pins. Each of these pairs of pins connects directly to the GSM module on the board, providing audio for phone calls. Note: the speaker needs to have a resistance of at least 32 ohms; to use a lower-resistance speaker, you'll need to include an amplification circuit.

A small breadboard with components you might connect to the GSM module: potentiometer (in blue), microphone, and pushbutton.

Cellphone Module

The Cellphone Module is the core of a basic cellphone. It can connect to cellular GSM networks (using a standard SIM card) to make phone calls and text messages and contains an Arduino-compatible microcontroller that can be programmed to control various sensors and actuators. The module is powered by a 3.7V lipo battery, which can be recharged via a mini-USB port on the module. The cellphone module is based on the Arduino GSM Shield. The module is open-source and available on GitHub (hardware, software).

Warning: the cellphone modules runs at a lower voltage (3.7 to 4.2V) than most Arduino boards. Don't connect 5 volts to its pins. Components that require 5V may not work properly with the cellphone module.

Note: the cellphone module has some slight differences from the Arduino GSM shield. As a result, you'll need to make a small change to the examples from the Arduino GSM library to use them with the module.

Tools and Parts

To work with cellphone module, you'll need a few additional parts:

Installing Software

The cellphone module can be programmed using the Arduino software and the Arduino GSM library. Because the cellphone module contains a microcontroller (the ATmega1284P) not found on standard Arduino boards, it requires an additional download.

  1. Download the Arduino software, version 1.0.5.
  2. Install the FTDI drivers for your operating system.
  3. Install the Git version control software. See, for example, the instructions from GitHub for Windows or Mac.
  4. Checkout the cellphone's source code from GitHub, e.g. "git clone https://github.com/damellis/cellphone2.git". Then "cd cellphone2" to change into the source code's directory.
  5. Checkout the other repositories used by the cellphone's software with "git submodule init" and "git submodule update".
  6. Checkout the module branch with "git checkout module". (The default master branch has code for the DIY cellphone.)
  7. Run Arduino and, in the preferences dialog, set your sketchbook folder to the cellphone2 directory (that you checked out from github).
  8. Also in the preferences dialog, enable verbose information on compile and upload. (This will help you debug if anything goes wrong.)
  9. Restart the Arduino software.
  10. You should see "DIY Cellphone" in the Tools > Board menu. That means you've successfully installed support for the cellphone module.

Troubleshooting: if you don't see "DIY Cellphone" in the Boards menu, make sure that you've set the sketchbook directory to the cellphone2/ folder (in the Arduino preferences) and that there are files in the hardware/ folder folder of the cellphone2/ folder (if not, you'll need to do the "git submodule init" and "git submodule update" commands).

Programming the Module

Once you've installed the software as directed above, you can program the cellphone module as you would a regular Arduino board. You'll use the 3.3V FTDI cable to connect the board to the computer.

  1. Select "DIY Cellphone" from the Tools > Board menu.
  2. Plug the LiPo battery into the cellphone.
  3. Connect the 3.3V FTDI cable to the computer and to the 6-pin header on the module. The black wire goes on the side labelled "B", the green on the side labelled "G".
  4. Select the serial port corresponding to the FTDI cable from the "Tools > Serial Port" menu. (You can tell which one it is by checking the menu with the cable unplugged from the computer, then plugging it in, reopening the menu, and looking for new entries.)
  5. Open a sketch (e.g. File > Examples > Basics > Blink) in the Arduino software.
  6. Hit the upload button (the right-facing arrow in the toolbar) in the Arduino software.
  7. If the upload is successful, you should see "Done uploading." in the status bar. (If you uploaded the blink example, you should see the pin 13 LED – the one labeled "13" – blinking.)

Troubleshooting: if the upload fails, make sure the battery is connected and is charged, that the FTDI cable isn't backwards (i.e. that the green and black wires are on the sides labeled "G" and "B" respectively), and that you have the right entries selected in the Tools > Board and Tools > Serial Port menus.

Using Arduino Code

The cellphone module should support the standard Arduino functions described in the reference. See the pin reference above (to the left) for details on the special functions of particular pins.

Because the cellphone module is powered by a battery, there are some differences from other Arduino boards. The voltage of the board (e.g. on the VCC pins and when setting a pin HIGH) varies depending on the charge of the battery: 4.2V or so when it's fully charged, down to about 3.7V when close to empty. That means that you shouldn't connect the pins to 5V signals or power, because they might damage the board. It also means that components that require 5V power probably won't work with the board. (You might be able to use an external 5V supply to power them, but you'll need to make sure that the signals they send to the board are limited to below the board's voltage.)

Connecting to the Network

The cellphone module can connect to a GSM network to make and receive phone calls and text messages. There are examples of this in the cellphone2 source code you installed, which should be visible in the File > Sketchbook menu. You can also try the examples from the Arduino GSM library (in File > Examples > GSM), although you'll have to make the modification described in the next section.

  1. Insert a SIM card into the socket.
  2. Upload the AnswerCall sketch.
  3. Once the upload is finished, the LED labeled 13 should turn on. Once the module connects to the network (which may take a while), the LED will turn off.
  4. Call the cellphone module by using another phone to dial the number of the SIM card in the module. The LED labeled 13 will flash.
  5. To answer the call, use a wire to briefly connect pin 31 to ground (GND).

Troubleshooting: It may take a while for the cellphone to connect to the network. If it doesn't connect after a few minutes, try resetting the board (by pressing the small reset button). You can see debugging information in the Arduino serial monitor at 9600 baud.

Working with the Arduino GSM Library

The cellphone modules uses a different pin than the Arduino GSM shield to power on the GSM module (Quectel M10) on the board. As a result, you'll need to make a small change to the examples in the Arduino GSM library to use them with the cellphone module. In particular, add the following lines just above the call to gsm.begin():

  pinMode(19, OUTPUT);
  digitalWrite(19, LOW);
  delay(12000);
  digitalWrite(19, HIGH);

This will turn on the GSM module using the correct pin for the cellphone module.

Additions to the Arduino GSM Library

The cellphone module includes a GSMExtras library with some additions to the Arduino GSM library. They include functions for setting the volume of a speaker, for setting and getting the time, and for playing DTMF tones.

Serial Debugging

If the cellphone module seems to be having trouble connecting to the network, you can get additional debugging information in the serial monitor in the Arduino software. Be sure to pass true to the constructor of the GSM in your Arduino sketch, as shown:

GSM gsm(true);

Then open the serial monitor by clicking the magnifying glass icon in the upper right corner of the Arduino software. (Be sure you've got the FTDI cable connected and the appropriate entry selected from the Tools > Serial Port menu.) Make sure the baud rate is set to 9600 in the lower right corner of the serial monitor. Opening the serial monitor will reset the program running on the module, so may have to wait 10-15 seconds for the debug messages to start. You should see something like this:

AT%13%
0 9>AT%13%%13%%10%OK%13%%10%
AT+CGREG?%13%
9 40>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%
40 71>AT+CGREG?%13%%13%%10%+CGREG: 0,2%13%%10%%13%%10%OK%13%%10%
AT+CGREG?%13%

The relevant piece is +CGREG: 0,2, the last number of which indicates the status of the network registration. A value of 0,2 means "trying to connect", 0,1 means "connected", 0,0 means "failed to connect", and 0,3 means "connection denied". In practice, I've seen 0,3 when the reception wasn't good enough to get a connection. Also, there's no particular status to indicate the absence of a SIM card; you'll get just 0,2 forever. If you're not getting a connection (and the SIM card is in), try resetting the board every couple of minutes by pressing the small button near the GSM module.

If you don't see anything more than AT%13%, the GSM module isn't responding to your Arduino sketch. Make sure you have the lines described above for using pin 19 to turn on the GSM module. Also, check the LED labelled "LED2" near the GSM module. It should be on, and blink off briefly just before the AT%13% appears in the serial monitor.