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.

Uncomment #define R4XX if you use an R4XX module.

Note

Connect a battery if you use an R412M.

#include <Arduino.h>

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

#define DEBUG_STREAM SerialUSB
#define MODEM_STREAM Serial1

#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()
{
  // Turn the power to the SARA module on.
  // we have a powerswitch on board to switch the power to the SARA on/of when needed
  // in most applications we keep the power on all the time  
  pinMode(SARA_ENABLE, OUTPUT);  
  digitalWrite(SARA_ENABLE, HIGH);

#ifdef R4XX
    // Turn the nb-iot module on
    // The R4XX module has an on/off pin. You can toggle this pin or keep it low to
    // switch on the module
    pinMode(SARA_R4XX_TOGGLE, OUTPUT);
    digitalWrite(SARA_R4XX_TOGGLE, LOW);
    delay(2000);
    pinMode(SARA_R4XX_TOGGLE, INPUT);
#endif

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

Note

Make sure in the Serial Monitor New Line and Carriage Return (NL & CR) are enabled.
The baudrate for the N211 = 9600.
The baudrate for the R41X = 115200.

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.

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Set URAT to LTE-M.
AT+URAT=7
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
AT+CGDCONT=1,"IP","internet.m2m"
Autoselect the operator.
AT+COPS=0,2
Or force select an operator, use 20408 to force KPN NL.
AT+COPS=1,2,"20408"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
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.

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Set URAT to LTE-M.
AT+URAT=7
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
AT+CGDCONT=1,"IP","live.vodafone.com"
Autoselect the operator
AT+COPS=0,2
Or force select an operator, use 20404 to force Vodafone NL
AT+COPS=1,2,"20404"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
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

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Check current URAT.
AT+URAT?
Set URAT to NB-IoT.
AT+URAT=8
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
AT+CGDCONT=1,"IP","nb.inetd.gdsp"
Check used APN.
AT+CGDCONT?
Turn on the radio.
AT+CFUN=1
Autoselect the operator
AT+COPS=0,2
Or force select an operator, use 20404 to force Vodafone NL
AT+COPS=1,2,"20404"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
AT+USOST=0,"YOURUDPSERVERIP",YOURUDPSERVERPORT,4,"Yes!"

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.

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Set URAT to LTE-M.
AT+URAT=7
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
AT+CGDCONT=1,"IP","smartsites.t-mobile"
Autoselect the operator.
AT+COPS=0,2
Or force select an operator, use 20416 to force T-Mobile NL.
AT+COPS=1,2,"20416"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
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.

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Check current URAT.
AT+URAT?
Set URAT to NB-IoT.
AT+URAT=8
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
AT+CGDCONT=1,"IP","cdp.iot.t-mobile.nl"
Check current APN.
AT+CGDCONT?
Turn on radio.
AT+CFUN=1
Autoselect the operator
AT+COPS=0,2
Or force select an operator, use 20416 to force T-Mobile NL
AT+COPS=1,2,"20416"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
AT+USOST=0,"172.27.131.100",15683,4,"Data"
Close socket.
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.

Reset the module.

AT+CFUN=15
Turn off echo.
ATE0
Check selected MNO Profile.
AT+UMNOPROF?
Set MNO profile. (1=automatic,100=standard europe)
AT+UMNOPROF=1
Set URAT to LTE-M.
AT+URAT=7
Enable URCs.
AT+CEREG=3
Set verbose error values.
AT+CMEE=2
Set the APN.
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"
Check Siganl strenght, repeat till you have a valid CSQ (99,99 means no signal).
AT+CSQ
Wait for attach, 1 = attached.
AT+CGATT? 
Open a socket.
AT+USOCR=17
Send data over the socket.
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"