You are on page 1of 34

AN1373

Using PIC32 MCUs to Develop GSM/GPRS/GPS Solutions


Authors: Adam Folts Microchip Technology Inc., with contributions from u-blox AG

Feature Overview
The M2M PICtail Plus Daughter Board contains many features, including GSM, GPRS, and GPS. Global System for Mobile Communication (GSM) GSM is a popular world-wide standard for mobile telephone systems. GSM includes technologies in both signaling and speech channels, which are digital; therefore, GSM is considered a Second Generation (i.e., 2G) mobile phone system. This facilitates the wide-spread implementation of data communication applications into the system. GSM also implements a Short Message Service (SMS), called text messaging. General Packet Radio Service (GPRS) GPRS is a service on 2G and 3G cellular communication systems (GSM). GPRS provides data rates of 56-114 kbps, which provides users with the capability to connect to the Internet. Global Positioning System (GPS) GPS is a space-based navigation system that provides reliable location and time information in all weather conditions and at all times, and anywhere on or near the Earth when and where there is an unobstructed line of sight to four or more GPS satellites. It is freely accessible by anyone with a GPS receiver.

INTRODUCTION
Technologies that allow both wireless and wired systems to communicate with other devices of the same ability are referred to as Machine-to-Machine (M2M). M2M uses a device to capture an event, which is then relayed through a network to an application that translates the event into meaningful information. A common application of M2M is fleet management, where vehicle tracking is wirelessly transmitted to a central monitoring office over cellular networks. There are many popular M2M applications, one of which is a utility meter. One of the major benefits of a M2M-based utility meter over a traditional one, is immediate operational efficiency from reading and programming meters remotely, which eliminates the need to physically visit the meter. Another application becoming more popular with M2M technology is in-car GPS navigation. With this technology, consumers now have a complete GPS navigation system in their vehicles. This technology can be used to track a drivers current location, or provide a map for directions. Also, the consumer can make an emergency call from the same device that is doing the tracking. Businesses can use this technology for parking lots to know how long a vehicle has been parked and to charge it accordingly. The Microchip M2M PICtail Plus Daughter Board (referred to as the M2M Board) developed by u-blox AG, was designed to connect directly to the PICtail interface of the Multimedia Expansion Board (MEB), but can also be used with any PIC32 microcontroller. This application note describes a reference design that enables the implementation of GSM/GPRS/GPS connectivity using a PIC32 microcontroller (MCU), the M2M Board, and the MEB.

Functionality
The main functionality of the M2M Board is accomplished using two communications modules from u-blox A, which is a company that specializes in GSM/ GPS ICs. For more information, visit www.u-blox.com. The M2M Board was designed to connect to Microchips MEB. The MEB uses Microchips PIC32 starter kit collection as the primary controller source. This suite makes it easy to start and implement embedded controller projects due to its: Built-in debugger USB power source On-board header for easy attachment to PCBs PIC32 device with high-speed performance and no peripheral loss

2011 Microchip Technology Inc.

DS01373A-page 1

AN1373
HARDWARE DESCRIPTION
As previously mentioned, the M2M Board is built around two controller modules, the LEON-G200 and the NEO-6Q, which are available from u-blox AG. The LEON-G200 is a Quad Band GSM/GPRS data and voice module. Communications to the module are through AT commands. The UART module on the PIC32 device handles the AT commands. The LEON-G200 handles the GPS communications to the NEO-6Q module. The module also contains 1 MB of non-volatile memory that can be used for storing local or Internet files. The NEO-6Q GPS module uses the u-blox sixpositioning engine for its GPS positions support. In this hardware setup, it acts as a slave to the LEONG200, but can be a stand-alone module with its own set of AT commands. For more information on these two modules and a list of AT commands, visit www.u-blox.com. A block diagram of the reference design is provided in Figure 1. The M2M Board connects to expansion slot header J5 of the MEB. Figure 1 illustrates the connector pins. Descriptions of each pin are listed in Table 1.

FIGURE 1:

SCHEMATIC OF CONNECTOR TO MEB

+3.3V supplied from the MEB


+3.3V 1 3 5 7 9 11 13 SDA3 RESET_N PWR_ON SCL3 15 17 19 21 23 25 27

J2
2 4 6 8 RI DTR DSR VIN

HDR-TH_0.1-2X14

R6 4.7k

R7 4.7k

10 12 14 16 18 20 22 24 26 28

RXD TXD RTS CTS DCD

FIGURE 2:

REFERENCE DESIGN BLOCK DIAGRAM

M2M PICtail Plus Daughter Board

PIC32 MCU

UART LEON-G200 (u-blox) NEO-6Q (u-blox) GPS Module GSM/GPRS Module

DS01373A-page 2

2011 Microchip Technology Inc.

AN1373
The M2M board also implements the following: SAW filter The filter is located in front of the LNA to improve the GPS interference immunity (outband interference from collocation of near field Wireless communication). The SAW-LNA-SAW chain is implemented for best immunity and performance. SIM holder The holder is used for the SIM card, which enables GPRS/GSM communication evaluation. RF SMA Connector The connector is located in front of antenna detection and switch circuitry, which allows automatic hardware detection and connection onto a GPS external antenna. Using an external GPS external antenna is optional and allows for better GPS performance under poor GPS conditions. Figure 3 provides a detailed diagram of the M2M Board.

FIGURE 3:

M2M PICtail PLUS DAUGHTER BOARD BLOCK DIAGRM


UART VCC GSM Antenna LDO LEON-G200 GPRS/GSM Module SIM Holder NEO-6Q GPS Module SAWLNASAW GPS Antenna

RF Connector

2011 Microchip Technology Inc.

DS01373A-page 3

AN1373
TABLE 1:
Connector Pin Name RI DTR DSR RXD TXD RTS CTS DCD PWR_ON RESET_N

MEB CONNECTOR PIN DESCRIPTIONS


