Skip to content

Commit ce002a8

Browse files
authored
Add files via upload
Added GSM Coordinates
1 parent 3682cd6 commit ce002a8

File tree

6 files changed

+204
-10
lines changed

6 files changed

+204
-10
lines changed

README.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,29 +23,35 @@ Arduino Uno | Sim800L | Notes
2323
GND | GND |
2424

2525

26+
* If it returns true there is an error
27+
2628
## Methods and functions
2729

2830
Name|Return|Notes
2931
:-------|:-------:|:-----------------------------------------------:|
3032
begin()|None|Initialize the library
3133
begin(number)|None|Initialize the library with user's baud rate
3234
reset()|None|Reset the module, and wait to Sms Ready.
33-
setSleepMode(bool)|true or false|enable or disable sleep mode
34-
getSleepMode()|true or false|return sleep mode status
35-
setFunctionalityMode(number)|true or false|set functionality mode
36-
getFunctionalityMode()|true or false|return functionality mode status
37-
setPIN(String)|true or false|enable user to set a pin code
35+
setSleepMode(bool)|true or false|enable or disable sleep mode *
36+
getSleepMode()|true or false|return sleep mode status *
37+
setFunctionalityMode(number)|true or false|set functionality mode *
38+
getFunctionalityMode()|true or false|return functionality mode status *
39+
setPIN(String)|true or false|enable user to set a pin code *
3840
getProductInfo()|String|return product identification information
3941
getOperatorsList()|String|return the list of operators
4042
getOperator()|String|return the currently selected operator
41-
sendSms(number,text)|true or false|both parameters must be Strings.
43+
calculateLocation()|true or false|calculate gsm position *
44+
getLocationCode()|String|return the location code
45+
getLongitude()|String|return longitude
46+
getLatitude()|String|return latitude
47+
sendSms(number,text)|true or false|both parameters must be Strings. *
4248
readSms(index)|String|index is the position of the sms in the prefered memory storage
4349
getNumberSms(index)|String|returns the number of the sms.
44-
delAllSms()|true or false|Delete all sms
50+
delAllSms()|true or false|Delete all sms *
4551
signalQuality()|String|return info about signal quality
46-
answerCall()|true or false|
52+
answerCall()|true or false| *
4753
callNumber(number)|None|
48-
hangoffCall()|true or false|
54+
hangoffCall()|true or false| *
4955
getCallStatus()|uint8_t|Return the call status, 0=ready,2=Unknown(),3=Ringing,4=Call in progress
5056
setPhoneFunctionality()|None|Set at to full functionality
5157
activateBearerProfile()|None|

Sim800L.cpp

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,73 @@ String Sim800L::getOperator()
251251
}
252252

253253

254+
bool Sim800L::calculateLocation()
255+
{
256+
/*
257+
Type: 1 To get longitude and latitude
258+
Cid = 1 Bearer profile identifier refer to AT+SAPBR
259+
*/
260+
261+
uint8_t type = 1;
262+
uint8_t cid = 1;
263+
264+
265+
this->print("AT+CIPGSMLOC=");
266+
this->print(type);
267+
this->print(",");
268+
this->print(cid);
269+
this->print("\r");
270+
271+
272+
String data = _readSerial();
273+
274+
if (data.indexOf("ER")!=(-1)) return false;
275+
276+
uint8_t indexOne;
277+
uint8_t indexTwo;
278+
279+
indexOne = data.indexOf(":") + 1;
280+
indexTwo = data.indexOf(",");
281+
282+
_locationCode = data.substring(indexOne , indexTwo);
283+
284+
indexOne = data.indexOf(",") + 1;
285+
indexTwo = data.indexOf("," , indexOne);
286+
287+
_longitude = data.substring(indexOne , indexTwo);
288+
289+
indexOne = data.indexOf(",", indexTwo) + 1;
290+
indexTwo = data.indexOf("," , indexOne);
291+
292+
_latitude = data.substring(indexOne , indexTwo);
293+
294+
return true;
295+
296+
}
297+
298+
String Sim800L::getLocationCode() {
299+
return _locationCode;
300+
/*
301+
Location Code:
302+
0 Success
303+
404 Not Found
304+
408 Request Time-out
305+
601 Network Error
306+
602 No Memory
307+
603 DNS Error
308+
604 Stack Busy
309+
65535 Other Error
310+
*/
311+
}
312+
313+
String Sim800L::getLongitude() {
314+
return _longitude;
315+
}
316+
317+
String Sim800L::getLatitude() {
318+
return _latitude;
319+
}
320+
254321

255322
//
256323
//PUBLIC METHODS

Sim800L.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ class Sim800L : public SoftwareSerial
8484
String _buffer;
8585
bool _sleepMode;
8686
uint8_t _functionalityMode;
87+
String _locationCode;
88+
String _longitude;
89+
String _latitude;
8790

8891
String _readSerial();
8992
String _readSerial(uint32_t timeout);
@@ -116,6 +119,11 @@ class Sim800L : public SoftwareSerial
116119

