Skip to content

Commit cd2a6e3

Browse files
authored
Merge pull request #6 from sparkfun/release_candidate
v1.0.2
2 parents 15c6d74 + a43adb7 commit cd2a6e3

File tree

5 files changed

+560
-171
lines changed

5 files changed

+560
-171
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
/*
2+
3+
SARA-R5 Example
4+
===============
5+
6+
Identification - using ESPSoftwareSerial
7+
8+
Written by: Paul Clark
9+
Date: December 29th 2021
10+
11+
This example demonstrates how to read the SARA's:
12+
Manufacturer identification
13+
Model identification
14+
Firmware version identification
15+
Product Serial No.
16+
IMEI identification
17+
IMSI identification
18+
SIM CCID
19+
Subscriber number
20+
Capabilities
21+
SIM state
22+
23+
The ESP32 core doesn't include SoftwareSerial. Instead we use the library by Peter Lerup and Dirk O. Kaar:
24+
https://github.com/plerup/espsoftwareserial
25+
26+
Feel like supporting open source hardware?
27+
Buy a board from SparkFun!
28+
29+
Licence: MIT
30+
Please see LICENSE.md for full details
31+
32+
*/
33+
34+
// Include SoftwareSerial.h _before_ including SparkFun_u-blox_SARA-R5_Arduino_Library.h
35+
// to allow the SARA-R5 library to detect SoftwareSerial.h using an #if __has_include
36+
#include <SoftwareSerial.h> //Click here to get the library: http://librarymanager/All#ESPSoftwareSerial_ESP8266/ESP32
37+
38+
#include <SparkFun_u-blox_SARA-R5_Arduino_Library.h> //Click here to get the library: http://librarymanager/All#SparkFun_u-blox_SARA-R5_Arduino_Library
39+
40+
// Create a SoftwareSerial object to pass to the SARA-R5 library
41+
// Note: we need to call saraSerial.begin and saraSerial.end in setup() - see below for details
42+
SoftwareSerial saraSerial;
43+
44+
// Create a SARA_R5 object to use throughout the sketch
45+
// Usually we would tell the library which GPIO pin to use to control the SARA power (see below),
46+
// but we can start the SARA without a power pin. It just means we need to manually
47+
// turn the power on if required! ;-D
48+
SARA_R5 mySARA;
49+
50+
// Create a SARA_R5 object to use throughout the sketch
51+
// We need to tell the library what GPIO pin is connected to the SARA power pin.
52+
// If you're using the MicroMod Asset Tracker and the MicroMod Artemis Processor Board,
53+
// the pin name is G2 which is connected to pin AD34.
54+
// Change the pin number if required.
55+
//SARA_R5 mySARA(34);
56+
57+
// Map SIM states to more readable strings
58+
String simStateString[] =
59+
{
60+
"Not present", // 0
61+
"PIN needed", // 1
62+
"PIN blocked", // 2
63+
"PUK blocked", // 3
64+
"Not operational", // 4
65+
"Restricted", // 5
66+
"Operational" // 6
67+
};
68+
69+
// processSIMstate is provided to the SARA-R5 library via a
70+
// callback setter -- setSIMstateReadCallback. (See setup())
71+
void processSIMstate(SARA_R5_sim_states_t state)
72+
{
73+
Serial.println();
74+
Serial.print(F("SIM state: "));
75+
Serial.print(String(state));
76+
Serial.println();
77+
}
78+
79+
void setup()
80+
{
81+
Serial.begin(115200); // Start the serial console
82+
83+
// Wait for user to press key to begin
84+
Serial.println(F("SARA-R5 Example"));
85+
Serial.println(F("Press any key to begin"));
86+
87+
while (!Serial.available()) // Wait for the user to press a key (send any serial character)
88+
;
89+
while (Serial.available()) // Empty the serial RX buffer
90+
Serial.read();
91+
92+
//mySARA.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
93+
94+
// For the MicroMod Asset Tracker, we need to invert the power pin so it pulls high instead of low
95+
// Comment the next line if required
96+
mySARA.invertPowerPin(true);
97+
98+
// ESPSoftwareSerial does not like repeated .begin's without a .end in between.
99+
// We need to .begin and .end the saraSerial port here, before the mySARA.begin, to set up the pin numbers etc.
100+
// E.g. to use: 57600 baud; 8 databits, no parity, 1 stop bit; RXD on pin 33; TXD on pin 32; no inversion.
101+
Serial.println(F("Configuring SoftwareSerial saraSerial"));
102+
saraSerial.begin(57600, SWSERIAL_8N1, 33, 32, false);
103+
saraSerial.end();
104+
105+
// Initialize the SARA
106+
if (mySARA.begin(saraSerial, 57600) )
107+
{
108+
Serial.println(F("SARA-R5 connected!"));
109+
}
110+
else
111+
{
112+
Serial.println(F("Unable to communicate with the SARA."));
113+
Serial.println(F("Manually power-on (hold the SARA On button for 3 seconds) on and try again."));
114+
while (1) ; // Loop forever on fail
115+
}
116+
Serial.println();
117+
118+
Serial.println("Manufacturer ID: " + String(mySARA.getManufacturerID()));
119+
Serial.println("Model ID: " + String(mySARA.getModelID()));
120+
Serial.println("Firmware Version: " + String(mySARA.getFirmwareVersion()));
121+
Serial.println("Product Serial No.: " + String(mySARA.getSerialNo()));
122+
Serial.println("IMEI: " + String(mySARA.getIMEI()));
123+
Serial.println("IMSI: " + String(mySARA.getIMSI()));
124+
Serial.println("SIM CCID: " + String(mySARA.getCCID()));
125+
Serial.println("Subscriber No.: " + String(mySARA.getSubscriberNo()));
126+
Serial.println("Capabilities: " + String(mySARA.getCapabilities()));
127+
128+
// Set a callback to return the SIM state once requested
129+
mySARA.setSIMstateReportCallback(&processSIMstate);
130+
// Now enable SIM state reporting for states 0 to 6 (by setting the reporting mode LSb)
131+
if (mySARA.setSIMstateReportingMode(1) == SARA_R5_SUCCESS)
132+
Serial.println("SIM state reports requested...");
133+
// You can disable the SIM staus reports again by calling assetTracker.setSIMstateReportingMode(0)
134+
}
135+
136+
void loop()
137+
{
138+
mySARA.poll(); // Keep processing data from the SARA so we can extract the SIM status
139+
}

