ModularSensors > Modules > Supported Modems and Communication Modules > Sodaq UBee's and other u-blox modules > Sodaq UBee LTE-M and other u-blox LTE-M Modules

Sodaq UBee LTE-M and other u-blox LTE-M Modules module

Introduction

There are a multitude of boards available that feature a variant of the u-blox SARA R4 series, including a Sodaq UBee.

The default baud rate for the SARA R410M is 115200. It DOES NOT save baud rate to non-volatile memory. After every power loss, the module will return to the default baud rate of 115200. This library attempts to compensate by sending a baud rate change command in the wake function. Because of this, 8MHz boards, LIKE THE MAYFLY, MUST use a HardwareSerial instance as modemSerial. This requirement does not exist for 16MHz (and faster) boards. For those, any Stream instance may be used.

Power draw is just about 500mA. A larger supply is (strongly) preferred.

Manufacturer Documentation

The module datasheet and AT commands for the SARA R4 series are available here: https://www.u-blox.com/en/product/sara-r4-series The schematics for the UBee are available here: https://support.sodaq.com/Shields_and_Bees/ubee/

Modem Constructor

SodaqUBeeR410M(HardwareSerial* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char* apn)

Construct a new Sodaq UBee R410M object.

Parameters
modemStream The Arduino stream instance for serial communication.
powerPin The digital pin number of the mcu pin controlling power to the modem (active HIGH).
statusPin The digital pin number of the mcu pin connected to the modem status output pin.
modemResetPin The digital pin number of the pin on the mcu attached the the hard or panic reset pin of the modem.
modemSleepRqPin The digital pin number of a pin on the mcu used to request the modem enter its lowest possible power state.
apn The Access Point Name (APN) for the SIM card.

The constuctor initializes all of the provided member variables, constructs a loggerModem parent class with the appropriate timing for the module, calls the constructor for a TinyGSM modem on the provided modemStream, and creates a TinyGSM Client linked to the modem.

Should be set to a negative number if the modem should be continuously powered or the power cannot be controlled by the MCU. For the Sodaq UBee, this is the pin labeled ON/OFF; pin 9 on the bee socket. The fact that this pin controls the power to the u-blox module is not clear in the Sodaq documentation.

Should be set to a negative number if the modem status pin cannot be read. This is the pin labeled V_INT in the u-blox integration guide. It is (misleadingly) called CTS in some of the Sodaq UBee documentation because Sodaq wired the V_INT from the u-blox to the pin usually reserved for CTS on the bee socket.

Should be set to a negative number if the modem reset pin is not connected to the MCU. This is the pin labeled RESET_N in both u-blox and Sodaq documentation.

Should be set to a negative number if there is no pin usable for deep sleep modes or it is not accessible to the MCU. This is the pin labeled PWR_ON in both u-blox and Sodaq documentation.



Example Code

Creating the Modem Object

The SARA R410M based UBee is used in the menu a la carte example.

// For the Sodaq UBee based on the 4G LTE-M u-blox SARA R410M
#include <modems/SodaqUBeeR410M.h>

// NOTE: Extra hardware and software serial ports are created in the "Settings
// for Additional Serial Ports" section
const int32_t modemBaud =
    115200;  // Default baud rate of the SARA R410M is 115200
// NOTE:  The SARA R410N DOES NOT save baud rate to non-volatile memory.  After
// every power loss, the module will return to the default baud rate of 115200.
// NOTE:  115200 is TOO FAST for an 8MHz Arduino.  This library attempts to
// compensate by sending a baud rate change command in the wake function when
// compiled for a 8MHz board. Because of this, 8MHz boards, LIKE THE MAYFLY,
// *MUST* use a HardwareSerial instance as modemSerial.

// Modem Pins - Describe the physical pin connection of your modem to your board
// NOTE:  Use -1 for pins that do not apply
// Example pins are for a Sodaq uBee R410M with a Mayfly 0.x
const int8_t modemVccPin     = 23;  // MCU pin controlling modem power
const int8_t modemStatusPin  = 19;  // MCU pin used to read modem status
const int8_t modemResetPin   = -1;  // MCU pin connected to modem reset pin
const int8_t modemSleepRqPin = 20;  // MCU pin for modem sleep/wake request
const int8_t modemLEDPin = redLED;  // MCU pin connected an LED to show modem
                                    // status

