Development Guide For 3G Shield And Module Using Arduino TH 20160321
User Manual:
Open the PDF directly: View PDF .
Page Count: 45
3G Shield / 3G Module
Platform Arduino
2
21//2559
3
3G Shield / 3G Module Arduino UNO R3 ...................................................................... 4
3G Shield ................................................................................................................................................ 4
Jumper ...................................................................................................................................... 4
3G Module ............................................................................................................................................. 5
3G Shield / 3G Module Mic Speaker ...................................................................... 6
3G Shield / 3G Module Arduino ...................................................... 7
AT command Arduino USB-to-Serial ........................................................................ 8
AT Command 3G Shield / 3G Module Library TEE_UC20_Shield
..................................................................................................................................................................... 11
UART Library TEE_UC20_Shield ...................................................................... 12
TEE_UC20_Shield AltSoftSerial.............................................................. 12
TEE_UC20_Shield SoftwareSerial .......................................................... 13
TEE_UC20_Shield HardwareSerial ....................................................... 13
TEE_UC20_Shield ........................................................................................................ 16
TEE_UC20_Shield ........................................................................ 19
TEE_UC20_Shield-SMS ............................................................... 21
TEE_UC20_Shield ........................................................................... 24
TEE_UC20_ShieldInternet ................................................................ 29
TEE_UC20_ShieldMMS .............................................................................. 32
TEE_UC20_ShieldTCP ......................................................................... 35
TEE_UC20_ShieldHTTPGET/HTTP POST ...................................................... 37
TEE_UC20_ShieldFTP ................................................................................ 39
TEE_UC20_ShieldGNSS ............................................................................ 43
4
3G Shield / 3G Module Arduino UNO R3
3G Shield
Jumper
5
3G Module
6
3G Shield / 3G Module Mic Speaker
7
3G Shield / 3G Module Arduino
- AltSoftSerial
http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
https://github.com/PaulStoffregen/AltSoftSerial
- AltSoftSerial-master.zip AltSoftSerial-master AltSoftSerial
- AltSoftSerial libraries Arduino IDE
- TEE_UC20_Shield http://www.thaieasyelec.com/
- TEE_UC20_Shield.7z
- TEE_UC20_Shield libraries Arduino
IDE
8
AT command Arduino USB-to-Serial
3G Shield/ 3G Module AT
Command Serial UART USB
USB USB Modem
USB AT
Serial UART
AT Command USB
Serial UART Baud Rate Baud
Rate USB Baud Rate USB
Serial UART Baud Rate Serial UART
USB-to-Serial Arduino USB-to-Serial
AT Command 3G Shield/ 3G Module Serial UART
- 3G Shield/3G Module Arduino
- Arduino
#include <AltSoftSerial.h>
AltSoftSerial mySerial;
void setup() {
Serial.begin(9600);
mySerial.begin(115200);
}
void loop() {
if (mySerial.available()) {
Serial.write(mySerial.read());
}
if (Serial.available()) {
mySerial.write(Serial.read());
}
}
- Code
Serial Hardware Serial Arduino
ATmega16U2 USB-to-Serial Arduino -
mySerial Software Serial Arduino Serial
Software
Serial UART Software Serial 3G Shield/3G Module
9
Software SerialBaud Rate
Hardware
Serial Hardware Software Serial
Arduino Serial Arduino Uno Hardware Serial
loop() Software Serial
mySerial.available() mySerial.read() Hardware Serial
Serial.write()
Hardware Serial Serial.available()
Serial.read() Software Serial mySerial.write()
Usb-to-Serial Arduino Serial UART 3G Shield /
3G Module
!!!mySerial.begin(115200) Baud rate 3G Shield / G
Module Default Baud Rate 115200 9600
- Arduino
- Serial Monitor
10
- Baud rate NL/CR
- AT
- OK
11
AT Command 3G Shield / 3G Module
Library TEE_UC20_Shield
!!! 3G Shield
- Echo
ATE0
- URCUART1URC
RING
USSD
AT+QURCCFG="urcport","uart1"
- Baud Rate 9600
AT+IPR=9600
AT+IFC=0,0
-
AT&W
12
UART Library TEE_UC20_Shield
TEE_UC20_Shield AltSoftSerial
AltSoftSerial GPIO Software Serial
Baud RateSoftwareSerial Arduino IDE
AltSoftSerial
http://www.pjrc.com/teensy/td_libs_AltSoftSerial.html
3G Shield Software Serial SW
TxRx89 Arduino Uno AltSoftSerial
!!! Software Serial Baud Rate 9600 – 57600 bps
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
AltSoftSerial mySerial;
void setup(){
Serial.begin(9600);
gsm.begin(&mySerial,9600);
}
void loop(){
}
13
TEE_UC20_Shield SoftwareSerial
SoftwareSerial Arduino IDE
Arduino Serial Port GPIO
Baud Rate19200bps
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
SoftwareSerial mySerial(8,9);
void setup(){
Serial.begin(9600);
gsm.begin(&mySerial,9600);
}
void loop(){
}
TEE_UC20_Shield HardwareSerial
Hardware Serial Serial Hardware Arduino
Arduino Uno Hardware Serial
Hardware
0 (Rx) 1 (Tx) Uno Arduino
-
Arduino Uno Software Serial
Hardware Serial Arduino Hardware Serial 1Arduino
Mega 2560 Arduino Due Arduino Leonardo (Hardware Serial USB CDC)
14
- Hardware Serial Arduino Uno Leonardo
- Hardware Serial Arduino Mega 2560
15
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
void setup(){
gsm.begin(&Serial,9600);
}
void loop(){
}
Note!!!
gsm.begin(&Serial,9600); //Serial Pin 0, 1 Uno
gsm.begin(&Serial1,9600); //Serial1 Pin 19, 18 Mega 2560
gsm.begin(&Serial2,9600); //Serial2 Pin 17, 16 Mega 2560
gsm.begin(&Serial3,9600); //Serial3 Pin 15, 14 Mega 2560
16
TEE_UC20_Shield
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
begin()
void begin(SerialPort, baudrate) Serial
AltSoftSerialSoftwareSerialHardwareSerial setup()
Serial
AltSoftSerial mySerial; AltSoftSerial
SoftwareSerial mySerial(8,9); Software Serial
Baud Rate 3G Shield/ 3G Module (
UART TEE_UC20_Shield)
Event_debug
Event_debug
void functionname(String data)
functionname Event_debug data
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
AltSoftSerial mySerial;
void debug(String data){
Serial.println(data);
}
void setup(){
Serial.begin(9600);
gsm.begin(&mySerial,9600);
gsm.Event_debug = debug;
}
void loop(){
}
17
SetPowerKeyPin()
void SetPowerKeyPin(int pin) Pin - 3G Shield/ 3G
Module pin
Digital 4 Arduino
PowerOn()
void PowerOn() 3G Shield/ 3G Module
Arduino Power Key 3G Module 4
SetPowerKeyPin() 3G Shield/ 3G Module
3G Shield/ 3G Module
PowerOff
void PowerOff() 3G Shield/ 3G ModuleArduino
Power Key 3G Shield/ 3G Module
SetPowerKeyPin()
WaitReady
bool WaitReady()3G Shield/ 3G Module
Initial
SIM Card Boolean false
GetOperator
String GetOperator() 3G Shield/ 3G Module
String
18
SignalQuality
unsigned char SignalQuality() 3G Module
Return
Signal Quality
0
- dBm or less
1
- dBm
-- dBm
- dBm or greater
Not known or not detectable
19
TEE_UC20_Shield
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "call.h"
CALL
CALL call;
Call()
unsigned char Call(String call_number) String
call_number
Return
Description
0
Timeout
1
Ok
2
No Carrier
3
Busy
HangUp
bool HangUp() true
DisconnectExisting
bool DisconnectExisting() Call
true
Answer()
bool Answer() true
CurrentCallsMe
String CurrentCallsMe()
String
20
WaitRing
bool WaitRing() RING
true RING
3G Shield/ 3G Module
File> Examples > TEE_UC20_Shield > Call
21
TEE_UC20_Shield-SMS
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "sms.h"
SMS
SMS sms;
DefaultSetting()
void DefaultSetting() SMS
AT+CMGF, AT+CSMP, AT+CSCS
Start()
void Start(String rx_number) SMS
SMS String SMS
Send() Sendln()
void Send(String data)void Sendln(String data)
String data
Send
Sendln
Stop
void Stop()
3G Shield/ 3G ModuleSMS
File> Examples > TEE_UC20_Shield > Send_SMS_Thai_English
22
IndexNewSMS()
unsigned char IndexNewSMS() SMS
Index
ReadSMS()
String ReadSMS(int index) SMS int
index SMS Index String
SMS Index
SMSInfo
String SMSInfo SMS
ConvertStrUnicodeToTIS
String ConvertStrUnicodeToTISString data) Unicode
TIS620 Serial Monitor
String
23
ConvertStrUnicodeToUTF()
String ConvertStrUnicodeToUTFString data) Unicode
UTF-8 String
DeleteSMS()
bool DeleteSMS(int index) SMS Index
int index true
3G Shield/ 3G ModuleSMS
File > Examples > TEE_UC20_Shield > Read_SMS_Thai_English
24
TEE_UC20_Shield
3G Shield/ 3G Module
MMSInternet
3G Shield 3G Module 2
UFS (User File Storage directory) Flash Memory
UFS
3G Shield UC20 60 MB
3G Module UC15 70 MB
RAM (Random Access Memory) UFS
3G Shield UC20 2.5 MB
3G Module UC15 3 MB
!!!
RAM UFS
UFS
RAM
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "File.h"
UC_FILE
UC_FILE file;
begin
void begin()
25
GetSpace
long GetSpace(String pattern)
String pattern
UFS = file.GetSpace(“UFS”);
RAM = file.GetSpace(“RAM”);
long
GetFreeSpace
long GetFreeSpace(String pattern)
String pattern
UFS = file.GetFreeSpace (“UFS”);
RAM = file.GetFreeSpace(“RAM”);
long
List
List(String pattern)
String pattern
UFS = file. List (“UFS”);
RAM = file. List (“RAM”);
ListOutput
ListOutput
Listvoid functionname(String data) functionname
ListOutput data
Open
int Open(String pattern,String fn)
String pattern
String fn Handle Number
-1
26
Close
bool Close(int handle)
Handle Number Open
true
BeginWrite
BeginWrite(int handle,int size) Open()
Handel Number int handle
int size BeginWrite
true
Write
Write(char data) 1
Print
Print(String data)
Println
Println(String data)
(0x0A,0x0D)
WaitFinish
WaitFinish()
Seek
Seek(int handle,long start_at)
Handle Number int handle
long start_at
27
Open, BeginWrite, Print, WaitFinish, Close
void write_file(String file_name,String data){
int handle = file.Open(UFS,file_name);
if(handle!=-1){
if(file.BeginWrite(handle,data.length())){
file.Print(data);
file.WaitFinish();
}
}
file.Close(handle);
}
Read
Read(int handle,int buf_size,char *buf) Open
HandleNumber int handle
int buf_size
char *buf
ReadFile
ReadFile(String pattern,String file_name)
Open Read
String pattern String file_name
DataOutput
DataOutput
ReadFilevoid functionname(char data)
functionname DataOutput data
ReadFile()
void data_out(char data){
Serial.write(data);
}
void read_file(String pattern,String file_name){
file.DataOutput = data_out;
file.ReadFile(pattern,file_name);
}
28
Delete
Delete(String pattern,String fn)
String pattern String fn
file.Delete(“UFS”,”test”); //test UFS
file.Delete(“RAM”,"*"); //RAM
3G Shield/ 3G Module
File > Examples > TEE_UC20_Shield > Read_Write_File
File > Examples > TEE_UC20_Shield > Dump_file_from_SD_to_Flash
29
TEE_UC20_ShieldInternet
Internet
MMS FTP SMTP Web client
3G Shield / 3G Module Internet
AIS
Parameter
Internet
MMS
APN
internet
multimedia
MMSC
-
http://mms.mobilelife.co.th
MMS Proxy
-
203.170.229.34
MMS Port
-
8080
User
-
-
Password
-
-
APN Type
default
mms
DTAC
Parameter
Internet
MMS
APN
www.dtac.co.th
mms
MMSC
-
http://mms2.dtac.co.th/8002
MMS Proxy
-
203.155.200.133
MMS Port
-
8080
User
-
-
Password
-
-
APN Type
default
mms
TRUE
Parameter
Internet
MMS
APN
internet
hmms
MMSC
-
http://mms.trueworld.net:8002
MMS Proxy
-
10.4.7.39
MMS Port
-
8080
30
User
true
true
Password
true
true
APN Type
default
mms
TOT
Parameter
Internet
MMS
APN
internet
mms
MMSC
-
http://mmsc.tot3g.net:8002
MMS Proxy
-
10.218.24.83
MMS Port
-
8080
User
-
-
Password
-
-
APN Type
default
mms
My by Cat
Parameter
Internet
MMS
APN
internet
MMSC
-
-
MMS Proxy
-
-
MMS Port
-
-
User
-
-
Password
-
-
APN Type
default
-
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "internet.h"
INTERNET
INTERNET net;
31
Configure
bool INTERNET::Configure(String apn,String user,String password)
Internet String apn, String user,String password
Connect
bool Connect() 3G Shield / 3G Module Internet
Configure()
true
DisConnect
bool DisConnect() 3G Shield / 3G Module
Internet true
GetIP
String INTERNET::GetIP()IPAddress 3G Module
Internet String ip
32
TEE_UC20_ShieldMMS
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "internet.h"
#include "File.h"
#include "mms.h"
INTERNETUC_FILEMMS
INTERNET net;
UC_FILE file;
MMS mms;
SetMMSC
bool SetMMSC(String data) MMSC MSSC
Internet
SetProxy
bool SetProxy(String ip,String port) IP Address Proxy Port
Internet
Title
bool Title(String title) MMS
SendTo
SendTo(String receive) MMS
33
AddFile
bool AddFile(String pattern,String Filename) UFS RAM
MMS
ListMMSFile
String ListMMSFile() MMS
String
Send
String Send() MMS
MMS String
Clear
bool Clear() MMS
3G Shield / 3G ModuleMMS
File > Examples > TEE_UC20_Shield > Send_MMS
34
SD Card MMS
SD Card
SD Card .jpg pic.jpg
SD Card 3G Shield / 3G Module SMS
35
TEE_UC20_ShieldTCP
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "internet.h"
#include "tcp.h"
INTERNETTCP
INTERNET net;
TCP tcp;
Open
bool Open(String ip_url,String port)TCP Server
IP Address URL Server String ip_url TCP
Port String port true
Server false
Close
bool Close()TCP Server true
Server false
CheckConnection
bool CheckConnectionTCP Server
true Server false
Server
StartSend
bool StartSend()TCP Server
true Server Return false
Write
Write(char data) 1
36
Print
Print(String data)
Println
Println(String data)
(0x0A,0x0D)
StopSend
bool StopSend() TCP Server
ReceiveAvailable
bool ReceiveAvailable() Server
true False
ReadBuffer
String ReadBuffer() 3G Module Server
UART
Ping
void Ping(unsigned char contextid,String ip_url)
Ping Server unsigned char contextid
String ip_url IP Address URL Server
NTP
String NTP(unsigned char contexid,String ip_url,String port)
Server unsigned char contextid String
ip_url IP Address URL Server String port Port
3G Shield / 3G ModuleTCP
File > Examples > TEE_UC20_Shield > TCP
File > Examples > TEE_UC20_Shield > Ping
File > Examples > TEE_UC20_Shield > NTP
37
TEE_UC20_ShieldHTTPGET/HTTP POST
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "internet.h"
#include "File.h"
#include "http.h"
Object INTERNET , UC_FILE , HTTP
INTERNET net;
UC_FILE file;
HTTP http;
begin
bool begin(unsigned char context_ID) HTTP
Context ID PDP (Packet Data Protocol)unsigned char
context_ID 116
url
bool url(String url) URL HTTP GETHTTP POST
get
int get() HTTP GET Server HTTP
GET Return GET/POST
post
int post()HTTP POST Server
HTTP GET Return GET/POST
38
Return GET/POST
<httprspcode>
Meaning
200
OK
403
Forbidden
404
Not found
409
Conflict
411
Length required
500
Internal Server error
ReadData
void ReadData() Server SerialUART 3G
Shield / 3G Module UFS RAM
SaveResponseToMemory
bool SaveResponseToMemory(String pattern,String Filename)
Server UFS RAM
String pattern String Filename
ReadFile
3G Shield / 3G ModuleHTTP GET / HTTP POST
File > Examples > TEE_UC20_Shield > HTTP_GET
File > Examples > TEE_UC20_Shield > HTTP_POST
39
TEE_UC20_ShieldFTP
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "internet.h"
#include "File.h"
#include “ftp.h"
INTERNETUC_FILEFTP
INTERNET net;
UC_FILE file;
FTP ftp;
begin()
bool begin(unsigned char context_ID) HTTP
Context ID PDP (Packet Data Protocol)unsigned char
context_ID 116
SetUsernamePassword
bool SetUsernamePassword(String user,String pass) Username
Password FTP Server
SetFileType
bool SetFileType(unsigned char type) FTP
2 0 = Binary 1 = ASCII
SetTransMode
bool SetTransMode(unsigned char type) FTP Server
2 0 = Active mode 1 = Passive mode
SetTimeout
SetTimeout(int t) Timeout FTP Server
Timeout 20180 (default value = 90 )
40
LoginServer
int LoginServer(String serv,int port) 3G Module FTP Server
URLIP AddressServer String serv Port
int port 0 =
QuectelUCFTPATCommandsManualV4
Logout
int Logout() 3G Module FTP Server
Logout QuectelUCFTP
ATCommandsManualV4
SetPath
intSetPath(String path) Path FTP
Server
List
bool List(String path) Path
ListOutput
ListOutput
ListOutput
Listvoid functionname(String data) functionname
ListOutput data
ListToMemory
IntListToMemory(String path,String pattern,String fn)
FTP Server UFS RAM Path String
path String pattern String fn
MakeFolder
int MakeFolder(String name) FTP Server
String name
41
RenameFolder
int RenameFolder(String name_old,String name_new)
FTP Server String name_old
String name_new
DeleteFolder
IntDeleteFolder(String name) FTP Server
String name
DeleteFile
int DeleteFile(String name) FTP Server
String name
put
intput(String File,String pattern,String fn,int startpos,int uploadlen,int beof)
FTP Server
String File FTP Server(
50 )
String pattern Server 3
UFSRAMCOM(Stream Serial UART)
String fn UFSRAMFTP Server
int startpos
int uploadlen Stream COM FTP Server
int beof 2
0 uploadlen
putStream
1 uploadlen
42
get
int get(String File,String pattern,String fn,int startpos,int downloadlen)
FTP Server
String File FTP Server(50
)
String pattern Server 3
UFSRAMCOM(Stream Serial UART)
String fn UFSRAM
int startpos
int downloadlen
3G Shield / 3G ModuleFTP
File > Examples > TEE_UC20_Shield > FTP_File_Operation
File > Examples > TEE_UC20_Shield > FTP_List_File
File > Examples > TEE_UC20_Shield > FTP_List_File_To_RAM
File > Examples > TEE_UC20_Shield > FTP_PUT
File > Examples > TEE_UC20_Shield > FTP_GET_To_FLASH
File > Examples > TEE_UC20_Shield > FTP_GET_To_RAM
43
TEE_UC20_ShieldGNSS
TEE_UC20_Shield include
#include "TEE_UC20.h"
#include "SoftwareSerial.h"
#include <AltSoftSerial.h>
#include "gnss.h"
GNSS
GNSS gps;
Start
bool Start() GPS/GNSS 3G Module
Stop
bool Stop() GPS/GNSS 3G Module
GetPosition
String GetPosition() GPS/GNSS
QGPSLOC: <UTC>,<latitude>,<longitude>,<hdop>,<altitude>,<fix>,<cog>,<spkm>,<spkn>,
<date>,<nsat>
Parameter
Meaning
<UTC>
UTC time. Format: hhmmss.sss (quoted
from GPGGA sentence).
<latitude>
Latitude. Format: ddmm.mmmm N/S
(quoted from GPGGA sentence).
dd 00-89 (degree).
mm.mmmm 00.0000-59.9999 (minute).
N/S North latitude/ South latitude.
<longitude>
Longitude. Format: dddmm.mmmm E/W
(quoted from GPGGA sentence).
ddd 000-179 (degree).
44
mm.mmmm 00.0000-59.9999 (minute).
E/W East longitude/West longitude.
<hdop>
Horizontal precision, 0.5-99.9 (quoted from
GPGGA sentence).
<altitude>
The altitude of the antenna away from the
sea level(unit: m), accurate to one decimal
place(quoted from GPGGA sentence).
<fix>
GNSS positioning mode(quoted from
GNGSA/GPGSA).
2 2D positioning.
3 3D positioning.
<cog>
Ground heading based on true north.
Format: ddd.mm (quoted from GPVT
sentence).
ddd 000-359 (degree).
mm 00-59 (minute).
<spkm>
Speed over ground. Format: xxxx.x, unit:
Km/h, accurate to one decimal place.
(quoted from GPVTG sentence).
<spkn>
Speed over ground. Format: xxxx.x, unit:
knots, accurate to one decimal place.
(quoted from GPVTG sentence).
<date>
UTC date when positioning. Format:
ddmmyy (quoted from GPRMC sentence).
<nsat>
Number of satellites, from 00 to 12 (the first
0 will also be transferred, quoted from
GPGGA sentence).
EnableNMEA
bool EnableNMEA() NMEA
45
DisableNMEA
bool DisableNMEA()NMEA
GetNMEA
String GetNMEA(String nmea) NMEA
NMEA String nmea
NMEA GGAGetNMEA(“GGA”)