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

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::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.

1// For the Sodaq UBee based on the 4G LTE-M u-blox SARA R410M
2#include <modems/SodaqUBeeR410M.h>
3
4// NOTE: Extra hardware and software serial ports are created in the "Settings
5// for Additional Serial Ports" section
6const int32_t modemBaud =
7 115200; // Default baud rate of the SARA R410M is 115200
8// NOTE: The SARA R410N DOES NOT save baud rate to non-volatile memory. After
9// every power loss, the module will return to the default baud rate of 115200.
10// NOTE: 115200 is TOO FAST for an 8MHz Arduino. This library attempts to
11// compensate by sending a baud rate change command in the wake function when
12// compiled for a 8MHz board. Because of this, 8MHz boards, LIKE THE MAYFLY,
13// *MUST* use a HardwareSerial instance as modemSerial.
14
15// Modem Pins - Describe the physical pin connection of your modem to your board
16// NOTE: Use -1 for pins that do not apply
17// Example pins are for a Sodaq uBee R410M with a Mayfly 0.x
18const int8_t modemVccPin = 23; // MCU pin controlling modem power
19const int8_t modemStatusPin = 19; // MCU pin used to read modem status
20const int8_t modemResetPin = -1; // MCU pin connected to modem reset pin
21const int8_t modemSleepRqPin = 20; // MCU pin for modem sleep/wake request
22const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem
23 // status
24
25// Network connection information
26const char* apn = "xxxxx"; // APN for GPRS connection
27
28// Create the modem object
29SodaqUBeeR410M modemR410(&modemSerial, modemVccPin, modemStatusPin,
30 modemResetPin, modemSleepRqPin, apn);
31// Create an extra reference to the modem by a generic name
32SodaqUBeeR410M 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.

1 // Extra modem set-up
2 Serial.println(F("Waking modem and setting Cellular Carrier Options..."));
3 modem.modemWake(); // NOTE: This will also set up the modem
4 // Turn off the cellular radio while making network changes
5 modem.gsmModem.sendAT(GF("+CFUN=0"));
6 modem.gsmModem.waitResponse();
7 // Mobile Network Operator Profile - 0 = SW default
8 // - 1 = SIM ICCID selected
9 // - 2: ATT
10 // - 6: China Telecom
11 // - 100: Standard Europe
12 // - 4: Telstra
13 // - 5: T-Mobile US
14 // - 19: Vodafone
15 // - 3: Verizon
16 // - 31: Deutsche Telekom
17 modem.gsmModem.sendAT(GF("+UMNOPROF="), 2);
18 modem.gsmModem.waitResponse();
19 // Selected network technology - 7: LTE Cat.M1
20 // - 8: LTE Cat.NB1
21 // Fallback network technology - 7: LTE Cat.M1
22 // - 8: LTE Cat.NB1
23 // NOTE: As of 2020 in the USA, AT&T and Verizon only use LTE-M
24 // T-Mobile uses NB-IOT
25 modem.gsmModem.sendAT(GF("+URAT="), 7, ',', 8);
26 modem.gsmModem.waitResponse();
27 // Restart the module to apply changes
28 modem.gsmModem.sendAT(GF("+CFUN=1,1"));
29 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.

Modem Pin Settings and Timing

The timing and pin level settings for a Sodaq UBee R410M

#define R410M_STATUS_LEVEL = HIGH
The loggerModem::_statusLevel.
#define R410M_STATUS_TIME_MS = 0
The loggerModem::_statusTime_ms.
#define R410M_RESET_LEVEL = LOW
The loggerModem::_resetLevel.
#define R410M_RESET_PULSE_MS = 10000L
The loggerModem::_resetPulse_ms.
#define R410M_WAKE_LEVEL = LOW
The loggerModem::_wakeLevel.
#define R410M_WAKE_PULSE_MS = 200
The loggerModem::_wakePulse_ms.
#define R410M_WAKE_DELAY_MS = 250
The loggerModem::_wakeDelayTime_ms.
#define R410M_ATRESPONSE_TIME_MS = 4500L
The loggerModem::_max_atresponse_time_ms.
#define R410M_DISCONNECT_TIME_MS = 15000L
The loggerModem::_disconnetTime_ms.

Define documentation

#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.