
Arduino to GM862 pin connection
It took some effort to figure out how to connect the GM862 GSM module to a UART (in my case the Arduino USB evaluation board, so I decided to document the steps here.
I also have the GM862 USB Evaluation board, if you plan to use this board and control the GM862 from Arduino, e.g., to programmatically send an SMS message, then you need to be careful how you power the GM862 USB board. If you power it via a battery or external power source (but not USB), then you’re fine. Otherwise, you must remove the jumper that disconnects the TX and RX pins from the GM862 USB FT232. To remove this jumper, you must remove the solder that is on the pins marked TX-I and RX-O. This Sparkfun.com board is not designed to accept a two pin header and a plastic jumper to allow you to easily switch between USB control and external control. So to get going, don’t use the GM862 USB to power the GM862, whilst it is being externally controlled through your Arduino board.
For a minimum implementation, only the TXD and RXD lines needs to be connected, the other signals of the GM862 modem serial port (DCD/pin 36, DTR/pin 43, DSR/pin 33, RTS/pin 45, CTS/pin 29, and RI/pin 30) can be left open provided a software flow control is implemented (which is what we are trying to do).
You’ll need to disconnect the RX pin 0 on the Arduino board each time you upload your program. If you don’t, upload will fail with the “avrdude: stk500_recv(): programmer is not responding” error message. After you’ve uploaded the program you can reconnect pin 0. Pin 1 can remain connected at all times, so there is no need to disconnect pin 1.
It helps to have a LED attached to the status indicator LED (pin 39 of GM862), but this is optional and not required for you to control the GM862 from Arduino. Pin 39 is an Open Collector output where we can directly connect a LED to show network and call status information (fast blink means net search, not registered or turning off, slow blink means registered full service, always on means a call is active). I connected a LED with a pull-up resistor.
After connecting the Arduino RX pin (pin 0) to GM862 RX-O pin (pin 37), Arduino TX pin (pin 1) to GM862 TX-I pin (pin 20), and Arduino Ground to GM862 Ground, you are ready to take control of GM862 right from Arduino (click on the thumbnail for detailed schematics). To test this set up, send a SMS message. Here is the code to do just that:
#include <SoftwareSerial.h>
int rxPin = 0;
int txPin = 1;
// set up a new serial port
SoftwareSerial serial=SoftwareSerial(rxPin,txPin);
void setup() {
pinMode(rxPin, INPUT);
pinMode(txPin, OUTPUT);
// set the data rate for the SoftwareSerial port
serial.begin(9600);
// Set SMS to text mode. Note it is critical
// to use \r\n to end each line
// The delays are also critical, without them,
// you may lose some of the
// characters of your message
serial.print("AT+CMGF=1\r\n");
delay(300);
serial.print("AT+CMGS=");
delay(300);
// Replace with a valid phone number
serial.print("+14081234567\r\n");
delay(300);
serial.print("Hello from Arduino.");
delay(300);
// End the SMS with a control-z
serial.print(0x1A,BYTE);
}
void loop() {
}
Here is a function that takes a char array and use that as the content of the SMS. Not sure if a delay after each print statement is really needed or not.
#define PHONE_NUMBER "+14081234567\r\n"
#define PRINTDELAY 500
void sendSms(char msg[]) {
modem.print("AT+CMGF=1\r\n");
delay(PRINTDELAY);
modem.print("AT+CMGS=");
modem.print(PHONE_NUMBER);
delay(PRINTDELAY);
modem.print(msg);
delay(PRINTDELAY);
modem.print(",");
delay(PRINTDELAY);
modem.print(millis());
delay(PRINTDELAY);
// End the SMS with a control-z
modem.print(0x1A,BYTE);
delay(PRINTDELAY);
}