Quantcast
Channel: 懒得折腾
Viewing all articles
Browse latest Browse all 764

3G + GPS shield over Arduino and Raspberry Pi

$
0
0

3G + GPS shield over Arduino and Raspberry Pi

Difficulty Level: Expert –

https://s7.addthis.com/static/tweet.html#href=https%3A%2F%2Fwww.cooking-hacks.com%2Fdocumentation%2Ftutorials%2F3g-gps-shield-arduino-raspberry-pi-tutorial%2F%23.Vn8VQGqJUWs.twitter&dr=https%3A%2F%2Fwww.cooking-hacks.com%2F3g-gprs-shield-for-arduino-3g-gps-audio-video-kit&conf=product%3Dtbx-300%26pubid%3Dra-550b04b6022f544d%26data_track_addressbar%3Dfalse&share=url_transforms%3Dshorten%253Dtwitter%25253Dbitly%2523%2540!defrag%253D1%2523%2540!remove%253D0%25253Dsms_ss%252523%252540!1%25253Dat_xt%252523%252540!2%25253Dat_pco%252523%252540!3%25253Dfb_ref%252523%252540!4%25253Dfb_source%23%40!shorteners%3Dbitly%253D%23%40!imp_url%3D1%23%40!url%3Dhttps%253A%252F%252Fwww.cooking-hacks.com%252Fdocumentation%252Ftutorials%252F3g-gps-shield-arduino-raspberry-pi-tutorial%252F%23%40!title%3D3G%2520%252B%2520GPS%2520shield%2520over%2520Arduino%2520and%2520Raspberry%2520Pi%23%40!smd%3Drsi%253D%2523%2540!rxi%253Dundefined%2523%2540!gen%253D0%2523%2540!rsc%253D%2523%2540!dr%253Dhttps%25253A%25252F%25252Fwww.cooking-hacks.com%25252F3g-gprs-shield-for-arduino-3g-gps-audio-video-kit%2523%2540!sta%253DAT-ra-550b04b6022f544d%25252F-%25252F-%25252F567f15402bc13f85%25252F1%23%40!passthrough%3D&tw=url%3Dhttps%253A%252F%252Fwww.cooking-hacks.com%252Fdocumentation%252Ftutorials%252F3g-gps-shield-arduino-raspberry-pi-tutorial%252F%2523.Vn8VQGqJUWs.twitter%23%40!counturl%3Dhttps%253A%252F%252Fwww.cooking-hacks.com%252Fdocumentation%252Ftutorials%252F3g-gps-shield-arduino-raspberry-pi-tutorial%252F%23%40!count%3Dhorizontal%23%40!text%3D%23%40!related%3D%23%40!hashtags%3D%23%40!width%3D110

The 3G shield for Arduino and Raspberry Pi enables the connectivity to high speed WCDMA and HSPA cellular networks in order to make possible the creation of the next level of worldwide interactivity projects inside the new “Internet of Things” era.

The module counts also with an internal GPS what enables the location of the device outdoors and indoors combining standard NMEA frames with mobile cell ID triangulation using both assisted-mobile (A-GPS) and mobile-based (S-GPS) modes.

Other interesting accessories which can be connected to the module are a 2MP high resolution camera (1600 x 1200) UXGA which enables take incredible photos and videos, an audio kit including microphone , speaker , hands free and headphones sets and a SD socket to save directly all the data coming from the 3G network or recorded from the video camera. You can even reproduce audio filesstored in the SD card (like a mp3 player!).

You can also use it as a standard 3G modem at full speed (~7.2Mbps download, ~5.5Mbps upload) just connecting it through its specific mini-USB socket to your laptop (Linux, Windows, MacOS).

The new communicating module is specially oriented to work with Internet servers implementing internally several application layer protocols which make easier to send the information to the cloud. We can make HTTP and HTTPS (secure mode) navigation, downloading and uploading content to a web server. In the same way FTP and FTPS (secure mode) protocols are also available which is really useful when your application requires handling files. You can even send and receive mails directly from Arduino using the SMTP and POP3 clients implemented internally.

With the SD Card socket so you can handle a complete FAT16 file systems and store up to 32GB of information. This specially useful as the 3G module can work at full speed (~7.2Mbps download, ~5.5Mbps upload) when working with the SD files directly without need of Arduino for data or files management.

The GPS module also makes possible perform geolocation services even in indoors as it can work in A-GPS and S-GPS modes, so the location given by the GPS through NMEA sentences is completed with the cell information provided by both the 3G module and external Internet Geoposition Servers which helps you to get the most accurate location in each case.

