SODAQ SARA R41XM

Get started with the SODAQ SARA R41XM

Get started with the SODAQ SARA R410M/R412M SFF or AFF, an Arduino-based development board with an embedded u-blox SARA R41X LTE-M, NB-IoT and GPRS modem. The device comes with an integrated GPS, Accelerometer and Magnetometer.

Quick Navigation

Prerequisites

Getting Started with the SODAQ SARA

Install SODAQ SARA board manager

Open up the Arduino IDE and select Arduino > Preferences from the menu bar. Paste the following URL in the field next to Additional Boards Manager URLs:

http://downloads.sodaq.net/package_sodaq_samd_index.json

Go to Tools > Board > Board Manager, search for SODAQ SAMD and install the latest version.

Upload Passthrough sketch

The Passthrough sketch allows you to send AT commands to the u-blox modem.

Start by connecting the LTE antenna

Add the Monogoto SIM

Connect the battery

Connect the SODAQ SARA to your computer using the micro USB port next to the SIM card slot, an LED will light up yellow.

Make sure to connect the USB cable to the micro USB port next to the SIM card slot. When connecting the cable to the second USB port it is not possible to upload the Arduino sketch.

Select the right board in the Arduino IDE via Tools > Board > SODAQ SAMD Boards > SODAQ SARA AFF/SFF

Select the right port via Tools > Port

SODAQ SARA AFF passthrough Arduino Sketch:
// Passthrough Arduino sketch
// Source: https://learn.sodaq.com/Boards/Sara_AFF/Examples/passthrough/

#include <Arduino.h>

#define R4XX // Comment out when you use the u-blox R2XX module

#if defined(ARDUINO_SODAQ_SARA)
#define DEBUG_STREAM SerialUSB
#define MODEM_STREAM Serial1
#define powerPin SARA_ENABLE
#define enablePin SARA_TX_ENABLE

#else
#error "Please select the SODAQ SARA as your board via Tools > Board:"
#endif

#if defined(R4XX)
unsigned long baud = 115200;  //start at 115200 allow the USB port to change the Baudrate
#else
unsigned long baud = 9600;  //start at 9600 allow the USB port to change the Baudrate
#endif

void setup()
{
#ifdef powerPin
  // Turn the nb-iot module on
  pinMode(powerPin, OUTPUT);
  digitalWrite(powerPin, HIGH);
#endif

#ifdef enablePin
  // Set state to active
  pinMode(enablePin, OUTPUT);
  digitalWrite(enablePin, HIGH);
#endif // enablePin

#if defined(R4XX)
    pinMode(SARA_R4XX_TOGGLE, OUTPUT);
    digitalWrite(SARA_R4XX_TOGGLE, LOW);
    delay(2000);
    pinMode(SARA_R4XX_TOGGLE, INPUT);
#endif

  // Start communication
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
}

// Forward every message to the other serial
void loop()
{
  while (DEBUG_STREAM.available())
  {
    MODEM_STREAM.write(DEBUG_STREAM.read());
  }

  while (MODEM_STREAM.available())
  {
    DEBUG_STREAM.write(MODEM_STREAM.read());
  }

  // check if the USB virtual serial wants a new baud rate
  // This will be used by the UEUpdater to flash new software
  if (DEBUG_STREAM.baud() != baud) {
    baud = DEBUG_STREAM.baud();
    MODEM_STREAM.begin(baud);
  }
}
SODAQ SARA SFF passthrough Arduino Sketch:
// Passthrough Arduino sketch
// Source: https://learn.sodaq.com/Boards/Sara_SFF/examples/passthrough/

#include <Arduino.h>

#define R4XX // Comment out when you use the u-blox R3XX or R2XX module
//#define N3XX // Uncomment when you use the ublox N3XX module

#define DEBUG_STREAM SerialUSB
#define MODEM_STREAM Serial1

#if defined(R4XX)
unsigned long baud = 115200;  //start at 115200 allow the USB port to change the Baudrate
#elif defined(N3XX)
unsigned long baud = 57600;  //start at 57600 allow the USB port to change the Baudrate
#else
unsigned long baud = 9600;  //start at 9600 allow the USB port to change the Baudrate
#endif