keywords.txt

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,11 @@ socketWriteUDP KEYWORD2
105105
socketRead KEYWORD2
106106
socketReadUDP KEYWORD2
107107
socketListen KEYWORD2
108+
socketDirectLinkMode KEYWORD2
109+
socketDirectLinkTimeTrigger KEYWORD2
110+
socketDirectLinkDataLengthTrigger KEYWORD2
111+
socketDirectLinkCharacterTrigger KEYWORD2
112+
socketDirectLinkCongestionTimer KEYWORD2
108113
socketGetLastError KEYWORD2
109114
lastRemoteIP KEYWORD2
110115
ping KEYWORD2
@@ -122,21 +127,22 @@ sendHTTPPOSTdata KEYWORD2
122127
setPDPconfiguration KEYWORD2
123128
performPDPaction KEYWORD2
124129
activatePDPcontext KEYWORD2
125-
boolean isGPSon KEYWORD2
130+
isGPSon KEYWORD2
126131
gpsPower KEYWORD2
127-
gpsEnableClock KEYWORD2
128-
gpsGetClock KEYWORD2
129-
gpsEnableFix KEYWORD2
130-
gpsGetFix KEYWORD2
131-
gpsEnablePos KEYWORD2
132-
gpsGetPos KEYWORD2
133-
gpsEnableSat KEYWORD2
134-
gpsGetSat KEYWORD2
132+
# gpsEnableClock KEYWORD2
133+
# gpsGetClock KEYWORD2
134+
# gpsEnableFix KEYWORD2
135+
# gpsGetFix KEYWORD2
136+
# gpsEnablePos KEYWORD2
137+
# gpsGetPos KEYWORD2
138+
# gpsEnableSat KEYWORD2
139+
# gpsGetSat KEYWORD2
135140
gpsEnableRmc KEYWORD2
136141
gpsGetRmc KEYWORD2
137-
gpsEnableSpeed KEYWORD2
138-
gpsGetSpeed KEYWORD2
142+
# gpsEnableSpeed KEYWORD2
143+
# gpsGetSpeed KEYWORD2
139144
gpsRequest KEYWORD2
145+
gpsAidingServerConf KEYWORD2
140146
getFileContents KEYWORD2
141147
functionality KEYWORD2
142148
sendCustomCommandWithResponse KEYWORD2

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox SARA-R5 Arduino Library
2-
version=1.0.1
2+
version=1.0.2
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for the u-blox SARA-R5 LTE-M / NB-IoT modules with secure cloud

0 commit comments

Comments
 (0)