// Network connection information
const char* apn = "xxxxx";  // APN for GPRS connection

// Create the modem object
SodaqUBeeR410M modemR410(&modemSerial, modemVccPin, modemStatusPin,
                         modemResetPin, modemSleepRqPin, apn);
// Create an extra reference to the modem by a generic name
SodaqUBeeR410M modem = modemR410;

LTE Network Selection

It is good practice to select which network you'll be connecting to based on your SIM card and signal availability. Example code for this can also be found in the menu a la carte example.

    // Extra modem set-up
    Serial.println(F("Waking modem and setting Cellular Carrier Options..."));
    modem.modemWake();  // NOTE:  This will also set up the modem
    // Turn off the cellular radio while making network changes
    modem.gsmModem.sendAT(GF("+CFUN=0"));
    modem.gsmModem.waitResponse();
    // Mobile Network Operator Profile - 0 = SW default
    //                                 - 1 = SIM ICCID selected
    //                                 - 2: ATT
    //                                 - 6: China Telecom
    //                                 - 100: Standard Europe
    //                                 - 4: Telstra
    //                                 - 5: T-Mobile US
    //                                 - 19: Vodafone
    //                                 - 3: Verizon
    //                                 - 31: Deutsche Telekom
    modem.gsmModem.sendAT(GF("+UMNOPROF="), 2);
    modem.gsmModem.waitResponse();
    // Selected network technology - 7: LTE Cat.M1
    //                             - 8: LTE Cat.NB1
    // Fallback network technology - 7: LTE Cat.M1
    //                              - 8: LTE Cat.NB1
    // NOTE:  As of 2020 in the USA, AT&T and Verizon only use LTE-M
    // T-Mobile uses NB-IOT
    modem.gsmModem.sendAT(GF("+URAT="), 7, ',', 8);
    modem.gsmModem.waitResponse();
    // Restart the module to apply changes
    modem.gsmModem.sendAT(GF("+CFUN=1,1"));
    modem.gsmModem.waitResponse(10000L);

Classes

class SodaqUBeeR410M
The loggerModem subclass for the LTE-M Sodaq UBee based on the u-blox SARA R410M LTE-M cellular module. This can be also used for any other breakout of the the u-blox R4 or N4 series modules.

Defines

#define TINY_GSM_MODEM_SARAR4
The modem type for the underlying TinyGSM library.
#define R410M_STATUS_LEVEL = HIGH
The loggerModem::_statusLevel.

V_INT on the SARA R4 becomes active mid-way through on-pulse so it should be instantly visible

Status should be monitored on the V_INT pin

#define R410M_STATUS_TIME_MS = 0
The loggerModem::_statusTime_ms.

V_INT on the SARA R4 becomes active mid-way through on-pulse so it should be instantly visible

Status should be monitored on the V_INT pin

#define R410M_RESET_LEVEL = LOW
The loggerModem::_resetLevel.

R4 series are reset with a >10 SECOND low pulse on the RESET_N pin

#define R410M_RESET_PULSE_MS = 10000L
The loggerModem::_resetPulse_ms.

R4 series are reset with a >10 SECOND low pulse on the RESET_N pin

#define R410M_WAKE_LEVEL = LOW
The loggerModem::_wakeLevel.

The SARA R410M is switched on by a 0.15-3.2 second LOW pulse on the PWR_ON pin

#define R410M_WAKE_PULSE_MS = 200
The loggerModem::_wakePulse_ms.

The SARA R410M is switched on by a 0.15-3.2 second LOW pulse on the PWR_ON pin

#define R410M_WAKE_DELAY_MS = 250
The loggerModem::_wakeDelayTime_ms.

Time after power on before PWR_ON on SARA R4 can be used is nclear in documentation! Using 250ms.

#define R410M_ATRESPONSE_TIME_MS = 4500L
The loggerModem::_max_atresponse_time_ms.

Time until system and digital pins on SARA R4 are operational is ~4.5s.

#define R410M_DISCONNECT_TIME_MS = 15000L
The loggerModem::_disconnetTime_ms.

Power down time for u-blox modules _"can largely vary depending on the application / network settings and the concurrent module activities."_ The V_INT pin should be monitored and power not withdrawn until that pin reads low. We allow up to 15 seconds for shutdown in case it is not monitored.