void setup()
{
  // Turn the power to the SARA module on.
  // we have a powerswitch on board to switch the power to the SARA on/of when needed
  // in most applications we keep the power on all the time  
  pinMode(SARA_ENABLE, OUTPUT);  
  digitalWrite(SARA_ENABLE, HIGH);

#if defined(R4XX) || defined(N3XX)
    // Turn the nb-iot module on
    // The R4XX module has an on/off pin. You can toggle this pin or keep it low to
    // switch on the module
    pinMode(SARA_R4XX_TOGGLE, OUTPUT);
    digitalWrite(SARA_R4XX_TOGGLE, LOW);
    delay(2000);
    pinMode(SARA_R4XX_TOGGLE, INPUT);
#endif

  // Start communication
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
}

// Forward every message to the other serial
void loop()
{
  while (DEBUG_STREAM.available())
  {
    MODEM_STREAM.write(DEBUG_STREAM.read());
  }

  while (MODEM_STREAM.available())
  {
    DEBUG_STREAM.write(MODEM_STREAM.read());
  }

  // check if the USB virtual serial wants a new baud rate
  // This will be used by the UEUpdater to flash new software
  if (DEBUG_STREAM.baud() != baud) {
    baud = DEBUG_STREAM.baud();
    MODEM_STREAM.begin(baud);
  }
}

Establish a connection with the u-blox modem

Open up the Serial Monitor from the Arduino IDE by clicking the Serial Monitor-button in the top right corner.

Set the baud rate to 115200 and enter AT in the Serial Monitor. If the connection with the u-blox modem has been established, the board will answer with OK.

If you don’t see OK click the reset button on the SODAQ SARA and try again.

Next up, disable PSM (Power Saving Mode) and eDRX (Extended Discontinuous Reception). When these features are enabled the modeqm goes to sleep automatically and stops responding to AT Commands.

Disable PSM:

AT+CPSMS=0

Disable eDRX:

AT+CEDRXS=0

Disable Power saving control:

AT+UPSV=0

Connect the u-blox modem to Monogoto

Visit the u-blox SARA R4 documentation for a detailed guide on connecting the modem to Monogoto.

pageu-blox SARA R4

Build an end-to-end tracking application

Guard your valuable assets, get notified if any assets move without your consent and keep track of their real-time GPS location. Source: AllThingsTalk

Prerequisites

Install the AllThingsTalk Arduino library

Open your Arduino IDE and install the AllThingsTalk LTE-M SDK library via Sketch > Include library > Manage Libraries.

Open the sketch GuardAndTrackAssets: File > Examples > AllThingsTalk LTE-M SDK > SDK Examples > GuardAndTrackAssets

Register your device in AllThingsTalk Maker

Create a free account on AllThingsTalk

Visit to the AllThingsTalk Maker portal

Click the CONNECT A DEVICE button and select the LTE-M Rapid Development Kit. Skip the step for selecting a NB-IoT/LTE-M network provider.

Click on Settings and Authentication to find your Device ID and Device Token.

In your Arduino sketch click the tab keys.h. Add the authentication credentials and update the APN settings to data.mono.

Upload the sketch to the SODAQ SARA and wait for the onboard LED to turn green.

Did the LED turn green? Congratulations! The device is connected to both Monogoto and AllThingsTalk 🙌

Start tracking your assets

Place your device outside or next to a window so it can receive GPS signals.

Go back to the AllThingsTalk Maker, select your asset and click on the actuator Lock, scroll down to the section State and enter.

{
    "value": "false"
}

Next up, click on the Lock actuator again, scroll down to the section Command and enter:

{
    "value": "true"
}

When shaking the device, an alert is triggered and the device starts sending GPS data regularly. Visit the Debug tab to see the GPS data appear.

Great work! 👏 You managed to build an end-to-end LTE-M application. You can now start playing around with widgets to visualize your GPS data in AllThingsTalk or to create rules to trigger actions based on sensor data.

Last updated