Library for the SODAQ SARA (rev.1) standalone Arduino board (not shield)

Hello,

Does the new library “Sodaq_nbIOT” @ https://github.com/SodaqMoja/Sodaq_nbIOT
(version 1.5.0) support the SARA standalone board (the Arduino compatible board,
not the add-on shield)?

The board has the commercial (02X-00) ublox N211 module with the latest firmware.

We are trying to develop a handheld NB signal strength measurement and testing device,
and doing it with back-and-forth AT commands to the module is kind of tedious.

Also a library for the included SAM-M8Q-0-10 GPS module would be nice to have.

Thank you.

@billgeo

The library Sodaq_nbIOT works for the shield and also for the sara board.
The GPS library can be found here:

Thanks for the prompt reply,
Is there a complete “Readme” file that explains all the functions?
I can’t seem to find it unfortunately.

For example is there a function that returns the RSSI value as an integer?

Also, is the EVA7M library compatible with the SAM-M8Q module?

Is there any example for the usage of the getRSSIAndBER function?
Thanks…

Any thought for how to properly use the nbiot.getRSSIAndBER function and store the RSSI value as an integer??

@billgeo

int8_t _rssi;
uint8_t _ber;
nbiot.getRSSIAndBER(&_rssi, &_ber);

Best regards,
Jan

Hello Jan

Thanks for the reply.

I implemented the code to my project and it finally compiles OK,
but now the problem is that I get only zeros as output.

Here is me code.
For now I am just trying to print the RSSI value on an LCD, nothing too complex to begin with.


// ----------------------------------------------------------------------------
// NB IoT - NB IoT Signal Meter
// Created by Bill Georgoulakis 10/07/2018
// billgeoz@gmail.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include <Arduino.h>
#include <Sodaq_AT_Device.h>
#include <Sodaq_nbIOT.h>
#include <Sodaq_wdt.h>

#if defined(ARDUINO_SODAQ_SARA)
// SODAQ SARA
#define DEBUG_STREAM SerialUSB  // Define Serial on USB port
#define MODEM_STREAM Serial1   // Define Serial to NB module - serial1 = pins: Ain5, Ain6 (RX, TX) on board.
#define powerPin SARA_ENABLE
#define enablePin SARA_TX_ENABLE
#else
#error "Please select the SODAQ SARA as your board"
#endif

unsigned long baud = 9600;

//hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd(0x20); // specify a specific i2c address

#define DEBUG_STREAM_BAUD 9600
#define STARTUP_DELAY 5000

Sodaq_nbIOT nbiot;

void setup()
{

// ---------  LCD setup   ---------
  const int LCD_COLS = 20;
  const int LCD_ROWS = 4;
  int status;
	status = lcd.begin(LCD_COLS, LCD_ROWS);
	if(status) // non zero status means it was unsuccesful
	{status = -status; // convert negative status value to positive number
	// begin() failed so blink error code using the onboard LED if possible
	hd44780::fatalError(status); // does not return} 
	}

	lcd.clear(); 
  delay(500);
  
// ------ Initialize NB-IoT module on the board ------

  #ifdef powerPin
  // Turn the nb-iot module on
  pinMode(SARA_ENABLE, OUTPUT); 
  pinMode(SARA_TX_ENABLE, OUTPUT);
  digitalWrite(SARA_ENABLE, HIGH);       // enable power to ublox
  digitalWrite(SARA_TX_ENABLE, HIGH);  
  nbiot.init(MODEM_STREAM, powerPin);   
  nbiot.setDiag(DEBUG_STREAM); 
  #endif //powerPin

  // Start serial communications (to ublox module and USB-debug)
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
  delay(3000);
  
// ------ Sent initial setup AT Commands to the NB module
  MODEM_STREAM.println("AT+NRB");
  delay(8000);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0354_0338_SCRAMBLING\",\"TRUE\"");
  delay(900);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0859_SI_AVOID\",\"TRUE\"");
  delay(900);
  MODEM_STREAM.println("AT+CFUN=0");
  delay(700);
  MODEM_STREAM.println("AT+NBAND=20");
  delay(700);
  MODEM_STREAM.println("AT+CFUN=1");
  delay(2500);
  MODEM_STREAM.println("AT+COPS=1,2,\"20201\"");
  delay(900);
  MODEM_STREAM.println("AT+CEREG=1");
  delay(900);

  nbiot.setDiag(DEBUG_STREAM);

  //clear UBLOX buffer
  while (MODEM_STREAM.available()) {
  MODEM_STREAM.read();
  }
  
}