Features

  • WCDMA and HSPA 3G networks compatibility
  • Internal GPS for Assisted A-GPS and Supported S-GPS modes
  • High Resolution Camera (2MP) for photo and video recordings available
  • Audio Kit including microphone, speaker, hands free and headphones available
  • SD file system up to 32GB
  • Works as a standard 3G modem in Linux/Windows/MacOS (~7.2Mbps download, ~5.5Mbps upload)
  • Talk directly to web servers by HTTP/HTTPS (secure)
  • Upload and download files directly by FTP/FTPS (secure)
  • Send and receive mails by POP3/SMTP
  • Play compressed audio files

NOTE: The Arduino codes of the tutorial have developed to work on Arduino IDE v1.0.1

NOTE: All the code examples in this tutorial developed for Raspberry Pi use the arduPi library. You can see the documentation and download the library here.

Kits and Accessories

Kits

Accesories

NOTE: the accessories (antennas, camera, microphone, speakers, headset, SD) are not included in the basic package. They may be acquired in any of the multi kits or by separate.

NOTE: If you only need to send SMS or use a low bandwidth for data transfer you can use our cheaper GPRS/GSM Quadband SIM900 module for Arduino and Raspberry Pi.

Does make sense a 3G module for a low speed microcontroller device such as Arduino?

Definitively yes.

On the one hand you can use the Arduino UART at full speed ~ 115kbps, so the communication of data will be at the same bandwidth as if you had the Arduino connected directly to the USB directly (obviously with more initial latency). With the GPRS modules available in the market until now the speed limit was established by the GPRS network ~ 20kbps, so now we get 6 times more download performance than before. The upload speed the increment three times from 10kbps (GPRS) to 35kbps (3G).

On the other hand there is a bunch of actions can be made directly from the 3G module without having to go through the Arduino microcontroller. This means you will control all the action from the main program running in Arduino although the data may flow from the 3G module to the SD card or from the video camera to the 3G module without going through the UART avoiding a possible bottle neck and ensuring maximum speed performance given by your 3G carrier (~7.2Mbps download, ~5.5Mbps upload at max). Some of this independent actions include:

  • Uploading and downloading files to HTTP and FTP servers directly from or to the SD
  • Recording and uploading video and photos to the Internet using the video camera connected directly to the module
  • Recording ambient audio and sending to a web server

This files may be also stored in the SD card of the 3G and in order to manage them after.

As well as this, the module offers theoretically also the possibility of performing Video-Calls. We say “theoretically” as the tests performed in Cooking Hacks we got a carrier error, the same we got when trying to make a Video-Call with our Smartphones so, although everything points it is is a carrier problem we can not ensure the Video-Call functionality (if you get please let us know!).

As pointed before the 3G module can also be used as and standalone 3G/GPRS USB modem! It works in Linux, Windows and MacOS, just plug it through its specific USB connector to your laptop and follow the steps located in the current manual.

You can control also the kind of network service and the quality of the signal received (RSSI) from the surrounding cells you are using even change among them: GSM – GPRS – WCDMA – HSPA depending on the coverage of the zone. Get detailed information about the frequency band you are using to connect to the carrier and the quality of the signal.

Article Index

1. FeaturesGo to index

Electrical features

The 3G module used is the SIM5218 from SIMCOM. The power supply of SIM5218 is from a single voltage source of VBAT= 3.4v-4.2v. In some case, the ripple in a transmit burst may cause voltage drops when current consumption rise to typical peaks of 2A. So the power supply must be able to provide sufficient current up to 2A. The maximum rating are VBAT=4,4v and 3A peak. The maximum value of voltage for digital or analogy pins is 2.8v.

Radio features

SIM5218 is a quad-band GSM/GPRS/EDGE and UMTS engine that works on frequencies of GSM 850MHz, EGSM 900 MHz, DCS 1800 MHz, PCS1900 MHz, and WCDMA 2100M/1900M/850M.

Output power:

  • UMTS 850/900/1900/2100: 0.25W
  • GSM850/GSM900: 2W
  • DCS1800/PCS1900: 1W

NOTE: when flight mode is activated RF functions are closed. The mode can be changed by putting the jumper in position (see 3G shield diagram below).

NOTE FOR US USERS: We have tested the new 3G shield with the AT&T network which supports nativelly the GSM and 3G protocolos. With other carriers may also work although we haven’t tried and thus we can not ensure it. For this reason we recommend to use AT&T SIM cards.