117120
String getOperatorsList();
118121
String getOperator();
122+
123+
bool calculateLocation();
124+
String getLocationCode();
125+
String getLongitude();
126+
String getLatitude();
119127

120128
bool answerCall();
121129
void callNumber(char* number);
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
/*
2+
This library was written by Vittorio Esposito
3+
https://github.com/VittorioEsposito
4+
5+
Designed to work with the GSM Sim800L.
6+
7+
ENG
8+
This library uses SoftwareSerial, you can define RX and TX pins
9+
in the header "Sim800L.h", by default pins are RX=10 and TX=11.
10+
Be sure that GND is connected to arduino too.
11+
You can also change the RESET_PIN as you prefer.
12+
13+
ESP
14+
Esta libreria usa SoftwareSerial, se pueden cambiar los pines de RX y TX
15+
en el archivo header, "Sim800L.h", por defecto los pines vienen configurado en
16+
RX=10 TX=11.
17+
Tambien se puede cambiar el RESET_PIN por otro que prefiera
18+
19+
ITA
20+
Questa libreria utilizza la SoftwareSerial, si possono cambiare i pin di RX e TX
21+
dall' intestazione "Sim800L.h", di default essi sono impostati come RX=10 RX=11
22+
Assicurarsi di aver collegato il dispositivo al pin GND di Arduino.
23+
E' anche possibile cambiare il RESET_PIN.
24+
25+
26+
DEFAULT PINOUT:
27+
_____________________________
28+
| ARDUINO UNO >>> Sim800L |
29+
-----------------------------
30+
GND >>> GND
31+
RX 10 >>> TX
32+
TX 11 >>> RX
33+
RESET 2 >>> RST
34+
35+
POWER SOURCE 4.2V >>> VCC
36+
37+
38+
SOFTWARE SERIAL NOTES:
39+
40+
PINOUT
41+
The library has the following known limitations:
42+
1. If using multiple software serial ports, only one can receive data at a time.
43+
2. Not all pins on the Mega and Mega 2560 support change interrupts, so only the following can be used for RX: 10, 11, 12, 13, 14, 15, 50, 51, 52, 53, A8 (62), A9 (63), A10 (64), A11 (65), A12 (66), A13 (67), A14 (68), A15 (69).
44+
3. Not all pins on the Leonardo and Micro support change interrupts, so only the following can be used for RX: 8, 9, 10, 11, 14 (MISO), 15 (SCK), 16 (MOSI).
45+
4. On Arduino or Genuino 101 the current maximum RX speed is 57600bps
46+
5. On Arduino or Genuino 101 RX doesn't work on Pin 13
47+
48+
BAUD RATE
49+
Supported baud rates are 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 31250, 38400, 57600, and 115200.
50+
51+
52+
Edited on: December 24, 2016
53+
Editor: Vittorio Esposito
54+
55+
Original version by: Cristian Steib
56+
57+
58+
*/
59+
60+
#include <Sim800L.h>
61+
#include <SoftwareSerial.h>
62+
63+
#define RX 10
64+
#define TX 11
65+
66+
Sim800L GSM(RX, TX);
67+
68+
/*
69+
In alternative:
70+
Sim800L GSM; // Use default pinout
71+
Sim800L GSM(RX, TX, RESET);
72+
Sim800L GSM(RX, TX, RESET, LED);
73+
*/
74+
75+
void setup() {
76+
Serial.begin(9600);
77+
GSM.begin(4800);
78+
79+
if (GSM.calculateLocation()) Serial.println("Location Calculated");
80+
else Serial.println("Error in calculating location");
81+
82+
Serial.print("Location Code: ");
83+
Serial.println(GSM.getLocationCode());
84+
85+
Serial.print("Longitude: ");
86+
Serial.println(GSM.getLongitude());
87+
88+
Serial.print("Longitude: ");
89+
Serial.println(GSM.getLatitude());
90+
91+
/*
92+
Location Code:
93+
0 Success
94+
404 Not Found
95+
408 Request Time-out
96+
601 Network Error
97+
602 No Memory
98+
603 DNS Error
99+
604 Stack Busy
100+
65535 Other Error
101+
*/
102+
103+
}
104+
105+
void loop() {
106+
107+
}
108+

keywords.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ getProductInfo KEYWORD2
4545
getOperatorsList KEYWORD2
4646
getOperator KEYWORD2
4747

48+
calculateLocation KEYWORD2
49+
getLocationCode KEYWORD2
50+
getLongitude KEYWORD2
51+
getLatitude KEYWORD2
52+
4853
answerCall KEYWORD2
4954
callNumber KEYWORD2
5055
hangoffCall KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Sim800L Library Revised
2-
version=1.0.0
2+
version=1.0.1
33
author=Vittorio Esposito
44
maintainer=Vittorio Esposito
55
sentence=Arduino library for Sim800L

0 commit comments

Comments
 (0)