MEB Pin Name WIFI_SDO WIFI_SDI WIFI_SCK SDI3A SDO3A SCK3A SS3A/RF12 WIFI_CS RA10 Description UART ring indicator UART data terminal ready UART data set ready UART receive data UART transmit data UART ready to send UART clear to send UART data carrier detect Holds the device in reset

DEMONSTRATION DESCRIPTION
This section describes in detail what is contained in the GSM/GPRS/GPS demonstration. Some of the images may contain different graphics than those shown in this application note, but the basic functionality of the demonstration is still present. The MEB contains a 3.2" QVGA touch screen display, making the demonstration easy to follow, and shows how each service is set up. The Debug output of the PIC32 Starter Kit can be used to see which u-blox commands are being used throughout the demonstration. The demonstration starts with the initialization of all GSM/GPS/GPRS services. Notice in Figure 4 that most buttons seem disabled except for HELP and NEXT. Selecting NEXT initializes the M2M Board setup. The M2M Board requires a SIM card with a data plan to be inserted into the back of it in order for the GSM/GPRS demonstrations to function. The initialization step has three screens that initialize GPS, GPRS, and GPS technologies, one at a time. Some technologies require some time (10-30 seconds) for their service provider to respond.

C2OUT/AN9 Turns the device on/off

As seen in Table 1, most of the communication to the LEON-G200 is handled through the UART. The MEB communicates to the M2M Board through the UART. The baud rate can be an auto baud rate, and most of the common baud rates are acceptable. The PIC32 family of devices offer the same peripherals as seen on previous Microchip devices. See References for links to information on the hardware and the PIC32 device used in this reference design.

FIGURE 4:

MAIN DEMO SCREEN

The GSM demonstration shows the current signal strength and the service provider. With this demonstration, the user can also send a text message by selecting the SMS button, as shown in Figure 5. Once SMS is selected, the user will be taken to a screen where they can enter a phone number. Once the number is entered and a SIM card is inserted into the M2M Board, a message from the M2M Board will be sent to that phone number. By default, the M2M demonstration has SMS receiving turned ON. This means that if a text message is sent to the board, the demo will pause and show the number and message received, and then return to the demo.

DS01373A-page 4

2011 Microchip Technology Inc.

AN1373
FIGURE 5: GSM DEMO SCREEN FIGURE 7: GPS DEMO SCREEN

The GPRS demo (see Figure 6) shows to which IP address the device is connected. This screen initiates the basic Internet connection needed to create demonstrations, such as an e-mail service, simple Web browsing, and any other 2G phone feature involving an Internet connection.

FIGURE 6:

GPRS DEMO SCREEN

The map demo uses HTTP requests and the on-board 1 MB of memory to receive and store an image from the Internet. The image is from Google Maps and shows the current GPS location of the M2M Board. The demo only shows a static image of the current location, and is not configured for navigation. GSM, GPRS, and GPS capabilities need to be active for this demo to be enabled. Make sure the SIM card attached is active and that data services are available.

FIGURE 8:

MAP DEMO SCREEN

The GPS demonstration shows the current longitude and latitude coordinates, as shown in Figure 7. The Email button will become enabled when an active SIM card is present with data services available. By selecting the Email button, the user will be sent to a screen where an e-mail address can be entered, and if an e-mail server has been set up correctly, an e-mail can be sent. Refer to the BYTE acdEmailSetup() function to change the email server name. The M2M board does not support SSL-based SMTP servers. The Map button will remain enabled until GPS data is available. Note: GPS data is not ready until the LED labeled TIMEPULSE on the M2M Board is blinking green.

2011 Microchip Technology Inc.

DS01373A-page 5

AN1373
GSM/GPRS/GPS STACK DESCRIPTION
The GSM/GPRS/GPS stack was built around u-blox communication commands. The basic commands can be found on the u-blox AG website at: www.u-blox.com. This section describes in detail the high-level commands listed in Table 2, which are needed to interface with the GSM/GPRS/GPS stack. Detailed descriptions of each function are provided following the table.

TABLE 2:
UBX_STATUS

ENUMERATOR AND FUNCTION DESCRIPTIONS


Enumerator Description u-blox high-level interface is configured. u-blox high-level interface is not configured. C16-G26Q plug-in board is powered-on. C16-G26Q plug-in board is powered-off. C16-G26Q plug-in recognized as LEON-G200. C16-G26Q plug-in board is present. C16-G26Q plug-in board is not present. SIM card is present. SIM card is not present. PIN on SIM card is enabled. PIN on SIM card is not enabled. GSM module is configured. GSM module is not configured. GSM network is registered. GSM network is not registered. GPRS is configured. GPRS is not configured. GPRS service is available. GPRS service is not available. GPS is configured. GPS is not configured. GPS is powered on. GPS is powered off. GPS with local aiding. GPS without local aiding. GPS AssistNow is off-line. GPS AssistNow is on-line. Success. Error, handling is required. Warning, can be ignored. Power-on GPS with local aiding (use GSM cell info where possible). Power-on GPS with AssistNow off-line (use 14 days almanac). Power-on GPS with AssistNow on-line. Head command. Get command. Delete command. Put command. Post file command. Post data command.

Structure