Extra features

  • USIM interface: support SIM cards: 3V & 1.8V
  • High speed USB interface for modem
  • Three audio channels include two microphones inputs and three audio outputs.
  • A camera interface is provided in FPC connector and 2mm pitch holes.
  • I2C interface is provided.
  • 8-bit ADC input with an input voltage range between 2.65v and GND
  • 2.8v LDO power output
  • 4 bit microSD card interface
  • 3 modes of GPS (stand alone, S-GPS y A-GPS)
  • FTP and FTPS for managing files
  • TCP and UDP sockets
  • POP3 and SMTP for e-mail

2. HardwareGo to index

3G Shield diagram

Version 2 of the shield:

NOTE: The Arduino/Raspberry Pi jumper MUST be in Arduino position. The Raspberry Pi position should be used only if the shield is connected to a Raspberry Pi. A wrong position of this jumper can damage the 3G shield

Version 1 of the shield:

3G Shield PCB

Version 2 of the shield:

Version 1 of the shield:

3. AntennasGo to index

Connections

SIM5218 has 3 UFL connectors. Two for diversity of 3G mobile carriers and one for GPS antenna. The impedance of the RF interface is 50Ω. It is recommended use just the “main” antenna socket for the mobile connection unless you experience coverage or performance problems. In this case two antennas allowing diversity may be placed.

Also, the module allows to solder the antenna to the pad, or attach it via contact springs.

Antenna availability

We recommend the usage of the following antennas:

4. BandwidthGo to index

3G module connected with Arduino allows downlinks rates over 115200 bauds (~11.5KBps), the maximum UART’s speed and uplinks rates over 30000 bauds (~3KBps). Using the module as 3G USB modem we got speeds of 2Mbps (~222KBps) for downlink and 0.7Mbps (~77KBps) for uplink and. The connection speed may vary depending on the state of the network, the quality of the signal and the carrier.

5. Using 3G module with AT commandsGo to index

Important issues:

  • Use capital letters for AT commands.
  • Send CR (Carriage return) and LF (Line feed) after the AT command.
  • Place the serial communication jumpers in the right position.
  • Use an external power supply and place the power jumpers in the right position. If the shield is powered from the Arduino or Raspberry Pi, the power jumper must be in Arduino 5V position. If the shield is powered from the Vin input (in the shield), the power jumper must be in Vext position.

Important type commands in capital letters and with CR (carriage return) and LF (line feed)!!!

Command Response Description
AT OK If you get OK, the communication with the module is working
AT+CPIN=”****” OK If the SIM card is locked with PIN (**** is the pin number)
AT+COPS? Operator information

NOTE: If your 3G module doesn’t answer to AT commands, maybe it is configured in a different baudrate. The command for change it temporally is AT+IPR. Try differents baudrates (300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400, 460800,921600, 3200000,3686400,4000000 ) until you get to communicate. Once you can communicate, you can configure it in the baudrate you want.

Using 3G module with AT commands in Arduino

The first thing we are going to do with the module is to connect the module to a PC directly (using an Arduino as gateway) and check the basic AT commands. In this case, serial communication jumpers have to be set on USB gateway position.

Remember take out the ATmega microcontroller from the Arduino gateway.

Basic configuration:

Connect the shield to the Arduino gateway.

Then connect the SIM card and the USB cable.

Finally plug the USB cable to the computer and open a serial port terminal to communicate via the usb port (e.g: hyperterminal (win), cutecom / gtkterm (linux)).

If you use the Arduino IDE serial monitor for sending AT commands – Be sure that you are sending CR (Carriage return) and LF (Line Feed).

Set the baudrate to 115200 bps and open the serial port, then press the ON button for two seconds. Then if you type AT you’ll get OK, this means that the communication with the module is working fine. Now, with the module working you can check some AT commands to control the module.

NOTE: With some sketches, the buffer of the UART may be small, to increase the length of the buffer you need to change these lines in the file HardwareSerial.h in /arduino-1.0.X/hardware/arduino/avr/cores/arduino/ (or in file HardwareSerial.cpp in /arduino-1.0.X/hardware/arduino/cores/arduino/ depending on the Arduino IDE version)

#if (RAMEND < 1000)
#define SERIAL_TX_BUFFER_SIZE 16
#define SERIAL_RX_BUFFER_SIZE 16
#else
#define SERIAL_TX_BUFFER_SIZE 64
#define SERIAL_RX_BUFFER_SIZE 64
#endif
#endif

to

