Skip to content

Passthrough

With the passthrough sketch you can send AT commands to the ublox module on the SODAQ SARA.
This example doesn’t require any additional libraries.

Arduino code

#include <Arduino.h>

//#define R4XX // Uncomment when you use the ublox R4XX module

#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

#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

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

AT Commands

R4

General R4 Commands

Remove SIM pin

Two commands, first unlock your SIM. Then remove the SIM pin. “0000” needs to be replaced by your SIM pin.

Unlock SIM.

AT+CPIN="0000"
Remove SIM pin.
AT+CLCK="SC",0,"0000"

KPN NL - LTE-M

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the LTE-M Network of KPN NL.

AT+CFUN=15
ATE0
AT+URAT=7
AT+CEREG=3
AT+CMEE=2
AT+CGDCONT=1,"IP","internet.m2m"
AT+COPS=1,2,"20408"
AT+CSQ (Wait for CSQ 99,99 means no signal)
AT+CGATT? (Wait for attach, 1 = attached)
AT+USOCR=17
AT+USOST=0,"YOURUDPSERVERIP",YOURUDPSERVERPORT,4,"Yes!"

Vodafone NL - LTE-M

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the LTE-M Network of Vodafone.

AT+CFUN=15
ATE0
AT+URAT=7
AT+CEREG=3
AT+CMEE=2
AT+CGDCONT=1,"IP","live.vodafone.com"
AT+COPS=1,2,"20404"
AT+CSQ (Wait for CSQ 99,99 means no signal)
AT+CGATT? (Wait for attach, 1 = attached)
AT+USOCR=17
AT+USOST=0,"YOURUDPSERVERIP",YOURUDPSERVERPORT,4,"Yes!"

Vodafone NL - NB-IoT

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the NB-IoT Network of Vodafone NL.

For Vodafone we have multiple APNs, use the correct APN! nb.inetd.gdsp –> default external APN dev.sodaq.com –> early access APN

AT+URAT=8
AT+URAT?
AT+CMEE=2
AT+CGDCONT=1,"IP","nb.inetd.gdsp"
AT+CGDCONT?
AT+CFUN=1
AT+COPS=1,2,"20404"
AT+CSQ
AT+CEREG=2
AT+CEREG?
AT+CGPADDR
AT+USOCR=17
AT+USOST=0,"37.97.216.22",3000,4,"Data"
AT+USOCL=0

T-Mobile NL - LTE-M

SIM APN
TMNL smartsites.t-mobile
Managed M2M m2m.public.nl

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the LTE-M Network of KPN NL.

AT+CFUN=15
ATE0
AT+URAT=7
AT+CEREG=3
AT+CMEE=2
AT+CGDCONT=1,"IP","smartsites.t-mobile"
AT+COPS=1,2,"20408"
AT+CSQ (Wait for CSQ 99,99 means no signal)
AT+CGATT? (Wait for attach, 1 = attached)
AT+USOCR=17
AT+USOST=0,"YOURUDPSERVERIP",YOURUDPSERVERPORT,4,"Yes!"

T-Mobile NL - NB-IoT

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the NB-IoT UDP Network of T-Mobile NL.

Note

Your device must be registered as a UDP device and not as CoAP.

AT+URAT=8
AT+URAT?
AT+CMEE=2
AT+CGDCONT=1,"IP","cdp.iot.t-mobile.nl"
AT+CGDCONT?
AT+CFUN=1
AT+COPS=1,2,"20416"
AT+CSQ
AT+CEREG=2
AT+CEREG?
AT+CGPADDR
AT+USOCR=17
AT+USOST=0,"172.27.131.100",15683,4,"Data"
AT+USOCL=0

Monogoto - LTE-M

After uploading the passthrough sketch use the following commands to send a message.
These commands communicate on the LTE-M Network of Vodafone.

AT+CFUN=15
ATE0
AT+URAT=7
AT+CEREG=3
AT+CMEE=2
AT+CGDCONT=1,"IP","data.mono"
Auto select operator
AT+COPS=0
If the auto operator selection doesn't work, you can force the operator
AT+COPS=1,2,"20404"
AT+CSQ (Wait for CSQ 99,99 means no signal)
AT+CGATT? (Wait for attach, 1 = attached)
AT+USOCR=17
AT+USOST=0,"YOURUDPSERVERIP",YOURUDPSERVERPORT,4,"Yes!"

N2

General N2 Commands

You can reboot to bring it into a ‘clean’ mode by:

AT+NRB

NCONFIG settings are saved into the memory of the module.
You can check if these settings

AT+NCONFIG?

You can check your IP address. This is from a private IP range.

AT+CGPADDR

Check the firmware version:

AT+CGMR
or
ATI9

Check the IMEI Number:

AT+CGSN=1

Check the CCID, SIM card number:

AT+CCID?

Vodafone NL – UDP