void loop() 

{

  int8_t _rssi;
  uint8_t _ber;
  nbiot.getRSSIAndBER(&_rssi, &_ber);

  lcd.setCursor(0, 2);
  lcd.print(_rssi);
  lcd.setCursor(0, 3);
  lcd.print(_ber);

  DEBUG_STREAM.println(_rssi);
  DEBUG_STREAM.println(_ber);
  
  delay(200);
  
}     
    

When I use the pass-through sketch and input those same AT commands manually,
the uBlox module connects to the NB cellular network and using the CSQ command
I get a normal RSSI value as the response.

Any help would be greatly appreciated.

Also, as a workaround, if I could send manual AT commands (AT+CSQ) and then somehow store the RSSI value reply as a variable, that would be OK too.

Any input on this would be very helpful to my project… thanks!

Is this the right code to get RSSI and BER values and display them?

  int8_t _rssi;
  uint8_t _ber;
  nbiot.getRSSIAndBER(&_rssi, &_ber);

  DEBUG_STREAM.println(_rssi);
  DEBUG_STREAM.println(_ber);
  delay(1000);

Because when I upload the sketch the code seem to get ‘stuck’ on the getRSSIAndBER line and goes no further.

This is the whole code:

// ----------------------------------------------------------------------------
// NB IoT - NB IoT Signal Meter
// Created by Bill Georgoulakis 10/09/2018
// billgeoz@gmail.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include <Arduino.h>
//#include <Sodaq_AT_Device.h>
#include <Sodaq_nbIOT.h>
#include <Sodaq_wdt.h>

#if defined(ARDUINO_SODAQ_SARA)
// ---SODAQ SARA----
#define DEBUG_STREAM SerialUSB  // Define Serial on USB port
#define MODEM_STREAM Serial1   // Define Serial to NB module - serial1 = pins: Ain5, Ain6 (RX, TX) on board.
#define powerPin SARA_ENABLE
#define enablePin SARA_TX_ENABLE
#else
#error "Please select the SODAQ SARA as your board"
#endif

unsigned long baud = 9600;

//hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd(0x20); // specify a specific i2c address

#define DEBUG_STREAM_BAUD 9600
#define STARTUP_DELAY 5000

Sodaq_nbIOT nbiot;

void setup()
{
// ---------  LCD setup   ---------
  const int LCD_COLS = 20;
  const int LCD_ROWS = 4;
  int status;
	status = lcd.begin(LCD_COLS, LCD_ROWS);
	if(status) // non zero status means it was unsuccesful
	{status = -status; // convert negative status value to positive number
	// begin() failed so blink error code using the onboard LED if possible
	hd44780::fatalError(status); // does not return} 
	}

	lcd.clear(); 
  delay(500);
  
// ------ Initialize NB-IoT module on the board ------

 sodaq_wdt_safe_delay(STARTUP_DELAY);

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

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

  // Start serial communications (to ublox module and USB-debug)
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
  delay(1000);
  
// ------ Sent initial setup AT Commands to the NB module
  MODEM_STREAM.println("AT+NRB");
  delay(9000);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0354_0338_SCRAMBLING\",\"TRUE\"");
  delay(1100);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0859_SI_AVOID\",\"TRUE\"");
  delay(1000);
  MODEM_STREAM.println("AT+CFUN=0");
  delay(800);
  MODEM_STREAM.println("AT+NBAND=20");
  delay(800);
  MODEM_STREAM.println("AT+CFUN=1");
  delay(3300);
  MODEM_STREAM.println("AT+COPS=1,2,\"20201\"");
  delay(1000);
  MODEM_STREAM.println("AT+CEREG=1");
  delay(1100);

  //clear UBLOX buffer
  while (MODEM_STREAM.available()) {
    MODEM_STREAM.read();
   }
  
}

void loop() 
{

  int8_t _rssi;
  uint8_t _ber;
  
 nbiot.getRSSIAndBER(&_rssi, &_ber);
 
 lcd.setCursor(0, 2);
 lcd.print("RSSI: ");
 lcd.print(_rssi);
 lcd.setCursor(0, 3);
 lcd.print("BER: ");
 lcd.print(_ber);

 DEBUG_STREAM.println(_rssi);
 DEBUG_STREAM.println(_ber);
 delay(1000);
 }