UBX_S_SYSTEM_CONFIGURED UBX_S_SYSTEM_NOT_CONFIGURED UBX_S_BOARD_POWERED UBX_S_BOARD_NOT_POWERED UBX_S_BOARD_PRESENT_LEONG200 UBX_S_BOARD_PRESENT UBX_S_BOARD_NOT_PRESENT UBX_S_SIM_PRESENT UBX_S_SIM_NOT_PRESENT UBX_S_PIN_ENABLED UBX_S_PIN_NOT_ENABLED UBX_S_GSM_CONFIGURED UBX_S_GSM_NOT_CONFIGURED UBX_S_GSM_NETWORK_REGISTRED UBX_S_GSM_NETWORK_NOT_REGISTRED UBX_S_PDP_CONFIGURED UBX_S_PDP_NOT_CONFIGURED UBX_S_PDP_SERVICE_REGISTRED UBX_S_PDP_SERVICE_NOT_REGISTRED UBX_S_GPS_CONFIGURED UBX_S_GPS_NOT_CONFIGURED UBX_S_GPS_POWERED UBX_S_GPS_NOT_POWERED UBX_S_GPS_ASSIST_LOCAL UBX_S_GPS_ASSIST_NONE UBX_S_GPS_ASSIST_OFFLINE UBX_S_GPS_ASSIST_ONLINE UBX_ERROR UBX_E_OK UBX_E_ERROR UBX_E_WARNING UBX_GPS_ASSIST_MODE UBX_GPS_ASSIST_LOCAL UBX_GPS_ASSIST_OFFLINE UBX_GPS_ASSIST_ONLINE HEAD GET DELETE PUT POST_FILE POST_DATA

HTTP_REQUESTS

DS01373A-page 6

2011 Microchip Technology Inc.

AN1373
Stack API Functions

UBX_ERROR ubxConfigureBoard(void)
Description
This function configures the C16-G26Q plug-in board.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 1.

UBX_ERROR ubxConfigureGps(void)
Description
This function configures the GPS module.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 3.

UBX_ERROR ubxConfigureGsm(void)
Description
This function configures the GSM network.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 2.

2011 Microchip Technology Inc.

DS01373A-page 7

AN1373
UBX_ERROR ubxConfigurePdp(char *apn)
Description
This function configures the GPRS service depending on the operators access point name.

Parameters
[in] apn Operators Access Point Name (APN)

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 4.

UBX_ERROR ubxConfigureSystem(UINT32 freq)


Description
This function configures the u-blox high-level interface.

Precondition
u-blox high-level interface should not be already configured

Parameters
[in] freq System (core) frequency

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
#include <plib.h> #include "libubx.h" #include "libp32.h" UBX_ERROR rc; rc = ubxConfigureSystem(SYSTEM_FREQ); if (rc != UBX_E_OK) { return; } DBPRINTF("System core is running at %d Hz\n", p32GetSystemClock()); DBPRINTF("Peripheral bus is running at %d Hz\n", p32GetPeripheralBusClock());

DS01373A-page 8

2011 Microchip Technology Inc.

AN1373
UBX_ERROR ubxGetBoardPowerStatus(void)
Description
This function returns the status of the C16-G26Q plug-in board power.

Returns
UBX_S_BOARD_POWERED UBX_S_BOARD_NOT_POWERED

UBX_STATUS ubxGetBoardStatus(void)
Description
This function returns the status of the C16-G26Q plug-in board.

Returns
UBX_S_BOARD_PRESENT_LEONG200 UBX_S_BOARD_PRESENT UBX_S_BOARD_NOT_PRESENT

UBX_STATUS ubxGetGpsAssistStatus(void)
Description
This function returns the current aiding mode of the GPS module.

Returns
UBX_S_GPS_ASSIST_LOCAL UBX_S_GPS_ASSIST_NONE UBX_S_GPS_ASSIST_OFFLINE UBX_S_GPS_ASSIST_ONLINE

UBX_STATUS ubxGetGpsPowerStatus(void)
Description
This function returns the power status of the GPS module.

Returns
UBX_S_GPS_POWERED UBX_S_GPS_NOT_POWERED

2011 Microchip Technology Inc.

DS01373A-page 9

AN1373
UBX_STATUS ubxGetGpsStatus(void)
Description
This function returns the status of the GPS module.

Returns
UBX_S_GPS_CONFIGURED UBX_S_GPS_NOT_CONFIGURED

UBX_ERROR ubxGetGsmNetworkOperator(char* netop)


Description
This function returns the name of the GSM network operator.

Parameters
[out] netop GSM network operator, null-terminated string

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

UBX_ERROR ubxGetGsmNetworkSignal(UINT32 *netss, char *netss_text)


Description
This function returns the signal strength of the GSM network.

Parameters
[out] netss GSM network signal strength, integer [0...5] [out] netss GSM network signal strength, null-terminated string

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

DS01373A-page 10

2011 Microchip Technology Inc.

AN1373
UBX_STATUS ubxGetGsmNetworkStatus(void)
Description
This function returns the status of the GSM network registration.

Returns
UBX_S_GSM_NETWORK_REGISTRED UBX_S_GSM_NETWORK_NOT_REGISTRED

Example
See Example 2.

UBX_STATUS ubxGetGsmStatus(void)
Description
This function returns the status of the GSM network.

Returns
UBX_S_GSM_CONFIGURED UBX_S_GSM_NOT_CONFIGURED

Example
See Example 2.

UBX_ERROR ubxGetPdpServiceAddress(char *ipadd)


Description
This function returns the IP address from GPRS service (current context).

Parameters
[out] ipadd GPRS service address, null-terminated string

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

2011 Microchip Technology Inc.

DS01373A-page 11

AN1373
UBX_STATUS ubxGetPdpServiceStatus(void)
Description
This function returns the status of the GPRS services.

Returns
UBX_S_PDP_SERVICE_REGISTRED UBX_S_PDP_SERVICE_NOT_REGISTRED

UBX_STATUS ubxGetPdpStatus(void)
Description
This function returns the status of the GPRS module configuration.

Returns
UBX_S_PDP_CONFIGURED UBX_S_PDP_NOT_CONFIGURED

UBX_STATUS ubxGetPinStatus(void)
Description
This function returns the status of the PIN code.

Returns
UBX_S_PIN_ENABLED UBX_S_PIN_NOT_ENABLED

UBX_STATUS ubxGetSimStatus(void)
Description
This function returns the status of the SIM card.

