SODAQ SARA N211

SODAQ SARA N211

The SODAQ SARA is a developers board in the standard Arduino formfactor. It comes with a powerful 32 bits microcontroller, two grove sockets to easily connect any sensor, two jst connectors to connect your battery and solar panel, onboard charge circuit, accelerometer, GPS and NB-IoT or Cat M1.

Menu
Getting Started
Features
Pinout
Pin definitions
Schematics
Examples

Install the latest SODAQ SAMD boardfiles.
See Arduino setup page

Microcontroller  ATSAMD21J18, 32-Bit ARM Cortex M0+
Compatibility Arduino M0 Compatible
Size Arduino Uno formfactor, 53.4 x 68.6 mm
Operating Voltage 3.3V
I/O Pins 23
Analog Output Pin 10-bit DAC
External Interrupts Available on all pins
DC Current per I/O pin 7 mA
Flash Memory 256 KB
SRAM 32KB
EEPROM Up to 16KB by emulation
Clock Speed 48 MHz
Power 5V USB power and/or 3.7 LiPo battery
Charging Solar charge controller, up to 500mA charge current
LED RGB LED, LED on D13
NB-IoT uBlox SARA N2XX, R4XX Series
GPS uBlox SAM M8Q
Accelerometer/Magneto LSM303AGR
USB MicroUSB Port

Some things like the onboard LED and the RGB LED are used on multiple boards. To make it more easy you can use the definition name.

Example:
pinMode(13, OUTPUT) and pinMode(LED_BUILTIN, OUTPUT) will do the same.

Pin description Pin number Definition
Red LED D16 LED_RED
Green LED D17 LED_GREEN
Blue LED D18 LED_BLUE
Onboard LED D13 LED_BUILTIN
GPS Enable D26 GPS_ENABLE
Power Pin SARA D27 SARA_ENABLE
Enable Pin SARA D29 SARA_TX_ENABLE
Reset Pin SARA D28 SARA_RESET
GPS Timepulse D25 GPS_TIMEPULSE
MISO (SPI)  D12 MISO
SS (SPI)  D10 SS
MOSI (SPI)  D11 MOSI
SCK (SPI)  D13 SCK
Accelrometer Interrupt 1 D19 ACCEL_INT1
Accelrometer Interrupt 2 D20 ACCEL_INT2
Magnetometer Interrupt D21 MAG_INT
USB Detect D22 USB_DETECT
Status pin Sara D23 SARA_STATUS
Charge Status D24 CHG_STAT

SARA-R2-schematic PDF

        
SARA-R1-schematic PDF

       

Passthrough

With the passthrough sketch you can send AT commands (NB-IoT) to the ublox module on the Sodaq Sara.

This example doesn’t require any additional libraries.

#include <Arduino.h>

#if defined(ARDUINO_SODAQ_SARA)
/* 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"
#endif

unsigned long baud = 9600;

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

  // 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());
  }
}

Library

Click on Sketch > Include Libraries > Manage Libraries…

Search for Sodaq_nbIOT
Click on the bar to show the install button and install the library.

Click on File > Examples > [library name] to see more example codes.

Low power sketch

Use the following sketch to put the SODAQ SARA into sleepmode.
The board will wake every 8 seconds to do a watchdog reset.
For your understanding you can enable the led to flash every 8 seconds in the loop()

For this sketch two libraries are required.
Sodaq_wdt and Sodaq_LSM303AGR
Information about how to install can be found on this page

#include <Sodaq_wdt.h>
#include <Sodaq_LSM303AGR.h>

Sodaq_LSM303AGR accelerometer;

void setup(){

  // Bootup delay to programm the board.
  delay(5000);

  Wire.begin();// I2C for the accelerometer
  
  // Disable the LSM303AGR
  accelerometer.disableAccelerometer();
  accelerometer.disableMagnetometer();

  pinMode(LED_BUILTIN,  OUTPUT);
  pinMode(MAG_INT,  OUTPUT);
  pinMode(GPS_ENABLE,  OUTPUT);
  pinMode(SARA_ENABLE,  OUTPUT);

  digitalWrite(LED_BUILTIN, LOW);   // led low=off, high=on
  digitalWrite(MAG_INT, LOW);       // we need to make this low otherwise this pin on the LSM303AGR starts leaking current
  digitalWrite(GPS_ENABLE, LOW);    // low=poweredoff, high=poweredon
  digitalWrite(SARA_ENABLE, HIGH);  // low=poweredoff, high=poweredon 

  //this code is needed to setup watchdogtimer and to make MCU sleep
  sodaq_wdt_enable(WDT_PERIOD_8X);    // watchdog expires in ~8 seconds
  sodaq_wdt_reset();                  // restting the watchdog

  initSleep();

  SerialUSB.flush();
  SerialUSB.end();
  USBDevice.detach();
  USB->DEVICE.CTRLA.reg &= ~USB_CTRLA_ENABLE; // Disable USB
}

void loop() {
  sodaq_wdt_reset();                  // restting the watchdog
  //digitalWrite(LED_BUILTIN, HIGH);
  //sodaq_wdt_safe_delay(10);                        
  //digitalWrite(LED_BUILTIN, LOW); 

  systemSleep();                  
}

/**
 * Initializes the CPU sleep mode.
 */
void initSleep()
{
    // Set the sleep mode
    SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
}

/**
 * Powers down all devices and puts the system to deep sleep.
 */
void systemSleep()
{
 
  __WFI(); // SAMD sleep

}

The power consumption in sleep will be ~26uA.

The board will immidiately go into sleep mode, to reprogram you must double press the reset button, the led will fade blue.

Need Help?

Ask your question on our forum.