Hello Jan,

I am having trouble while trying to store and display BER and RSSI values from the module using the library.

I only get zero (“0”) as out put. I used your recommended code.

 int8_t _rssi;
 uint8_t _ber;
 nbiot.getRSSIAndBER(&_rssi, &_ber);
 lcd.setCursor(0, 2);
 lcd.print(_rssi);
 lcd.setCursor(0, 3);
 lcd.print(_ber);
 DEBUG_STREAM.println(_rssi);
 DEBUG_STREAM.println(_ber);
 delay(200);

This is the whole code:

// ----------------------------------------------------------------------------
// NB IoT - NB IoT Signal Meter
// Created by Bill Georgoulakis 10/09/2018
// billgeoz@gmail.com
//
// This example code is unlicensed and is released into the public domain
// ----------------------------------------------------------------------------

#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header
#include <Arduino.h>
//#include <Sodaq_AT_Device.h>
#include <Sodaq_nbIOT.h>
#include <Sodaq_wdt.h>

#if defined(ARDUINO_SODAQ_SARA)
// ---SODAQ SARA----
#define DEBUG_STREAM SerialUSB  // Define Serial on USB port
#define MODEM_STREAM Serial1   // Define Serial to NB module - serial1 = pins: Ain5, Ain6 (RX, TX) on board.
#define powerPin SARA_ENABLE
#define enablePin SARA_TX_ENABLE
#else
#error "Please select the SODAQ SARA as your board"
#endif

unsigned long baud = 9600;

//hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip
hd44780_I2Cexp lcd(0x20); // specify a specific i2c address

#define DEBUG_STREAM_BAUD 9600
#define STARTUP_DELAY 8000

Sodaq_nbIOT nbiot;

void setup()
{
// ---------  LCD setup   ---------
  const int LCD_COLS = 20;
  const int LCD_ROWS = 4;
  int status;
  status = lcd.begin(LCD_COLS, LCD_ROWS);
  if(status) // non zero status means it was unsuccesful
  {status = -status; // convert negative status value to positive number
  // begin() failed so blink error code using the onboard LED if possible
  hd44780::fatalError(status); // does not return} 
  }

  lcd.clear(); 
  delay(500);
  
// ------ Initialize NB-IoT module on the board ------

 sodaq_wdt_safe_delay(STARTUP_DELAY);

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

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

 nbiot.init(MODEM_STREAM, powerPin);

// ------- Start serial communications (to ublox module and USB-debug)
  DEBUG_STREAM.begin(baud);
  MODEM_STREAM.begin(baud);
  delay(1000);
  
// ------ Sent initial setup AT Commands to the NB module
  MODEM_STREAM.println("AT+NRB");
  delay(8500);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0354_0338_SCRAMBLING\",\"TRUE\"");
  delay(1100);
  MODEM_STREAM.println("AT+NCONFIG=\"CR_0859_SI_AVOID\",\"TRUE\"");
  delay(1000);
  MODEM_STREAM.println("AT+CFUN=0");
  delay(900);
  MODEM_STREAM.println("AT+NBAND=20");
  delay(900);
  MODEM_STREAM.println("AT+CFUN=1");
  delay(3300);
  MODEM_STREAM.println("AT+COPS=1,2,\"20201\"");
  delay(1100);
  MODEM_STREAM.println("AT+CEREG=1");
  delay(1100);

  //clear UBLOX buffer
  while (MODEM_STREAM.available()) {
    MODEM_STREAM.read();
   }
  
}

void loop() 
{

  int8_t _rssi;
  uint8_t _ber;
  
 nbiot.getRSSIAndBER(&_rssi, &_ber);
 
 lcd.setCursor(0, 2);
 lcd.print("RSSI: ");
 lcd.print(_rssi);
 lcd.setCursor(0, 3);
 lcd.print("BER: ");
 lcd.print(_ber);

 DEBUG_STREAM.println(_rssi);
 DEBUG_STREAM.println(_ber);
 delay(1000);
 }

The code compiles. The board returns RSSI values when I upload the serial-passthrough and I enter AT+CSQ manually.
Do you think there is a problem with the code, the board?