#if (RAMEND < 1000)
#define SERIAL_TX_BUFFER_SIZE 400
#define SERIAL_RX_BUFFER_SIZE 400
#else
#define SERIAL_TX_BUFFER_SIZE 400
#define SERIAL_RX_BUFFER_SIZE 400
#endif
#endif

Using 3G module with AT commands in Raspberry Pi

The first thing we are going to do with the module is to check the basic AT commands in gateway mode. Using gateway mode, commands can be sent from our Raspberry Pi directly to any serial module. To stablish UART connection with the module you can use several programs as cutecom in Raspbian graphical environment or minicom in a terminal window in order to use it via SSH . For using minicom follow these steps:

    1. Place the Arduino/RPI jumper in the 3G shield to the right, in RPI position.
    2. Place the two Serial com. jumpers in the 3G shield to the left, in Arduino position. These jumpers always have to be in this position, in gateway mode and when you run codes.
    3. We recommend to power externally the shield, but it’s not necessary in all cases.

      If you decide not to use an external power supply you must set the “Vin ext. Jumper” to the left, in “Arduino 5V position” and do not forget to place the switch in the Raspberry connection bridge to the right.

      If you choose to use an external power supply of 5V or 12V you must place it through the Vin pin, (in the shield, it is placed where Arduino has the Vin pin), the “Vin ext. jumper” must be set to the right, in “Vin position”. The power supply must be able to provide sufficient current up to 2A. Besides this, do not forget to place the switch in the Raspberry connection bridge to the left.

      You can check our FAQ about 3G/Sim900/Sim908 here.

    4. Connect the shield to the Raspberry Pi connection bridge and the antennas to the shield. Now press the ON button in the shield, you will see a green LED.

  1. Open a Terminal window on Raspberry Pi, or connect to Raspberry Pi through SSH. In order to enter via SSH change here the IP from your Raspberry Pi. The default user is pi.
    ssh -X pi@192.168.1.X

    Now you will have to type your password. The default password is “raspberry”.

  2. Install minicom (only if you haven’t done it before):
    sudo apt-get install minicom
  3. Open comunication with the module UART, the baudrate is 115200:
    minicom -b 115200 -o -D /dev/ttyAMA0
  4. Then if you type AT you’ll get OK, this means that the communication with the module is working fine. Now, with the module working you can check some AT commands to control the module.
  5. To exit minicom press CTRL+A, then press X and Yes.

6. Using 3G module like a modemGo to index

If you want to use the 3G module such a modem, please refer to the next link:

3G modem tutorial

7. AudioGo to index

Audio features

SIM5218 module provides two analogy inputs for microphone and three analogy outputs for two speakers and headphones. Depending of the selected audio channel (normal, headset and hands-free) a specific input and output are activated. The different channels are selected with the command AT+CSDVC.

Normal channel (AT+CSDVC=1) uses the main microphone and a speaker. Headset channel (AT+CSDVC=2) uses the jack connector. Hand-free channel (AT+CSDVC=3) uses the main microphone and the loudspeaker.

Both microphones don’t need an external power source because they are powered directly by the module. You can use some extra commands in your codes like noise suppression, echo canceller or the gain of the mic amps. Please, refer to the AT command document list at the end of this article for more information.

Audio connectors

Audio connectors are situated at the bottom of the board. The two speakers and the main microphone are connected to board using pin connectors.

3G/GPRS shield for Arduino (3G + GPS) + Audio/Video Kit

Headset connector are situated at the bottom too, between Arduino board and 3G board.

This connector has 4 terminals that correspond with the positive terminal of the microphone, left and rigth headphones and common ground. The order of connections show below.

Originating and receiving voice calls

The code example and the connection diagram shown below are used to originate a voice call and, pushing a button, end that voice call. The button is connected between digital pin 12 an ground. A 10kΩ pull-up resistor is needed at this pin.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

To make a lost call next code is used.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

To receive calls the used code are this and the connection diagram is the same that the used to originate calls. Don’t forget the pull-up resistor on pin 12.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

The channel may be changed during a call. Use the command AT+CSDVC to select the channel that you want.

Recording and playing sound

With the next code we can record a sound, stores it and before play it. You can select the place to store the sound clip: the local storage or a SD card. Once saved the sound can be sent to an FTP or FTPS as you’ll see later.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Also, you can use the 3G module like a mp3 player! First, you must save your music in mp3, amr or qcp format. You can use Audacity (linux) or Mobile Media Converter (Windows or Linux) to do this. Then, save the music in the Audio folder on microSD card. Now, put microSD card into the shield and enjoy the music!