Setup

Give URC's of when the Sara module has communication with the base station, useful for debugging.

AT+CSCON=1
Give URC's of the netwok registration status, useful for debugging and knowing whether you have received the power save timers.
AT+CEREG=5
Give URC's whenever the module sleeps and awakens, useful for knowing whenever you want into low power.
AT+NPSMR=1
Enable power save mode, request RPTAU of 10 seconds and request RAT of 2 seconds.
AT+CPSMS=1,,,"00000001","00000001"
Note that the above values are requested, you will receive some set timers from the network after connection, look for the last two variables with CEREG URC.

Set the Following NCONFIG settings. This only have to be done once. The settings are saved in memmory.

AT+NCONFIG="CR_0354_0338_SCRAMBLING","TRUE"
AT+NCONFIG="CR_0859_SI_AVOID","FALSE"
Turn the radio off.
AT+CFUN=0
Set vodafone PDP settings.
AT+CGDCONT=1,"IP","nb.inetd.gdsp"
Turn the radio on.
AT+CFUN=1
Set band to 20 (Vodafone uses 20).
AT+NBAND=20
Toggle the radio off and on (this appears to force a refresh and works best in practice).
AT+CFUN=0
AT+CFUN=1
Connect to Vodafone.
AT+COPS=1,2,"20404"

Now make sure you actually have connection to the base station. Periodically check for base station signal strength and whether GPRS is attached.

Wait for connection

Check for signal strength, the first or second variable should not be 99.

AT+CSQ
Check for GPRS attachment, should return 1.
AT+CGATT?
For sending an UDP package you need to open a socket after having connection.

Socket

Create a socket on port 16666 for sending and receiving datagrams (UDP).

AT+NSOCR="DGRAM",17,16666,0

Now that you’re connected, transmit a message.

Transmit

Send Hello world! , immediately stop transmitting after sending the command.

AT+NSOSTF=0,"YOUR_SERVER_IP",YOUR_SERVER_PORT,0x200,12,"48656c6c6f20576f726c6421"
Make sure to enter your own ip and port!

T-Mobile NL – UDP

Setup

Give URC's of when the Sara module has communication with the base station, useful for debugging.

AT+CSCON=1
Give URC's of the netwok registration status, useful for debugging and knowing whether you have received the power save timers.
AT+CEREG=5
Give URC's whenever the module sleeps and awakens, useful for knowing whenever you want into low power.
AT+NPSMR=1

Enable power save mode, request RPTAU of 10 seconds and request RAT of 2 seconds.

AT+CPSMS=1,,,"00000001","00000001"
Note that the above values are requested, you will receive some set timers from the network after connection, look for the last two variables with CEREG URC.

Set the Following NCONFIG settings. This only have to be done once. The settings are saved in memmory.

AT+NCONFIG="CR_0354_0338_SCRAMBLING","TRUE"
AT+NCONFIG="CR_0859_SI_AVOID","FALSE"
Turn the radio off.
AT+CFUN=0
Set T-mobile PDP settings.
AT+CGDCONT=0,"IP","cdp.iot.t-mobile.nl"
Turn the radio on.
AT+CFUN=1
Set band to 8 (T-Mobile uses 8).
AT+NBAND=8
Toggle the radio off and on (this appears to force a refresh and works best in practice).
AT+CFUN=0
AT+CFUN=1
Connect to T-Mobile.
AT+COPS=1,2,"20416"
Now make sure you actually have connection to the base station. Periodically check for base station signal strength and whether GPRS is attached

Wait for connection

Check for signal strength.

AT+CSQ 
The first or second variable should not be 99. Repeat the command till you get a valid CSQ.

Check for attachment, if attached the module should return 1.

AT+CGATT?

For sending an UDP package you need to open a socket after having connection.

Socket

Create a socket on port 16666 for sending and receiving datagrams (UDP)

AT+NSOCR="DGRAM",17,16666,0
Now that you’re connected, transmit a message.

Transmit

Send Hello world! and immediately stop transmitting after sending the command.

AT+NSOSTF=0,"172.27.131.100",15683,0x200,12,"48656c6c6f20576f726c6421" 
With T-Mobile NL you always send your data to the CDP. The CDP will send the data to your north-application.

T-Mobile NL – CoAP

AT+NCONFIG="CR_0354_0338_SCRAMBLING","TRUE"
AT+NCONFIG="CR_0859_SI_AVOID","FALSE"
AT+CFUN=0
AT+NCDP="172.27.131.100"
AT+CGDCONT=0,"IP","cdp.iot.t-mobile.nl"
AT+CFUN=1
AT+NBAND=8
AT+COPS=1,2,"20416"
AT+CSQ
AT+CGATT?
AT+NSMI=1 // Send Message indicator
AT+NNMI=1 // Receive Message indicator
AT+NMGS=11,"48656c6c6f20576f726c64"