This is a draft of a new GPRS application/example. Corrections may be added.
NetBurner GPRS Application Note
What is GPRS
General Packet Radio Service (GPRS) is a form of wireless communication utilizing a cellular data connection. This data connection can be used to transmit and receive packets of data. While connected via GPRS, you can expect to get a data rate of 60-80 kbps. A GPRS connection is generally available anywhere that you can get cellular service.
Application Note Description
This application will demonstrate how to establish a mobile connection via GPRS and email data collected back to an email address.
The application begins by opening a GPRS connection to get a network address through the mobile data link. The application uses a small temperature sensor which reports the current temperature measured from the device every minute. Data is exchanged between the NetBurner module and the temperature sensor via an SPI connection. Over the course of one hour, the temperature readout is saved in a buffer. After one hour has past, the NetBurner module and emails the logged data to a specified email address. Once the email has been sent the module resumes collecting temperature data.
Parts List
Part Name
Part Code
Supplier
Price
NetBurner MOD5270LC Development Kit
NNDK-MOD5270LC-Kit
http://www.netburnerstore.com
$99
LM70 Temperature Sensor
LM70CIMM-3CT-ND
http://www.digikey.com
$1.98
GM862 Cellular Quad Band Module
CEL-00757
http://www.sparkfun.com
$99.95
GM862 Evaluation Board - Basic 50-Pin (Optional)
CEL-00277
http://www.sparkfun.com
$29.95
GM862 Evaluation Board - RS232 (Optional)
CEL-00477
http://www.sparkfun.com
$74.95
Connections
If you hook up the following lines to their specified ports, you should be able to duplication this example.
LM70 --> MOD5270
The LM70 temperature sensor should be connected to the MOD5270 QSPI lines.
SI/O --> SPI_DIN
SC --> SPI_CLK
~CS --> SPI_CS0
V+ --> VCC
GND --> GND
TELIT GM862 --> MOD5270
The GM862 will have a different connection set up depending on if you are using the 50-pin evaluation board, or are using the RS232 evaluation board.
The RS232 evaluation board is easier to set up, as it has an onboard power supply that will give you the 3.8V required input. Data is connected to the NetBurner MOD5270 through an RS232 serial cable.
The 50-pin evaluation board must be powered by 3.8V. The MOD5270LC kit does not supply this voltage, so you will need to provide 3.8V to the device. For a power indicator, you should supply an LED. The RS232 evaluation board includes an LED.
Connections that are only required for the 50-pin evaluation board will be marked (50pin) in the connection list. Connections required by the RS232 will be marked (RS232).
3.8V --> VCC (50pin) (You must supply 3.8V)
ON/OFF --> IRQ1
PWR_CTL --> LED (50pin)
RX --> UART1_TX (50pin)
TX --> UART1_RX (50pin)
GND --> GND (50pin)
DB9 --> UART1 (RS232)
Code Description
SPI Temperature Collection
The code to collect data from the thermometer is very simple. QSPI is initialized at boot time, and then is queried for the 2 bytes of temperature data every minute. A semaphore is used to tell the code to wait until the QSPI transfer is complete before continuing on in the code.
Code: Select all
OS_SEM QSPI_SEM;
OSSemInit(&QSPI_SEM, 0);
QSPIInit(1000000, 11, 0xE, 1, 0, 1, TRUE,0x30, 0x30);
Code: Select all
short RawTempData = 0;
QSPIStart(NULL, (BYTE*) &RawTempData, 2, &QSPI_SEM); // Receive data
OSSemPend(&QSPI_SEM, 0); // Wait for QSPI to complete
GPRS Connection
The GPRS connection is treated as a PPP connection, and uses the NetBurner PPP instructions to manage the connection. The GPRS is run from a task that monitors the GPRS link. If a link is lost, then program will attempt to reestablish that connection. All dialing, PPP commands, IP stack is handled by the NetBurner source that works without modification.
Code: Select all
iprintf("\r\nDialing...\r\n");
int rv = DialPPP(SERIALPORT_TO_USE, &pppo, DIAL_STRING);
if (rv != ERR_PPP_SUCCESS)
ShowErrors("Dial Failed", rv);
else {
iprintf("Connection Established\r\n");
EthernetIpGate = 0;
}
if (GetPPPState() != eOpen)
OSTimeDly(TICKS_PER_SECOND * 5);
while (GetPPPState() == eOpen && allDone == false) {
GPRSLink = TRUE;
OSTimeDly(3 * TICKS_PER_SECOND);
iprintf("Active Connection, Secs:%d\r\n",Secs);
}
ClosePPPSesion();
StopPPPDameon();
GPRSLink = FALSE;
iprintf("Disconnected from GPRS server.... \r\n");
connectionCounter++;
If the connection fails, the program will continue to try to redial until it successfully connects to the mobile network. If the connection is successful, the task sits and monitors the connection. At the first sign of failure, it will close the connection and redial to reestablish the link.
Sending the Collected Data via Email
Mail is sent from the NetBurner device every hour containing a log of the temperatures collected so far. No mail server login credentials are required, as we are acting as the mail server in this example. Please note, some mail clients may treat the email as spam, so you should white list the email reply address you are sending from.
Code: Select all
while (mailSent != 1) {
mailSent = SendMailAsServer("email_address_from",
"email_address_to",
"subject", data);
OSTimeDly(TICKS_PER_SECOND * 5);
}
Adding Functionality
This example is intended to provide a rudimentary connection example. To complete the project and turn it into a product to sell, added functionality in the Telit GPRS module should be taken advantage of. The ability to turn on and off the Telit through code should be added to the source. I would also recommend a way to disconnect from the GPRS mobile link when sampling data, as the mobile connection is not in use and is draining power.