NOTE: You will need to update your firmware to play mp3. The update is available here. Uncompress and run it in a PC with Windows (emulated Windows not supported).

A voice call can be recorded using these same commands too.

Command summary

Command Response Description
AT+CPTONE=** OK Plays a DTMF tone or complex tone on local voice channel device . ** is the number of the tone.
ATD*********; ********* is the number to call.
ATA OK Answer an incoming call.
AT+CHUP OK Cancel voice calls.
AT+CNSM OK Enable/disable noise suppression.
AT+CQCPREC=*,&&& Starts recording sound clips . Answers with the path and the name of the clip. * is the path and &&& is the format.
AT+CQCPPAUSE OK Pauses record sound.
AT+CQCPRESUME OK Resumes record sound.
AT+CQCPSTOP OK Stops record sound.
AT+CCMXPLAY=”*****” OK Plays an audio file . ***** is the name of the file.
AT+CCMXPAUSE OK Pauses playing audio file.
AT+CCMXRESUME OK Resumes playing audio file.
AT+CCMXSTOP OK Stops playing audio file.

8. CameraGo to index

We have modified the 3G Shield to make it work with a better camera. So instead of using the old 0’3MP Camera, now the shield supports a 2MP Camera, improving the resolution from 640 x 480 (VGA) to 1600 x 1200 (UXGA)!

Comparative:

Old Camera New Camera
Resolution 0.3 MP 2 MP
Sensor OV7725 OV2640
Max. resolution 640 x 480 (VGA) 1600 x 1200 (UXGA)
Image area 3984 µm x 2952 µm 3590 µm x 2684 µm
Sensitivity 3800 mV/Lux-sec 0.6 V/Lux-sec
Optical format 1/4″ 1/4″
Power 120 mW 140 mW

Click in the next photos to enlarge (left click):

Old photo

New photo

The new 2MP Camera is included in the Audio / Video 3G Kit. You can also get directly the 2MP Camera here.

NOTE: The new 2MP Camera can be used only in the last version of the 3G Shield. The old 0’3MP camera can not be used in the new version of the 3G Shield.

NOTE: The 2MP resolution of 1600 x 1200 is just for photos. Video recording is performed at 320 x 240 due to module restrictions.

How do I know if my 3G Shield is compatible with the new 2MP Camera?

  • Check your serial ID. The sticker included in the shield tells you the number of batch. The new 2MP Camera is compatible with batches xxxx-0010-xxx and above.

  • Date of Order. For orders starting in June 2014 all the 3G Shields sold are compatible with the new 2MP Camera.

Camera features

This module allows to connect a camera for video recording and taking photos. Once saved the video or image file can be sent to an FTP or FTPS as you’ll see later. The pin diagram shows below:

Pin nº Name Pin nº Name Pin nº Name
1 NC 9 HSYNC 17 PCLK
2 AGND 10 DVDD 18 DATA6
3 SDA 11 DOVDD 19 DATA2
4 AVDD 12 DATA9 20 DATA5
5 SCL 13 MCLK 21 DATA3
6 RESET 14 DATA8 22 DATA4
7 VSYNC 15 AGND 23 DATA1
8 PWDN 16 DATA7 24 DATA0

Mounting the camera

Follow these simple steps to mount the camera into the 3G Arduino board.

The first step is to open the socket. To do this, pull carefully out the sides of the connector.

Inserts the camera with metallic contacts facing up

At the final step, push in the laterals of the connector.

The camera may get hot if continuous usage is performed. Maximum operation temperature is 45ºC.

Video recording

To record video, and take images, you must start the camera in the first step. After you can configure some parameters like resolution, fps, rotation or zoom. The next code allows to record a video file in mp4 format. Remember, if you want to store the video file in a SD card, you must to use AT+FSLOCA command.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Taking photos

Take photos is very easy, here is the example code:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Video call

The SIM5218 allows video calls, but to carry them out correctly the operator and the network must be able to allow it. The example code is below. Cooking Hacks not ensure that the video call functions correctly.

Please, be sure that your SIM card have activated the videocall feature, with your network operator and with the phone that you want to call, before to test the next sketch.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