Returns
UBX_S_SIM_PRESENT UBX_S_SIM_NOT_PRESENT

DS01373A-page 12

2011 Microchip Technology Inc.

AN1373
UBX_STATUS ubxGetSystemStatus(void)
Description
This function returns the status of the u-blox high-level interface.

Returns
UBX_S_SYSTEM_CONFIGURED UBX_S_SYSTEM_NOT_CONFIGURED

Example
#include <plib.h> #include "libubx.h" UBX_ERROR rc; rc = ubxConfigureSystem(SYSTEM_FREQ); if (ubxGetSystemStatus() != UBX_S_SYSTEM_CONFIGURED) { return; } DBPRINTF("\nSystem configured\n");

UBX_ERROR ubxPowerOffBoard(void)
Description
This function turns off power to the C16-G26Q plug-in board.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

UBX_ERROR ubxPowerOffGps(void)
Description
This function turns off power to the GPS module.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

2011 Microchip Technology Inc.

DS01373A-page 13

AN1373
UBX_ERROR ubxPowerOnBoard(void)
Description
This function turns on power to the C16-G26Q plug-in board.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

UBX_ERROR ubxPowerOnGps(UBX_GPS_ASSIST_MODE mode)


Description
This function turns on power to the GPS module.

Parameters
[in] mode GPS aiding mode

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 3.

UBX_ERROR ubxRegisterGsmNetwork(void)
Description
This function registers to the GSM network.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 2.

DS01373A-page 14

2011 Microchip Technology Inc.

AN1373
UBX_ERROR ubxRegisterPdpService(void)
Description
This function registers to GPRS services.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
See Example 4.

UBX_ERROR ubxSendGsmShortMessage(char *gsmsn, char *sms)


Description
This function sends an SMS (text message) via the GSM network.

Parameters
[in] [in] gsmsn GSM subscriber number sms Short message (160 character maximum)

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

UBX_ERROR ubxUnregisterGsmNetwork(void)
Description
This function unregisters from the GSM network.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

2011 Microchip Technology Inc.

DS01373A-page 15

AN1373
UBX_ERROR ubxUnregisterPdpService(void)
Description
This function unregisters from the GPRS services.

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

UBX_ERROR ubxUpdateGpsContext(GPS_CONTEXT context)


Description
This function updates a GPS data context (read only selected message).

Parameters
[in] context GPS data context to update

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
#include <stdlib.h> #include <plib.h> #include "libubx.h" #include "libgps.h" UBX_ERROR rc; GPS_DATA_GGA *gga; rc = ubxUpdateGpsContext(GPS_C_GGA); gga = gpsGetGGA(); DBPRINTF("Altitude: %i m/sl\n", atoi(gga->alt)); DBPRINTF("Latitude: %f %s\n", atof(rmc->lat), rmc->lat_ns); DBPRINTF("Longitude: %f %s\n", atof(rmc->lon), rmc->lon_ew);

DS01373A-page 16

2011 Microchip Technology Inc.

AN1373
UBX_ERROR ubxUpdateGpsFullContext(void)
Description
This function updates all GPS data context (read all messages).

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

Example
#include <stdlib.h> #include <plib.h> #include "libubx.h" #include "libgps.h" UBX_ERROR rc; GPS_DATA_GSV *gsv; GPS_DATA_RMC *rmc; rc = ubxUpdateGpsFullContext(); gsv = gpsGetGSV(); rmc = gpsGetRMC(); DBPRINTF("Number of satellites used for tracking: %d\n", atoi(gsv->nst)); DBPRINTF("Latitude: %f %s\n", atof(rmc->lat), rmc->lat_ns); DBPRINTF("Longitude: %f %s\n", atof(rmc->lon), rmc->lon_ew);

UBX_ERROR ubxVerifyPin(char *pin)


Description
This function verifies the Pin code.

Parameters
[in] pin Pin code (null-terminated string)

Returns
UBX_E_OK UBX_E_ERROR UBX_E_WARNING

2011 Microchip Technology Inc.

DS01373A-page 17

AN1373
BYTE acdEmailSetup()
Description
This function sets up initial communications with an SMTP server. The M2M Board does not have SSL capabilities. The sender of the e-mail is also setup here.

Returns
BYTE showing return value of SMTP request. Value is 0 if no error.

BYTE acdSendEmail(char *Recipient, char *Subject, char *Message)


Description
This function sends an e-mail.

Parameters
[in] [in] [in] Recipient Subject Message character string of the e-mail to send the e-mail to character string of the subject of the e-mail character string of the message of the e-mail

Returns
BYTE value showing return value of SMTP request, value is 0 if no error.

BYTE acdHTTPRequest(BYTE requesttype, char *Servername, char *FileLocation, char *Filename)


Description
This function sends an e-mail.

Parameters
[in] [in] [in] [in] requesttype Servername FileLocation Filename BYTE defining HTTP request type (HEAD, GET, DELETE, PUT, POST_FILE, POST_DATA) Character string of server name Character string of server file location Character string of M2M file to save the file from HTTP server to LEON-G200 memory

Returns
BYTE value showing return value of HTTP request. Value is 0 if no error.

DS01373A-page 18

2011 Microchip Technology Inc.

AN1373
int acdReadM2MFile(char *Filename, unsigned char *File)
Description
This function sends an e-mail.

Parameters
[in] [in] FileName File Character string of Filename of local file Character string of File in PIC memory

Returns
Integer value showing BYTE length of file read from M2M memory.

2011 Microchip Technology Inc.

DS01373A-page 19

AN1373
Stack API Usage Examples
EXAMPLE 1: INITIALIZING THE M2M PICtail PLUS DAUGHTER BOARD

ubxConfigureBoard();

EXAMPLE 2:

INITIALIZING GSM

ubxConfigureGsm(); if (ubxGetSimStatus() == UBX_S_SIM_PRESENT) { ubxRegisterGsmNetwork(); break; } //Check to see SIM card is present

