This guide is a simple walk-through of how to get started with communication with the module directly from your computer without the use of a microcontroller. The same commands can of course be called from a microcontroller instead, so with this knowledge you can implement a library for the EE-NBIOT-01 for any microcontroller in any language you prefer.
Here is a brief guide on what you need and how to set up the serial communication with the EE-NBIOT-01. If you need more details, SparkFun has an excellent in depth guide on Serial Terminal Basics.
The communication to the u-blox SARA-N210 is just a simple serial connection with text commands. Modern computers don’t have a serial port any more, so you need a special USB cable to connect the serial pins (RX/TX) of the EE-NBIOT-01 board to your computer. These cables are often called FTDI, UART, or TTL cables.
The SARA-N210 RX/TX pins require 3.3V. The absolute max in the SARA-N210 datasheet is 4.25V; more may lead to damaging the SARA-N210 module. So make sure you get a cable that has 3.3V logic for RX/TX.
Regarding power, the EE-NBIOT-01 has a buck voltage regulator that can handle 1.8V-5.5V input, so it’s fine if the USB to serial adapter has 5V VCC.
Here are a few suggestions for adapters:
In Norway you should be able to find them in any of these stores:
Most cables require you to install a driver for the USB serial adapter. Check the product description and it should guide you to the correct driver for your operating system.
You can use any serial terminal application you like. We’ll only explain how to use CoolTerm in this guide - since it’s free, easy to use and works on Windows, macOS and Linux.
/dev/ttyUSB0if you use a USB to serial adapter or
/dev/ttyAMA0on the Raspberry Pi.
Set the baud rate to 9600
Leave the rest of the options as default and click «OK»
Normally on a serial connection, the TX is the output from one device and RX is the input. So when you connect two devices, you would connect TX->RX both ways. However, u-blox thought otherwise, so they’ve labled the input as TX and output as RX. To avoid an extra layer of confusion we used the same labeling as u-blox on the EE-NBIOT-01. So when connecting the wires - connect RX to RX and TX to TX.
NB! Make sure the cable has 5V to 3.3V logic level conversion on RX&TX
|VCC +5V/3.3V - red||VCC|
|GND - black||GND|
|RX - yellow||RXD|
|TX (3.3V) - orange||TXD|
You control the u-blox SARA-N210 by sending it AT-commands over the serial connection. The response will be prefixed with
> to indicate it’s a response and not something you should write in the terminal.
We need to set the APN so that our devices’ upstream messages are forwarded correctly and so that our devices are assigned IP addresses to which can send downstream messages.
Before changing the config we must disable auto-connect because we don’t want the device to start connecting while we’re modifying the config. Then we need to reboot before the changes will take effect.
AT+NCONFIG="AUTOCONNECT","FALSE";+NRB > OK ... > REBOOT_CAUSE_APPLICATION_AT > u-blox > OK
Now we’re ready to update the config. It’s not persisted on the SARA-N210, so remember to run this after every reboot:
AT+CFUN=1;+COPS=1,2,"24201";+CGDCONT=1,"IP","mda.ee";+CGACT=1,1 > OK > OK > OK > OK
If you haven’t registered the devie in the Telenor NB-IoT Developer Platform yet, now is a good time. You’ll need the IMSI and IMEI:
AT+CIMI;+CGSN=1; > <IMSI number> > OK > +CGSN: <IMEI number> > OK
Save these numbers and follow the getting started guide to add the device, so you’ll be able to watch the incoming data that you’re about to send in the next section.
Check if we are registered on the network yet?:
AT+CEREG? > +CEREG: 0,2
The seccond response value (
2) is the registration status. Status
2 is not registered, but it’s currently trying to attach or searching for an operator to register to.
Wait a few seconds and try again:
AT+CEREG? > +CEREG: 0,1
Now the registration status is
1, which means it’s registered to the home network.
Then open a new UDP socket. If successful, the first line of the response will be the socket number. You need the socket number later when sending data.
AT+NSOCR="DGRAM",17,30000,1 > 0 > OK
Now socket 0 is ready to send UDP data to a server. The APN we configured earlier will forward data from devices in the Telenor network to your application server.
AT+NSOST=0,"172.16.15.14",1234,12,"48656C6C6F20576F726C6421" > 0,12 > OK
The first response line is
<sent_length>, followed by OK if it was successful.
To close socket 0:
This is just a summary of the commands we find the most useful. For the complete list, download the u-blox «SARA-N2 AT Commands» PDF from the u-blox website instead.
Most commands have 3 syntaxes. Read (
COMMAND?), set (
COMMAND=...) and test (
COMMAND=?). Test will list possible values for all arguments.
0**: Disable the radio
1**: Enable the radio
|Request the IMEI (International Mobile Equipment Identity).|
|Request the IMSI (International Mobile Subscriber Identity).|
||OK||Force an attempt to select and register with the network operator. Through
0**: (default) automatic
2**: deregister from network
||OK||Attach or detach to/from the mobile network. Allowed
0**: Detach from network
1**: Attach to network
|Check if GPRS attached||
|Check if SARA-N210 is attached to the mobile network or not.
0**: Detached from network
1**: Attached to network
|Network registration status||
|This command has 6 different modes, each of which gives different return values. Response is
0**: not registered, the MT is not currently searching an operator to register to
1: registered, home network
2: not registered,but the MT is currently trying to attach or searching an operator to register to
3: registration denied
4: unknown (e.g. out of E-UTRAN coverage)
5: registered, roaming
8**: attached for emergency bearer services only
|Check signal strength||
|Request signalpower_ and qual. On the SARA-N210, qual will always be 99. The mapping between signalpower_ and RSSI dBm is
RSSI = (
|Create a socket. If a port is set, receiving is enabled and +NSONMI URC will appear for any message that is received on that port. Max number of ports: 7.
Port range: 0-65535 except for 5683.
0**: incoming messages will be ignored
1: (default) incoming messages will trigger a +NSONMI URC
Response**: Socket identifier to be referenced by the other socket AT commands
|Send UDP to IP||
|Send a UDP datagram to the specified host and port. See Table 3 for parameter descriptions.|
|Send UDP to IP with flags||
|Send a UDP datagram to the specified host and port with flags. Needed for power saving mode. See Table 3 for parameter descriptions.|
|Error report formatting||
||OK||Configure formatting of errors. List of supported
1**: +CME ERROR:
See Appendix A in the «SARA-N2 AT Commands» documentation for error result code descriptions.
||OK||Configure customizable aspects of the SARA-N210 (e.g Auto Attach). The changes are effective after the module reboot by means of the
|PDP context definition||
||OK||Define the connection parameters for a PDP context. Usually to configure APN settings manually. See example further up.|
|Request the most recent operational statistics of the module. Should be called right after sending. Some interesting values: TX power, ECL (equipment coverage class), throughput, bytes received, bytes sent, cell info. See chapter 4.8 in «SARA-N2 AT Commands» for full description of all fields and available
|Reboot the SARA-N210. There is a short delay after the command issuing before the SARA-N210 reboots.|
|Power saving mode settings||
||OK||Enable and configure the power saving mode. See own low power tutorial for full details and examples.|
||OK||Configure extended discontinuous reception (eDRX) parameters. See own low power tutorial for full details and examples.|
|Get network time/clock||AT+CCLK?||
|Fetches the network time/clock.|
¹ - Simplified syntax. See «SARA-N2 AT Commands» for full syntax.
Table 3: AT+NSOST parameters (from SARA-N2 AT Commands documentation)
|socket||Number||Socket identifier returned by
|remote IP address||String||Remote host IP address of the remote host in IPv4 format. IP addresses can be specified in decimal, octal or hexadecimal notation.|
|remote port||Number||A number in the range 0-65535. Remote port the messages will be received on.|
|length||Number||Size of the data to send. The maximum length 512 bytes.|
|data||String||Data to be sent (as a hexadecimal string)|
|flags (for NSOSTF)||Number||Specifies the type of message transmission in hexadecimal format. Values of this argument are formed by logically OR’ing zero or more of the following flags:
• 0x000: no flags are set
• 0x100: exception message. Send message with high priority
• 0x200: release indicator. Indicate release after next message
• 0x400: release indicator. Indicate release after next message has been replied to