Command Response Description
AT+CCAMS OK Starts camera.
AT+CCAME OK Stops camera.
AT+CCAMSETD=xxx,yyy OK Sets dimension of camera. xxx is the width and yyy is the height.
AT+CCAMSETF=* OK Sets the frames per second. * is the frame rate option.
AT+CCAMRS OK Starts video recording . Also responds with the path and name of the file.
AT+CCAMRP OK Pauses the record.
AT+CCAMRR OK Resumes video record.
AT+CCAMRE OK Stops video record.
AT+CCAMTP OK Takes a picture.
AT+CCAMEP OK Saves a picture taken by last AT+CCAMTP. Also responds with the path and name of the file.
AT+VPMAKE Makes a video call.
AT+VPEND Ends a video call.

9. GPSGo to index

SIM5218 supports both A-GPS and S-GPS and provides three operating modes: mobile-assisted mode, mobile-based mode and standalone mode. A-GPS is include mobile-assisted and mobile-based mode.

In mobile-assisted mode, when a request for position location is issued, available network information is provided to the location server (e.g., Cell-ID) and assistance is requested from the location server. The location server sends the assistance information to the handset. The handset/mobile unit measures the GPS observables and provides the GPS measurements along with available network data (that is appropriate for the given air interface technology) to the location server. The location server then calculates the position location and returns results to the requesting entity.

In mobile-based mode, the assistance data provided by the location server encompasses not only the information required to assist the handset in measuring the satellite signals, but also the information required to calculate the handset’s position. Therefore, rather than provide the GPS measurements and available network data back to the location server, the mobile calculates the location on the handset and passes the result to the requesting entity.

In standalone (autonomous) mode, the handset demodulates the data directly from the GPS satellites. This mode has some reduced cold-start sensitivity, and a longer time to first fix as compared to the assisted modes. However, it requires no server interaction and works out of network coverage.

This combination of GPS measurements and available network information provides:

  • High-sensitivity solution that works in all terrains: indoor, outdoor, urban, and rural
  • High availability that is enabled by using both satellite and network information

Therefore, while network solutions typically perform poorly in rural areas and areas of poor cell geometry/density, and while unassisted, GPS-only solutions typically perform poorly indoors, the SIM5218 GPS solution provides optimal time to fix, accuracy, sensitivity, availability, and reduced network utilization in both of these environments, depending on the given condition.

Stand-alone mode

In this mode, the GPS obtains position, altitude,… with only the signal of the satellites, making it the slowest of the three modes. If you use the AT+CGPSINFO command, the module bring directly latitud, logitude, date, UTC time, altitude and speed. Here is the example code:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

If you want to get the NMEA sentences, you must to use the command AT+CGPSSWITCH=1 and configure the UART port at 57600 bauds. Supported NMEA sentences include GSV, GGA, RMC, GSA, and VTG.

S-GPS mode

For the S-GPS the module connects to a GPS server and the module calculates the position. Here is the example code:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

A-GPS mode

For the A-GPS the module connects to a GPS server for calculate the position. Here is the example code:

MS-assisted Server Module
Location server sends aiding data that is valid for the current fix Sending data
Module sends code phases Code phases
Server calculates position Calculate position
MS-based Server Module
Location server sends aiding data that is valid for the current fix Send aiding data
Module calculates Calculate position
Stand alone Server Module
Module demodulates data form GPS satellite Demodulates GPS satellite data
Module calculates position Calculate position

GPS units

The command AT+CGPSINFO returns the GPS info in a string:

+CGPSINFO: [<latitude>],[<N/S>],[<longitude>],[<E/W>],[<date>],[<UTC_time>],[<altitude>],[<speedOG>],[<course>]

Values Format Example
latitude ddmm.mmmmmm

d: degree; m: minute

4140.831527
longitude dddmm.mmmmmm

d: degree; m: minute

00053.173495
date ddmmyy

d: day; m: month; y: year

020812
UTC_time hhmmss.s

h: hour; m: minute; s: seconds

083418.0
altitude meters 257.00
speedOG knots 2
course degrees 0

If UE-assisted mode, when fixed will report indication:

+CAGPSINFO:<latitude>,<longitude>,<altitude>,<date>,<UTC_time>

Values Format Example
latitude Unit is in 10^8 degree 4168050885
longitude Unit is in 10^8 degree 88618039
altitude meters 293
date ddmmyyyy
d: day; m: month; y: year
28092012
UTC_time hhmmss.s
h: hour; m: minute; s: seconds
081611.0

Command summary

Command Response Description
AT+CGSOCKCONT=**,&&& OK ** is the protocol and &&& Access Point Name.
AT+CGPS=*,& OK * sets on (1) or off (0) and & is the GPS mode.
AT+CGPSINFO Gets current position information.
AT+CGPSURL=”***” OK Sets AGPS default server URL . *** is the URL.
AT+CGPSSSL=* OK Select transport security, used certificate (*=1) or not (*=0).
AT+CGPSSWITCH OK Choose the output port for NMEA sentence.