if (ubxGetGsmNetworkStatus() == UBX_S_GSM_NETWORK_REGISTRED) { acdSMSSetup(); //Setup SMS Reading }

EXAMPLE 3:

INITIALIZING GPS

ubxConfigureGps(); ubxPowerOnGps(UBX_GPS_ASSIST_OFFLINE);

EXAMPLE 4:

INITIALIZING GPRS

if (ubxGetGsmNetworkStatus() != UBX_S_GSM_NETWORK_REGISTRED) { ubxConfigurePdp(UBX_CONFIG_APN); break; }

EXAMPLE 5:

USING SMTP (SENDING AN E-MAIL)

acdEmailSetup(); //Sets up the SMTP server (generic is Yahoo server) acdSendEmail(EmailAddress,"Microchip M2M Board Message","This is a message from Microchip's M2M Board.");

EXAMPLE 6:

USING HTTP
//Type //HTTP //file //Read of HTTP request server location on server Google Maps JPEG

acdHTTPRequest(GET, "maps.google.com", temp, "Map");

EXAMPLE 7:

READING FROM MEMORY


//Reads file from M2M Board //to PIC32 memory

fileLength =acdReadM2MFile("Map", &PIC32MapMemoryLocation[0])

DS01373A-page 20

2011 Microchip Technology Inc.

AN1373
GRAPHICS LIBRARY DESCRIPTION
The demonstration uses the Microchip Graphics Library, version 2.11, which is a powerful library that makes creating a Graphical User Interface (GUI) such as this one fast and easy. The Microchip Graphics Library is free and available for download from: www.microchip.com/MAL.

REFERENCES
LEON-G200 and NEO-6Q Communications Modules (www.u-blox.com) LEON-G100 G200 2G GPS/GPRS AT Commands Manual GSM.G1-SW-09002 (www.u-blox.com) M2M PICtail Plus Daughter Board (www.microchip.com) Multimedia Expansion Board (MEB) (www.microchip.com/meb) PIC32 device family (www.microchip.com/PIC32)

2011 Microchip Technology Inc.

DS01373A-page 21

AN1373
APPENDIX A: SOURCE CODE
Software License Agreement
The software supplied herewith by Microchip Technology Incorporated (the Company) is intended and supplied to you, the Companys customer, for use solely and exclusively with products manufactured by the Company. The software is owned by the Company and/or its supplier, and is protected under applicable copyright laws. All rights are reserved. Any use in violation of the foregoing restrictions may subject the user to criminal sanctions under applicable laws, as well as to civil liability for the breach of the terms and conditions of this license. THIS SOFTWARE IS PROVIDED IN AN AS IS CONDITION. NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.

All of the software covered in this application note is available as a single WinZip archive file. This archive can be downloaded from the Microchip corporate Web site at: www.microchip.com

DS01373A-page 22

2011 Microchip Technology Inc.

APPENDIX B:
FIGURE B-1:

SCHEMATICS

U101
1 GND1 V_BCKP GND2 V_CHARGE_RESERVED CHARGE_SENSE_ADC1 GND3 GND4 GND5 DSR RI DCD DTR RTS CTS TxD RxD GND6 HS_DET PW R_ON GPIO1 GPIO2 RESET_N RESERVED1 RESERVED2 GND7 VCC GND12 GND11 ANT GND10 GND9 IC_BIAS1 M M IC_GND1 M IC_GND2 M IC_BIAS2 RESERVED3 SPK_N SPK_P HS_P GND8 VSIM SIM_RST SIM_IO SIM _CLK SDA SCL I2S_RXD_RESERVED I2S_CLK_RESERVED I2S_TXD_RESERVED I2S_W A_RESERVED 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 31 30 29 28 27 26

100nF_10%

10nF_10%

10pF_5%

39pF_5%

C113

C112

C111

C110

L100 10nH_3%

10nH_3%

L101

L103

CHARGE_SENSE 1-E4 100KOhm_5% R109 Nomount R118 res0402_nm DSR 1-F4 RI 1-F4,1-G5 DCD 1-F4 DTR 1-F4 RTS 1-F4 CTS 1-F4 TxD 1-F4 RxD 1-F4 100KOhm_5%

0Ohm_5%

coil0402_nm

Nomount

7 8 9 10 11 12 13 14 15 16 17 18

cap0402_nm

C100

R119

res0402_nm

R110

2011 Microchip Technology Inc. DS01373A-page 23

LEON-G200 MODULE AND ANTENNA

VBAT

VBAT

V_CHARGE

ANTENNA

V_BCKP

2 3

R103 0Ohm_5%

R100 0Ohm_5%

R104

ANT100
1 2

PA-25 FLEX

R105 0Ohm_5%

PWR_ON 1-G4 GPIO1 1-E8 GPIO2 2-G8 RESET_N 1-G4,1-G5 (I2C_DATA_READY) DATAREADY 2-F6 (TIME_AIDING) EXTINT0 2-E6

19

TP100 TP101 L102 BLM15HD182SN1_0402 1800ohm_25%

SPI_IRQn

20 21 22

SIM_VCC 1-F9 SIM_RST 1-G9 SIM_IO 1-F9 SIM_CLK 1-G9 SDA 2-D2 SCL 2-E2 TP102 TP103 TP104 TP105 TP106

SPI_MRST SPI_CLK SPI_CSn SPI_MTSR

R117 res0402_nm R120 res0402_nm

23 24 25

AN1373

LEON G100 G200

FIGURE B-2:

POWER BOARD HEADER

J101
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20

330uF 6.3V

C106

U102 CA05P4S14THSG

U103 CA05P4S14THSG

U105 CA05P4S14THSG

U104 CA05P4S14THSG

47pF_5%

C108

DS01373A-page 24 2011 Microchip Technology Inc.

AN1373

V_CHARGE

VBAT

V_GPS

CHARGE_SENSE 1-B3

DSR 1-B3 RI 1-C3,1-G5 DCD 1-C3 DTR 1-C3 RTS 1-C3 CTS 1-C3 TxD 1-C3 RxD 1-C3 PWR_ON 1-C3 RESET_N 1-D3,1-G5

V_GPS_EN 2-G8 GPS_RxD 2-E2 GPS_TxD 2-E2

20 PIN 2,54STRIP MALE RIGHTANGLE

FIGURE B-3:

SIM CARD HOLDER

100nF_10%

C107

res0402_nm

GND

IO_1

GND_TAB
9

100nF_10%

47pF_5%

47pF_5%

47pF_5%

47pF_5%

C104

C103

C102

C105

C101

2011 Microchip Technology Inc. DS01373A-page 25

SLM76CF3201P VQFN-8-1
R108 0Ohm_5% R107 0Ohm_5% R106 0Ohm_5% R102 0Ohm_5% R101
8

VDD

CLK

RST

IO_0

U100

J100
SIM_VCC 1-C10
1 5

CCVCC CCVPP CCIO CCCLK CCRST GND

SIM_IO 1-C10 SIM_CLK 1-C10 SIM_RST 1-C10 4 2 USB0002 2 4 USB0002

6 3 2 4

C707_10M006_136_2

AN1373

1 D100

3 D101

FIGURE B-4:

AMPLIFIER CIRCUIT
R116 10KOhm_5% GPIO1 1-C3

22KOhm_5%

R111

E2

B2

C1

C2

R113

INDICATOR
1 2

D102

D103

RING

820Ohm_5%

0603ORANGE R114 330KOhm_5% R115 0Ohm_5%

RESET_N 1-D3,1-G4

RI 1-C3,1-F4

0603 RED

INDICATOR

VBAT

NETWORK

B1

E1

1.2KOhm_5%

BC847S

T100

R112

DS01373A-page 26 2011 Microchip Technology Inc.

AN1373

VBAT

VBAT

C109 100nF_10% IC100 5 VCC 1 A Y 4 2 B GND NC7SZ02P5X 3

FIGURE B-5:

NEO-6Q GPS MODULE AND ANTENNA

560Ohm_5%

R221

10Ohm_5%

R224

27nH_5%

100KOhm_5%

L204

J200
15pF_5%
1

ESD9L5,OST5G

C222

73415-1691
2 3 4 5

U209

RF_SWITCH_CTRL 2-B12

MCX50OHMCONNECTOR

V_LNA

V_LNA

R222

100nH_5%

L202

4.7KOhm_5%

13 C212 4.7KOhm_5% 4.7KOhm_5% 47pF_5% R207 C202


17

GND3 MOSI_CFG_COM0
MISO_CFG_COM1 CFG_G PS0_SCK RESERVED3

GND2 RF_IN GND1 VCC_RF

12 11 10 9 8 C208 15pF_5% 1 OUT

U205 1575.42MHz
B7839

CTRL RFC

RF2 GND

3 2

R206

R208

16

B7839

4.7nH_+-0.2nH

C210

1uF_10% SDA 1-C10 SCL 1-D10 GPS_TxD 1-G4 GPS_RxD 1-G4


1

RESERVED2

VSS 7

GND 3 15pF_5% C207 L201

L203

PE4259

PON

BIAS

G3 5

G2 3

G1 2 B7839

47nH_5%

BGA715L7

1.8pF_+-.25pF

1.8pF_+-.1pF

ML-621S/DN

1uF_10%

C217

B200

NFL18ST207X1C3

U207

2011 Microchip Technology Inc. DS01373A-page 27

V_LNA

100nF_10% C219

V_LNA

VAL
2 6

V+
PAD 3

1 4

SHDN_n

RF_SWITCH_CTRL 2-C5

10nF_10%

C224

V5

LT6000IDCB

U201

100nF_10% C220 V_LNA

15pF_5% C216

ANT200 PA1575MZ50I4G_INPAQ
Nomount

Nomount
C206 1uF_10%

V_GPS

V_GPS

V_GPS

U200

U202

C205 27pF_5% 5 TR200 6 OUT VCC U203 1575.42MHz OUT


B7839

14
15

IN

4 C223 15pF_5%

5 6

15pF_5%
1

0Ohm_5% IN 4 R200

CTRLn_VDD RF1

IN

C204

G3

G2

G1

C209

ANT201 SGP1575254D02_TAOGLAS GPS ANTENNA

NFL18ST207X1C3 NFL18ST207X1C3 TP200 TP201 NFL18ST207X1C3 NFL18ST207X1C3

U208 U210 U211 U212

18 19 20 21 22

SDA2 SCL2 TXD1 RXD1 V_BCKP VCC GND4

VDDUSB USB_DP USB_DM EXTINT0 TIMEPULSE


SS_N

7 6 5 U206 4 3
2

V_GPS

D202
2

EXTINT0 1-D3

(TIME_AIDING)

NFL18ST207X1C3

BAT62-02W

R209 4.7KOhm_5%

23 TP202 24

RESERVED1

NEO-6Q GPS MODULE

V_GPS D200 R201


2 1

470Ohm_5%

0603GREEN

TIMEPULSE
DATAREADY (I2C_DATA_READY) 1-D3

AN1373

FIGURE B-6:

VOLTAGE REGULATOR CIRCUIT

10uF_20%

10nF_10%

100KOhm_5%

C201

R213

GND 4

GPIO2 1-D3

R215 0Ohm_5% 100KOhm_5% R202 res0402_nm 56KOhm_1% R205 R210

V_GPS_EN 1-G4

R204

C200

SHDNn SENSE_ADJ 2

91KOhm_1%

Nomount

C203

BYP 3

10uF_20%

DS01373A-page 28 2011 Microchip Technology Inc.

AN1373
V_GPS

VBAT

U204 LT1962EMS8 ADJ


8 IN OUT 1

FIGURE B-7:

GSM/GPS POWER SUPPLY DAUGHTER BOARD

HDR-TH_0.1-2X14

3 12 5 14 7 16 9 18 11 20 13 22 15 24 26 28

HDR-TH_0.1-2X8

LM20343

GND

GND

C3 C2 3.9nF 6.8nF

GND

21

2011 Microchip Technology Inc. DS01373A-page 29

J2
1 3 5 2 4 6 8 1 9 11 13 15 17 19 21 23 25 27 10 2 4 6 8 10 12 14 16

CHARGER+

GND

+3.8V

R6 4.7K

R7 4.7K

J3

D1

+VIN D2 C1 22uF GND C9 C7 22uF 4.7uF C8 U1 5 6 16 15 4.7uF VIN VIN VIN VIN
19 EN 20 RT 4 COMP 14 SW 13 SW SW 8 SW 7 BOOT FB VCC PGOOD PE 17 2 18 3

L1 10uH C6 100nF R4 37.4K C5 R5 10K 100uF C10 100uF C11

R1 69.8K

R2 953R

1 12

SS/TRK AGND

AN1373

100uF

9 10 11

R3 12.7K

C4 1uF

APPENDIX C:
FIGURE C-1:

LAYOUT

R114

Ring

R111 C109

Network

D103

D102

R213

R204

C203

C201

I C100

R112

R115

R113

U204

R210

R205

R215 C110 C111

R202

R118

R119

R105 L101 C100 L100 R100 R104 L103

C205

R206

C210 C207 U203

C206

L201

TR200

C204

Timepulse
D200
R201 D202 R209 C217 R110 C212

B2 0 0

External Antenna Connector J200

L203 C216 R200

LEON-G200
TP106 TP202 TP100

NEO-6Q
U209 C222 C209 L204 R224

R109

C202

U101

TP201
U212

TP101

U20 6

TP200
R101 U211 R208 R102

TP102

C224

U200

C219

U202

U210 R207 U208

TP103

U20 1

C223

C220

TP104

U205

R221 R222

C208 R117 R107 R106 R108 C107 R120

L202

L102

U207

U100

TP105

25

26

ANT10 0

R103

DS01373A-page 30 2011 Microchip Technology Inc.

AN1373

M2M BOARD LAYOUT (TOP ASSEMBLY)

OPT100
J101
C108 U104 U103 U102 U105

ANT201
R116

ANT200
T100

C106
C200

C112 C113

50

FIGURE C-2:

M2M BOARD LAYOUT (BOTTOM ASSEMBLY)

2011 Microchip Technology Inc. DS01373A-page 31

C104

D100

C103

J100

C105 C101
D101

C102

OPT101

AN1373

FIGURE C-3:

GSM/GPS POWER SUPPLY DAUGHTER BOARD LAYOUT

DS01373A-page 32 2011 Microchip Technology Inc.

AN1373

Note the following details of the code protection feature on Microchip devices: Microchip products meet the specification contained in their particular Microchip Data Sheet. Microchip believes that its family of products is one of the most secure families of its kind on the market today, when used in the intended manner and under normal conditions. There are dishonest and possibly illegal methods used to breach the code protection feature. All of these methods, to our knowledge, require using the Microchip products in a manner outside the operating specifications contained in Microchips Data Sheets. Most likely, the person doing so is engaged in theft of intellectual property. Microchip is willing to work with the customer who is concerned about the integrity of their code. Neither Microchip nor any other semiconductor manufacturer can guarantee the security of their code. Code protection does not mean that we are guaranteeing the product as unbreakable.

Code protection is constantly evolving. We at Microchip are committed to continuously improving the code protection features of our products. Attempts to break Microchips code protection feature may be a violation of the Digital Millennium Copyright Act. If such acts allow unauthorized access to your software or other copyrighted work, you may have a right to sue for relief under that Act.

Information contained in this publication regarding device applications and the like is provided only for your convenience and may be superseded by updates. It is your responsibility to ensure that your application meets with your specifications. MICROCHIP MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND WHETHER EXPRESS OR IMPLIED, WRITTEN OR ORAL, STATUTORY OR OTHERWISE, RELATED TO THE INFORMATION, INCLUDING BUT NOT LIMITED TO ITS CONDITION, QUALITY, PERFORMANCE, MERCHANTABILITY OR FITNESS FOR PURPOSE. Microchip disclaims all liability arising from this information and its use. Use of Microchip devices in life support and/or safety applications is entirely at the buyers risk, and the buyer agrees to defend, indemnify and hold harmless Microchip from any and all damages, claims, suits, or expenses resulting from such use. No licenses are conveyed, implicitly or otherwise, under any Microchip intellectual property rights.

Trademarks The Microchip name and logo, the Microchip logo, dsPIC, KEELOQ, KEELOQ logo, MPLAB, PIC, PICmicro, PICSTART, PIC32 logo, rfPIC and UNI/O are registered trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. FilterLab, Hampshire, HI-TECH C, Linear Active Thermistor, MXDEV, MXLAB, SEEVAL and The Embedded Control Solutions Company are registered trademarks of Microchip Technology Incorporated in the U.S.A. Analog-for-the-Digital Age, Application Maestro, CodeGuard, dsPICDEM, dsPICDEM.net, dsPICworks, dsSPEAK, ECAN, ECONOMONITOR, FanSense, HI-TIDE, In-Circuit Serial Programming, ICSP, Mindi, MiWi, MPASM, MPLAB Certified logo, MPLIB, MPLINK, mTouch, Omniscient Code Generation, PICC, PICC-18, PICDEM, PICDEM.net, PICkit, PICtail, REAL ICE, rfLAB, Select Mode, Total Endurance, TSHARC, UniWinDriver, WiperLock and ZENA are trademarks of Microchip Technology Incorporated in the U.S.A. and other countries. SQTP is a service mark of Microchip Technology Incorporated in the U.S.A. All other trademarks mentioned herein are property of their respective companies. 2011, Microchip Technology Incorporated, Printed in the U.S.A., All Rights Reserved. Printed on recycled paper.

ISBN: 978-1-60932-923-5
Microchip received ISO/TS-16949:2002 certification for its worldwide headquarters, design and wafer fabrication facilities in Chandler and Tempe, Arizona; Gresham, Oregon and design centers in California and India. The Companys quality system processes and procedures are for its PIC MCUs and dsPIC DSCs, KEELOQ code hopping devices, Serial EEPROMs, microperipherals, nonvolatile memory and analog products. In addition, Microchips quality system for the design and manufacture of development systems is ISO 9001:2000 certified.

2011 Microchip Technology Inc.

DS01373A-page 33

Worldwide Sales and Service


AMERICAS
Corporate Office 2355 West Chandler Blvd. Chandler, AZ 85224-6199 Tel: 480-792-7200 Fax: 480-792-7277 Technical Support: http://www.microchip.com/ support Web Address: www.microchip.com Atlanta Duluth, GA Tel: 678-957-9614 Fax: 678-957-1455 Boston Westborough, MA Tel: 774-760-0087 Fax: 774-760-0088 Chicago Itasca, IL Tel: 630-285-0071 Fax: 630-285-0075 Cleveland Independence, OH Tel: 216-447-0464 Fax: 216-447-0643 Dallas Addison, TX Tel: 972-818-7423 Fax: 972-818-2924 Detroit Farmington Hills, MI Tel: 248-538-2250 Fax: 248-538-2260 Indianapolis Noblesville, IN Tel: 317-773-8323 Fax: 317-773-5453 Los Angeles Mission Viejo, CA Tel: 949-462-9523 Fax: 949-462-9608 Santa Clara Santa Clara, CA Tel: 408-961-6444 Fax: 408-961-6445 Toronto Mississauga, Ontario, Canada Tel: 905-673-0699 Fax: 905-673-6509

ASIA/PACIFIC
Asia Pacific Office Suites 3707-14, 37th Floor Tower 6, The Gateway Harbour City, Kowloon Hong Kong Tel: 852-2401-1200 Fax: 852-2401-3431 Australia - Sydney Tel: 61-2-9868-6733 Fax: 61-2-9868-6755 China - Beijing Tel: 86-10-8528-2100 Fax: 86-10-8528-2104 China - Chengdu Tel: 86-28-8665-5511 Fax: 86-28-8665-7889 China - Chongqing Tel: 86-23-8980-9588 Fax: 86-23-8980-9500 China - Hong Kong SAR Tel: 852-2401-1200 Fax: 852-2401-3431 China - Nanjing Tel: 86-25-8473-2460 Fax: 86-25-8473-2470 China - Qingdao Tel: 86-532-8502-7355 Fax: 86-532-8502-7205 China - Shanghai Tel: 86-21-5407-5533 Fax: 86-21-5407-5066 China - Shenyang Tel: 86-24-2334-2829 Fax: 86-24-2334-2393 China - Shenzhen Tel: 86-755-8203-2660 Fax: 86-755-8203-1760 China - Wuhan Tel: 86-27-5980-5300 Fax: 86-27-5980-5118 China - Xian Tel: 86-29-8833-7252 Fax: 86-29-8833-7256 China - Xiamen Tel: 86-592-2388138 Fax: 86-592-2388130 China - Zhuhai Tel: 86-756-3210040 Fax: 86-756-3210049

ASIA/PACIFIC
India - Bangalore Tel: 91-80-3090-4444 Fax: 91-80-3090-4123 India - New Delhi Tel: 91-11-4160-8631 Fax: 91-11-4160-8632 India - Pune Tel: 91-20-2566-1512 Fax: 91-20-2566-1513 Japan - Yokohama Tel: 81-45-471- 6166 Fax: 81-45-471-6122 Korea - Daegu Tel: 82-53-744-4301 Fax: 82-53-744-4302 Korea - Seoul Tel: 82-2-554-7200 Fax: 82-2-558-5932 or 82-2-558-5934 Malaysia - Kuala Lumpur Tel: 60-3-6201-9857 Fax: 60-3-6201-9859 Malaysia - Penang Tel: 60-4-227-8870 Fax: 60-4-227-4068 Philippines - Manila Tel: 63-2-634-9065 Fax: 63-2-634-9069 Singapore Tel: 65-6334-8870 Fax: 65-6334-8850 Taiwan - Hsin Chu Tel: 886-3-6578-300 Fax: 886-3-6578-370 Taiwan - Kaohsiung Tel: 886-7-213-7830 Fax: 886-7-330-9305 Taiwan - Taipei Tel: 886-2-2500-6610 Fax: 886-2-2508-0102 Thailand - Bangkok Tel: 66-2-694-1351 Fax: 66-2-694-1350

EUROPE
Austria - Wels Tel: 43-7242-2244-39 Fax: 43-7242-2244-393 Denmark - Copenhagen Tel: 45-4450-2828 Fax: 45-4485-2829 France - Paris Tel: 33-1-69-53-63-20 Fax: 33-1-69-30-90-79 Germany - Munich Tel: 49-89-627-144-0 Fax: 49-89-627-144-44 Italy - Milan Tel: 39-0331-742611 Fax: 39-0331-466781 Netherlands - Drunen Tel: 31-416-690399 Fax: 31-416-690340 Spain - Madrid Tel: 34-91-708-08-90 Fax: 34-91-708-08-91 UK - Wokingham Tel: 44-118-921-5869 Fax: 44-118-921-5820

02/18/11

DS01373A-page 34

2011 Microchip Technology Inc.

You might also like