Nordic Thingy:91

Introduction


The Nordic Thingy:91 is an easy-to-use battery-operated prototyping platform for cellular IoT using LTE-M, NB-IoT and GPS. It is ideal for creating Proof-of-Concept (PoC), demos and initial prototypes in your cIoT development phase.
The nRF9160 from Nordic Semiconductor is a compact, highly-integrated System-in-Package (SiP) that makes the latest low power LTE technology and advanced processing and security accessible, and easy to use, for a wide range of single device low power cellular IoT (cIoT) designs. There is even an application controller available in the SiP. Development Kits or reference designs like the Thingy:91 come with a preprogrammed asset tracker application. However, for first evaluations an AT command interface would be more interesting. In this article we cover how to reprogram the nRF9160 with a Serial-LTE-Modem software and explain the first steps to prepare it for LTE-M or NB-IoT. You will also learn how to communicate via UDP with the Thingy:91.

Nordic Thingy:91Nordic Thingy:91

Nordic Thingy:91

Links*

Links to the AT command samples:

Setup the Device


Updating Thingy’s Application Firmware

First, we have to replace the application firmware on the nRF9160 by the Serial-LTE-Modem firmware. This is done as follow:

  • Install nRF Connect for Desktop on your computer.
    The installation file is available here.

  • nRF Connect for Desktop should start automatically after installation. This tool gives you access to several other tools. The Programmer and LTE Monitor are the important tools for us. Please click the INSTALL button for these tools.

  • Now we should download the Serial-LTE-Modem firmware from Nordic’s webpage. You find the Precompiled application and modem firmware here
    Select the latest version and click on the thingy91fw... file name.

  • Extract the downloaded zip file.

  • Now we have to download two firmware images to the Thingy91, the modem firmware and the application firmware.

  • Modem firmware update:
    Please look for the Programming the modem through USB (MCUboot) section on this webpage and follow the steps to update the modem. *Note that the modem firmware is included in the file we have downloaded and extracted in the previous steps.
  • The next chapter on the website is Programming Applications through USB (MCUboot). Please follow these steps and select the file imgapp_bl/serial_lte_modem... .hex.

Now your Thinkgy:91 is acting as a Serial LTE Modem and you can send commands via a virtual COM port to the device.

Execute AT Commands

Please put in the SIM card before switching on the Thingy:91. Connect your Thingy:91 via USB to your computer and switch it on.
We could now use a standard terminal program for serial communication. Our standard settings here would be 115200 baudrate, 8 data bits, 1 stop bit, no parity, no flow control.
However, an easier way is to use the LTE Monitor tool that is available in nRF Connect for Desktop.

After starting the LTE Monitor you must connect to the Thingy. This is done by choosing the PCA20035 board in the dropdown list, as shown in this picture:

LTE Monitor: dropdown listLTE Monitor: dropdown list

LTE Monitor: dropdown list

Enter in the text box that states: "Type AT command here…" the command AT and press enter. The terminal program shows the message you have sent and an answer from the Thingy:91.

The Thingy:91 board replies with “OK”. This means, firmware update was successfully done and the Serial LTE Modem firmware is running. Now we can continue to configure the device and attached to the network.

Attach to NB-IoT Network


This chapter explains how you can attach your Thngy:91 to the NB-IoT network.

Let’s enter the following commands:

AT%XSYSTEMMODE=0,1,0,0
OK

AT%BANDLOCK=1,"10000000"
OK

Now we can attach to the network with:

  • Setting the APN to cdp.iot.t-mobile.nl
  • Setting the mobile network operator such as T-Mobile Netherland or Telekom Deutschland
# T-Mobile Netherland
AT+COPS=1,2,"20416",9
OK

# Telekom Deutschland
AT+COPS=1,2,"26201",9
OK

# T-Mobile Poland
AT+COPS=1,2,"26002",9
OK
AT%XAPNSTATUS=1,"cdp.iot.t-mobile.nl"
OK

The list of all PLMN IDs (Public Land Mobile Network) you can find at https://en.wikipedia.org/wiki/Mobile_country_code
In the normal case the AT+COPS command can take up to 30 seconds.

If you want to know which network operators are visible or your devkit you can also use the AT+COPS=? command. Don't be supprised that this command blocks somtimes up to an minute

After this we need to turn on the radio function with +CFUN.

AT+CFUN=1
OK

Please note that after entering the command the Thingy:91 needs some time to connect to the network. You can use the command AT+CGDCONT? to test whether the connection has been established. As long as the response is just “OK”, the connection has not yet been established.

📘

Connecting

Please note that after entering the command the Thingy:91 needs some time to connect to the network. You can use the command AT+CGDCONT? to test whether the connection has been established. As long as the response is only “OK”, the connection has not yet been established.

Check connectionCheck connection

Check connection

Send and Receive via UDP


In the following chapters I will explain to you how you can send a "Hello World" message from the device to the IoT Creators SCS and how you can receive a "Hello Device" message on your devkit from IoT Creators SCS.

Send "Hello World"

After the connection has been established, we are ready to send messages to our IoT creators UDP server.

❗️

Register your device first!

Make sure that you have registered your device with its IMEI at the IoT Creators portal BEFORE you send your first message to the UDP or CoAP server of IoT Creators.

If you forget, you will have problems to register your device afterwards. In this case please get in contact with IoT Creators support team.

Open a UDP socket to the UDP server of the IoT Creators.

AT#XSOCKET=1,2,1
#XSOCKET: 1,2,1,17
OK

Sending "Hello World" UDP Message to UDP Server

I recommand not to send plain text or binary data from the device to your backend applications or vice versa. You can use a hex or a base64 encoding format of data. In our sample we send Hello World as a hex converted string to the IoT Creators.
To convert Hello World you can use this online tool.

The hex string for Hello World is 48656c6c6f20576f726c64.

To let your device sent this message via UDP to the UDP server of IoT Creators you can use the following AT command:

AT#XSENDTO="172.27.131.100",15683,1,"Hello World"
#XSENDTO: 8
OK

As next we can change back to the project space of the IoT portal to check what has been received.

View the received Messages in IoT Creators Portal

For each device the IoT Creators Portal makes the laste received message available by showing it in the Payload column. In case of our Hello World message

If you click on the payload the value of it is copied to the clipboard.

As already mentioned above it is a nice behaviour to transfer strings and binary data not as they are. It is better to encode them to hex or base64 for the transfer.
We sent our Hello World as hex encoded string on its way. Out if this reason we see in the IoT Creators Portal the string 48656c6c6f20576f726c64.

To decode the received message back from hex to a readable string we can use the online tool http://string-functions.com/hex-string.aspx.

👍

If you can decode your received message to Hello World **CONGRATULATIONS**! You just sent and receceived your first UDP message.


Did this page help you?