10. SMSGo to index

Sending and receiving SMS

The first code is used to send a SMS, the second one reads the SIM message memory and shows the last SMS.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

Command Response Description
AT+CMGF= OK Specifies the input and output format of the short messages. 0 for PDU mode and 1 for text mode.
AT+CMGS Sends a message.
AT+CPMS=*** Selects memory storages. *** is the memory type.
AT+CMGR=* Reads a message. * is the number of the message.

11. E-mailsGo to index

Sending an e-mail

To send e-mail a SMTP server is used, so we need an e-mail account. The code example is the next:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Receiving an e-mail

For read an e-mail from a POP3 server we need an e-mail account. The code example is here:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

Command Response Description
AT+CGSOCKCONT=**,&&& OK ** is the protocol and &&& Access Point Name.
AT+SMTPSRV=”*****”,&&& OK Sets SMTP server address and server’s port . ***** is the sever address and &&& is the server’s port.
AT+SMTPAUTH=1,”***”,”&&&” OK Controls SMTP authentication. *** is the user name and &&& is the password.
AT+SMTPFROM=”***”,”&&&” OK Sets sender’s address and nam e. *** is the sender’s address and &&& is the sender’s name.
AT+SMTPRCPT=x,”***”,”&&&” OK Sets recipient address/name and kind . x is the kind (TO/CC/BCC), *** is the recipient address and &&& is the recipient name.
AT+SMTPSUB=”****” OK Sets the subject of e-mail . **** is the subject.
AT+SMTPBODY Sets e-mail body.
AT+SMTPSEND Initiates TCP session with SMTP server and sends an e-mail
AT+POP3SRV=”**”,”&&”,”xx”,yy OK Sets all parameters to get an e-mail from POP3 . ** is the server address, && is the user name, xx is the password and yy the server port
AT+POP3IN OK Logs in POP3 server
AT+POP3GET=*** Gets an e-mail from POP3 server , *** is the number of the e-mail.
AT+POP3OUT OK Logs out POP3 server
AT+POP3READ=”***”,”&&&” Reads an e-mail from file system . *** is the location and &&& is the name.

12. SD and system memoryGo to index

The file system is used to store files in a hierarchical (tree) structure. Local storage space is mapped to “C:”, and SD is mapped to “D:”. In both “C:” and “D:” directories, module creates four directories named “Picture”, “Audio”, “Video” and “VideoCall” automatically; “Picture” is used to store static image when taking picture by camera, “Audio” is used to store audio file, “Video” is used to store video file when recor ding by camera, and “VideoCall” is used to store media file which is recorded during a video call.

The maximum size of the microSD card is 32GB. Here are some AT commands to manage the file system:

AT command Response Description
AT+FSCD=**** OK Select a directory as current directory . **** is the directory.
AT+FSMKDIR=**** OK Create a new directory in current directory . **** is the name of the new directory.
AT+FSRMDIR=**** OK Delete existing directory in current directory . **** is the name of the directory to delete.
AT+FSLS Make a list with informations of directories and/or files in current directory.
AT+DEL=**** OK Delete a file in current directory. **** is the name of the file to delete.
AT+FSRENAME=****,&&& OK Rename a file in current directory. **** is the actual name and &&& is the new name.
AT+FSATTRI=**** Request the attributes of file which is existing in current directory. **** is the name of the file.
AT+FSMEM Check the size of available memory.
AT+FSFMT OK Format storage card which is plugged in.
AT+FSLOCA= OK Set the storage place , 0 for local and 1 for SD

13. FTP and FTPSGo to index

FTP

Creating a file into the FTP server, writing it and reading it.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Uploading a file from local storage or SD to FTP server.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Downloading a file from FTP server or SD to local storage.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

FTPS

Creating a file into the FTP server, writing it and reading it (likes FTP codes)

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Uploading a file from local storage or SD to FTP server

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Downloading a file from FTPS server or SD to local storage

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

