Drive the module via USB port (AT command)

Last revision 2026/01/20

The sketch for controlling the GSM/GPRS/GPS module via SMS to turn an LED on/off.

How to drive the GPS Mode via USB port

NOTE: You have to take the module outdoor to get valid GPS data. If you are only to test its AT command, you can stay inside.

Steps:

Code for GPS feature, AT mode

void setup() {
  //Init the driver pins for GSM function
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  //Output GSM Timing
  digitalWrite(5, HIGH);
  delay(1500);
  digitalWrite(5, LOW);
}

void loop() {
  digitalWrite(3, HIGH); //disable GSM TX、RX
  digitalWrite(4, HIGH); //disable GPS TX、RX
}
  1. Stack this GPS/GSM shield onto Arduino UNO (Leonardo is special, you could go to FAQ, Q8 to know how), then connect UNO to computer with a USB cable.
    • NOTE: The SIM card & External power source can be omitted here, we don't need that so far. But if you have inserted a SIM card onto the module, you do NEED an external power then, a mere USB power is NOT capable to run it!
  2. Turn the S1 to Prog
  3. Upload the sample code "Code for GPS feature, AT mode" in right
  4. Turn the three switches to: S1: Comm, S2: USB, S3(UART): GSM
  5. Connect the CoolTerm serial port
    • The Serial monitor command format should be set as 9600, CR LF in Option.
    • If you found the STAT & NET led turned off, please press RST button (or disconnect and re-connect the serial port) to reboot the module.
  6. Send AT commands below, you will receive corresponding OK from the module as showing in the picture
    1. Send: AT
    2. Send: AT CGPSIPR=9600 (set the baud rate)
    3. Send: AT CGPSPWR=1 (turn on GPS power supply)
    4. Send: AT CGPSRST=1 (reset GPS in autonomy mode)
  7. Turn the switch S3(Uart) to the GPS, you could receive the GPS data.
  8. If you want turn GPS off.
    1. Turn the Uart switch to GSM side
    2. Send AT CGPSPWR=0(turn off GPS power supply, in code)
    3. Send AT CPOWD=1 ( turn off GSM/GPS/GPRS module, in code)
  9. If you want to restart the module, press RST button please.
    USBgps.jpg
    TEL0051_GPS_USB_module.png
NOTE: What is the meaning of GPS data received? Please refer to Location Mapping (GPRMC), you could also go to FAQ>Q2 for more info.

How to Send a message

NOTE: Before you test GSM function using AT command (including Make a call or other function related to GSM). You have to upload the code below to enable GSM.

Steps:

Code for GSM feature, AT mode

void setup(){
  //Init the driver pins for GSM function
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  //Output GSM Timing
  digitalWrite(5, HIGH);
  delay(1500);
  digitalWrite(5, LOW);
}
void loop(){
  digitalWrite(3, LOW); //enable GSM TX、RX
  digitalWrite(4, HIGH); //disable GPS TX、RX
}
  1. Repeat the steps in NO.2 How to enter AT mode, sending AT command? to enter AT mode.
    • You should upload the code "Code for GSM feature, AT mode" this time in right
  2. After you entered AT mode, you can:
    1. Send: AT
    2. Send: AT CMGF=1 (set the message to text format)
    3. Send: AT CMGS="XXXXX" (xxxx is the number of receiver)
    4. After you see ‘>’ then type the message you want to send
    5. Press 'ctrl Z' to send. (If you want to cancel, you can press ESC)
      • NOTE: This step depends on the Serial software you use and its configuration. Arduino Serial Monitor can not accomplish this. Please go to the section below, "Ways to send Ctrl Z in Coolterm", for more details.
  3. Then you will see "OK". After several seconds, the receiver should get a message from this shield.

USBsendmessage.jpg

Ways to send Ctrl Z in Coolterm

Method 1. After typing the message text, press enter key, it will show:

'Enter' after text finished

Then, in the input area, pressing Ctrl Z will send out the single CTRL character successfully as below:

Note: This key shortcut depends on your version and configuration.

After press Ctrl Z

Method 2. Ctrl characters can also be sent out in their hexadecimal, Ctrl Z = '1A', this avoids problems with Coolterm version and configurations.

This method can be used with other Serial softwares, e.g. [DF Serial Debugger by Lisper](https://github.com/leffhub/DFRobotSIM808_Leonardo_mainboard/raw/master/Software/DF Serial Debugger.exe)), clike here to know more detals about how.

Sending Ctrl Z with in hexadecimal format

How to Make a phone call

Steps:

  1. Send: AT
  2. Send: ATDXXXXXXX;(xxxxxxx is the number of receiver, please do not forget the semicolon ";")
  3. Then you will see "OK". And after several seconds, the receiver should get a phone call from this shield.
  4. If you want to cancel/ hang up the call, send: ATH
    • ATA : Answer the phone

USBphonecall.jpg

Was this article helpful?

TOP