Skip to content

Commit 7b4f4b5

Browse files
committed
Added the SMS example
1 parent 25f7277 commit 7b4f4b5

File tree

4 files changed

+100
-2
lines changed

4 files changed

+100
-2
lines changed

examples/Example101_GNSS_GPRMC/Example101_GNSS_GPRMC.ino

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@
2525
//SoftwareSerial saraSerial(8, 9);
2626

2727
// Create a SARA_R5 object to use throughout the sketch
28+
// Usually we would tell the library which GPIO pin to use to control the SARA power (see below),
29+
// but we can start the SARA without a power pin. It just means we need to use a finger to
30+
// turn the power on manually if required! ;-D
2831
SARA_R5 assetTracker;
2932

33+
// Create a SARA_R5 object to use throughout the sketch
34+
// We need to tell the library what GPIO pin is connected to the SARA power pin.
35+
// If you're using the MicroMod Asset Tracker and the MicroMod Artemis Processor Board,
36+
// the pin number is GPIO2 which is connected to AD34. TO DO: Check this!
37+
// Change the pin number if required.
38+
//SARA_R5 assetTracker(34);
39+
3040
PositionData gps;
3141
SpeedData spd;
3242
ClockData clk;

examples/Example201_NetworkInfo/Example201_NetworkInfo.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@
3030
//SoftwareSerial saraSerial(8, 9);
3131

3232
// Create a SARA_R5 object to use throughout the sketch
33-
SARA_R5 assetTracker;
33+
// We need to tell the library what GPIO pin is connected to the SARA power pin.
34+
// If you're using the MicroMod Asset Tracker and the MicroMod Artemis Processor Board,
35+
// the pin number is GPIO2 which is connected to AD34. TO DO: Check this!
36+
SARA_R5 assetTracker(34);
3437

3538
// Map registration status messages to more readable strings
3639
String registrationString[] =

examples/Example301_Identification/Example301_Identification.ino

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@
3434
//SoftwareSerial saraSerial(8, 9);
3535

3636
// Create a SARA_R5 object to use throughout the sketch
37-
SARA_R5 assetTracker;
37+
// We need to tell the library what GPIO pin is connected to the SARA power pin.
38+
// If you're using the MicroMod Asset Tracker and the MicroMod Artemis Processor Board,
39+
// the pin number is GPIO2 which is connected to AD34. TO DO: Check this!
40+
SARA_R5 assetTracker(34);
3841

3942
void setup() {
4043
Serial.begin(9600);
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
/*
2+
Send an SMS with the SARA-R5
3+
By: Paul Clark
4+
SparkFun Electronics
5+
Date: October 20th 2020
6+
7+
Please see LICENSE.md for the license information
8+
9+
This example demonstrates how to send an SMS message with your MicroMod Asset Tracker Carrier Board.
10+
11+
Before uploading, set the DESTINATION_NUMBER constant to the
12+
phone number you want to send a text message to.
13+
(Don't forget to add an internation code (e.g. 1 for US)).
14+
15+
Once programmed, open the serial monitor, set the baud rate to 9600,
16+
and type a message to be sent via SMS.
17+
18+
This code is intend to run on the MicroMod Asset Tracker Carrier Board
19+
using (e.g.) the MicroMod Artemis Processor Board
20+
21+
Select the SparkFun RedBoard Artemis ATP from the SparkFun Apollo3 boards
22+
23+
*/
24+
25+
//Click here to get the library: http://librarymanager/All#SparkFun_u-blox_SARA-R5_Arduino_Library
26+
#include <SparkFun_u-blox_SARA-R5_Arduino_Library.h>
27+
28+
// Uncomment the next line to connect to the SARA-R5 using hardware Serial1
29+
#define saraSerial Serial1
30+
31+
// Uncomment the next line to create a SoftwareSerial object to pass to the SARA-R5 library instead
32+
//SoftwareSerial saraSerial(8, 9);
33+
34+
// Create a SARA_R5 object to use throughout the sketch
35+
// We need to tell the library what GPIO pin is connected to the SARA power pin.
36+
// If you're using the MicroMod Asset Tracker and the MicroMod Artemis Processor Board,
37+
// the pin number is GPIO2 which is connected to AD34. TO DO: Check this!
38+
SARA_R5 assetTracker(34);
39+
40+
// Set the cell phone number to be texted
41+
String DESTINATION_NUMBER = "11234567890";
42+
43+
void setup() {
44+
Serial.begin(9600);
45+
46+
// Initialize the SARA
47+
if (assetTracker.begin(saraSerial, 9600))
48+
{
49+
Serial.println(F("Asset Tracker (SARA-R5) connected!"));
50+
}
51+
else
52+
{
53+
Serial.println(F("Unable to communicate with the SARA."));
54+
Serial.println(F("Manually power-on (hold POWER for 3 seconds) on and try again."));
55+
while (1) ; // Loop forever on fail
56+
}
57+
Serial.println();
58+
59+
Serial.println(F("Type a message. Send a Newline (\\n) to send it..."));
60+
}
61+
62+
void loop() {
63+
static String message = "";
64+
if (Serial.available())
65+
{
66+
char c = Serial.read();
67+
// Read a message until a \n (newline) is received
68+
if (c == '\n')
69+
{
70+
// Once we receive a newline. send the text.
71+
Serial.println("Sending: \"" + String(message) + "\" to " + DESTINATION_NUMBER);
72+
// Call assetTracker.sendSMS(String number, String message) to send an SMS
73+
// message.
74+
assetTracker.sendSMS(DESTINATION_NUMBER, message);
75+
message = ""; // Clear message string
76+
}
77+
else
78+
{
79+
message += c; // Add last character to message
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)