AT command Response Description
AT+CGSOCKCONT=**,&&& OK ** is the protocol and &&& Access Point Name.
AT+CFTPSERV=”****” Sets FTP server domain name or IP address. **** is the domain name or the IP.
AT+CFTPPORT=*** OK Sets FTP server port. *** is the port.
AT+CFTPUN=”***” OK Sets user name for FTP server access. *** is the user name.
AT+CFTPPW=”***” OK Sets password for FTP server access. *** is the password.
AT+CFTPMODE= OK Sets FTP mode. 1 for passive or 0 for proactive.
AT+CFTPTYPE= OK Sets the transfer type on FTP server . A for ASCII or I for binary.
AT+CFTPPUT=”***”,&& Puts a file from FTP server to serial port . *** is the path with the name of the file and && is the length.
AT+CFTPGET=”***” Gets a file from FTP server to serial port . *** is the path with the name of the file.
AT+CFTPPUTFILE=”***”,& Uploads a file to FTP server from module . *** is the path and & is the storage directory.
AT+CFTPGETFILE”=***”,& Downloads a file from FTP server to module . *** is the path with the name and & is the storage directory.
AT+CFTPSSTART OK Acquires FTPS protocol stack.
AT+CFTPSLOGIN=”**”,&&&,”xxx”,”yyy” OK Logs in FTPS server. *** is the host address, &&& is the port, xxx is the user name and yyy is the password.
AT+CFTPSTYPE= OK Sets the transfer type on FTPS server . A for ASCII or I for binary.
AT+CFTPSPUT=”***”,&& Puts a file from FTPS server to serial port . *** is the path with the name of the file and && is the length.
AT+CFTPSGET=”***” Gets a file from FTPS server to serial port . *** is the path with the name of the file.
AT+CFTPSPUTFILE=”***”,& Uploads a file to FTPS server from module . *** is the path and & is the storage directory.
AT+CFTPSGETFILE=”***”,& Downloads a file from FTPS server to module . *** is the path with the name and & is the storage directory.

14. TCP and UDPGo to index

UDP client

Sending data to a UDP server:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

TCP client

Sending data to a TCP server:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Multiclient

SIM5218 allows to use ten connections simultaneously. Here is the example code with a UDP and TCP connections.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

TCP server

SIM5218 allows to create a TCP server with a maximum of ten TCP clients. In this example the server send a message every 5 seconds to all clients.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

AT command Response Description
AT+NETOPEN=”***”,&& Opens a socket . *** is the socket type and && is the port.
AT+NETCLOSE OK Closes socket.
AT+UPDSEND Sends UDP data.
AT+TCPCONNECT=”***”,&& Establishes TCP connection with TCP server. *** is the IP address and && is the port.
AT+TCPWRITE Sends TCP data when the TCP connection is established.
AT+SERVERSTART OK Starts up TCP server.
AT+LISTCLIENT Lists all of clients’ information.
AT+ACTCLIENT=* OK Activates the specified client. * is the number of the client.
AT+CLOSECLIENT=* OK Disconnects the specified client. * is the number of the client.
AT+CIPOPEN=*,”&&”,”xx”,yy Establish a connection with TCP server or UDP server. * is the number of the connection, && is the type of transmision protocol, xx is the server IP and yy is the server port.
AT+CIPSEND Sends some data to remote host in mult-client mode.
AT+CIPCLOSE=* OK Closes a specified connection in multi-client mode. * is the number of the connection.

15. HTTP AND HTTPSGo to index

HTTP

SIM5218 can launch a HTTP operation like GET or POST. Here is an example with GET operation. As you can read in the header of the code, you will need to increase the buffer size to 400 bytes.

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

HTTPS

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:

Command summary

AT command Response Description
AT+CHTTPACT=”***”,&& Launches a HTTP operation . *** is the server address and && is the port.
AT+CHTTPSSTART OK Acquires HTTPS protocol stack.
AT+CHTTPSSTOP OK Releases HTTPS protocol stack.
AT+CHTTPSOPSE OK Opens a new HTTPS session.
AT+CHTTPSCLSE OK Closes the opened HTTPS session.
AT+CHTTPSSEND=* Sends HTTPS request. * is the length of the data in the sending buffer.
AT+CHTTPSRECV=* Receives HTTPS response after sending HTTPS request.

16. Fritzing LibrariesGo to index

The new 3G shield for Arduino enables the connectivity to high speed WCDMA and HSPA cellular networks in order to make possible the creation of the next level of worldwide interactivity projects inside the new “Internet of Things” era.

You can download our Fritzing libraries from this area.

17. Video-TutorialGo to index

Here’s an explanatory video, which shows the whole process developed in this tutorial:

Check the GPS+PIC Code here:

Arduino:

Show code
Code:

Raspberry Pi:

Show code
Code:


Viewing all articles
Browse latest Browse all 764

Trending Articles