Developing with Thingy:91

Nordic Thingy:91 is a battery-operated prototyping platform for cellular IoT systems, designed especially for asset tracking applications and environmental monitoring. Thingy:91 integrates an nRF9160 SiP that supports LTE-M, NB-IoT, and Global Navigation Satellite System (GNSS) and an nRF52840 SoC that supports Bluetooth® Low Energy, Near Field Communication (NFC) and USB.

You can find more information on the product in the Thingy:91 product page and in the Nordic Thingy:91 User Guide. The nRF Connect SDK provides support for developing applications on the Thingy:91. If you are not familiar with the nRF Connect SDK and the development environment, see the introductory documentation.

This guide gives you more information on the various aspects of Thingy:91.

Connecting to Thingy:91

For connecting to Thingy:91, you can use LTE Link Monitor, Trace Collector, or a serial terminal.

Using serial ports

If you prefer to use a standard serial terminal, the baud rate has to be specified manually.

Thingy:91 uses the following UART baud rate configuration:

UART Interface

Baud Rate

UART_0

115200

UART_1

1000000

Operating modes

Thingy:91 contains RGB indicator LEDs, which indicate the operating state of the device as described in the LED indication section of the User Interface module.

GNSS

Thingy:91 has a GNSS receiver, which, if activated, allows the device to be located globally using GNSS signals. In nRF9160: Asset Tracker v2, GNSS is activated by default.

LTE Band Lock

The modem within Thingy:91 can be configured to use specific LTE bands by using the band lock AT command. See Band lock and the band lock section in the AT Commands reference document for additional information. The preprogrammed firmware configures the modem to use the bands currently certified on the Thingy:91 hardware. When building the firmware, you can configure which bands should be enabled.

LTE-M / NB-IoT switching

Thingy:91 has a multimode modem, which enables it to support automatic switching between LTE-M and NB-IoT. A built-in parameter in the Thingy:91 firmware determines whether the modem first attempts to connect in LTE-M or NB-IoT mode. If the modem fails to connect using this preferred mode within the default timeout period (10 minutes), the modem switches to the other mode.

Building and programming from the source code

You can also program the Thingy:91 by using the images obtained by building the code in an nRF Connect SDK environment.

To set up your system to be able to build a compatible firmware image, follow the Getting started guide for nRF Connect SDK. The build targets of interest for Thingy:91 in nRF Connect SDK are as follows:

Component

Build target

nRF9160 SiP

thingy91_nrf9160 for the secure version

thingy91_nrf9160_ns for the non-secure version

nRF52840 SoC

thingy91_nrf52840

You must use the build target thingy91_nrf9160 or thingy91_nrf9160_ns when building the application code for the nRF9160 SiP and the build target thingy91_nrf52840 when building the application code for the onboard nRF52840 SoC.

Note

  • In nRF Connect SDK releases before v1.3.0, these build targets were named nrf9160_pca20035, nrf9160_pca20035ns, and nrf52840_pca20035.

  • In nRF Connect SDK releases ranging from v1.3.0 to v1.6.1, the build target thingy91_nrf9160_ns was named thingy91_nrf9160ns.

Note

LTE/GNSS features can only be used with non-secure target.

The table below shows the different types of build files that are generated and the different scenarios in which they are used:

File

File format

Programming scenario

merged.hex

Full image, HEX format

Using an external debug probe

and nRF Connect Programmer

app_signed.hex

MCUboot compatible image, HEX format

Using the built-in bootloader

and nRF Connect Programmer

app_update.bin

MCUboot compatible image, binary format

  • Using the built-in bootloader

    and mcumgr command line tool

  • For FOTA updates

There are multiple methods of programming a sample or application onto a Thingy:91. You can choose the method based on the availability or absence of an external debug probe to program.

Note

If you do not have an external debug probe available to program the Thingy:91, you can directly program by using the USB (MCUboot) method and nRF Connect Programmer. In this scenario, use the app_signed.hex firmware image file.

Note

While building applications for Thingy:91, the build system changes the signing algorithm of MCUboot so that it uses the default RSA Keys. This is to ensure backward compatibility with the MCUboot versions that precede the nRF Connect SDK v1.4.0. The default RSA keys must only be used for development. In a final product, you must use your own, secret keys. See Using development keys for more information.

Building and programming using Visual Studio Code

The nRF Connect for VS Code extension is a complete IDE for developing applications for nRF91, nRF53 and nRF52 Series devices. This includes an interface to the compiler and linker, an RTOS-aware debugger, a seamless interface to the nRF Connect SDK, and a serial terminal. For detailed instructions, see the nRF Connect for Visual Studio Code documentation site.

Complete the following steps after installing the nRF Connect for VS Code extension:

  1. Open Visual Studio Code.

    If you installed the nRF Connect SDK using the Toolchain Manager, you can click the Open VS Code button next to the version you installed.

  2. Open the nRF Connect for VS Code extension by clicking its icon or pressing Ctrl + Alt + N.

  3. Click the Add an existing application from the Welcome panel.

  4. In the prompt, navigate to the folder containing the sample or application you want to build, such as samples/nrf9160/cloud_client.

    Samples are located under nrf/samples/, and applications are located under nrf/applications/.

  5. Click Select folder to select the sample’s or the application’s folder.

    A new application is automatically added in the Applications panel.

  6. If needed, click Yes when prompted if you trust the authors of the files.

  7. Click the Add Build Configuration button in the Application panel, or click the text stating No build configurations. Click to create one.

    This opens the Add Build Configuration panel in a new tab.

  8. Select the board onto which you want to program the sample. In this case, you must use the build target thingy91_nrf9160 or thingy91_nrf9160_ns when building the application code for the nRF9160 SiP and the build target thingy91_nrf52840 when building the application code for the onboard nRF52840 SoC..

  9. Select the Build after generating configuration checkbox and click the Build Configuration button.

    This generates the configuration file and triggers the build process. When the process is complete, an Actions panel appears. In this panel, you can trigger the build process again, flash the built sample, or start a debug session.

  10. Program the application:

  1. Set the Thingy:91 SWD selection switch (SW2) to nRF91 or nRF52 depending on whether you want to program the nRF9160 SiP or the nRF52840 SoC component.

  2. Connect the Thingy:91 to the debug out port on a 10-pin external debug probe, for example, nRF9160 DK (Development Kit), using a 10-pin JTAG cable.

    Note

    If you are using nRF9160 DK as the debug probe, make sure that VDD_IO (SW11) is set to 1.8 V on the nRF9160 DK.

  3. Connect the external debug probe to the PC using a USB cable.

  4. Make sure that the Thingy:91 and the external debug probe are powered on.

  1. In Visual Studio Code, click the Flash option in the Actions panel.

    If you have multiple boards connected, you are prompted to pick a device at the top of the screen.

    A small notification banner appears in the bottom-right corner of Visual Studio Code to display the progress and confirm when the flash is complete.

Building and programming on the command line

Complete the command-line build setup before you start building nRF Connect SDK projects on the command line.

To build and program the source code from the command line, complete the following steps:

  1. Open a terminal window.

  2. Go to the specific sample or application directory. For example, the folder path is ncs/nrf/applications/asset_tracker_v2 when building the source code for the nRF9160: Asset Tracker v2 application on the nRF9160 SiP component and ncs/nrf/applications/connectivity_bridge when building the source code for the Connectivity bridge application on the nRF52840 SoC component.

  3. Make sure that you have the required version of the nRF Connect SDK repository by pulling the nRF Connect SDK repository, sdk-nrf on GitHub using the procedures described in Obtaining a copy of the nRF Connect SDK and Updating a copy of the nRF Connect SDK.

  4. To get the rest of the dependencies, run the west update command as follows:

    west update
    
  5. To build the sample or application code, run the west build command as follows:

    west build -b build_target -d destination_directory_name

    The parameter build_target should be thingy91_nrf9160 or thingy91_nrf9160_ns if building for the nRF9160 SiP component and thingy91_nrf52840 if building for the nRF52840 SoC component.

    Note

    The parameter destination_directory_name can be used to optionally specify the destination directory in the west command. Unless a destination_directory_name is specified, the build files are automatically generated in build/zephyr/.

  6. Program the application:

  1. Set the Thingy:91 SWD selection switch (SW2) to nRF91 or nRF52 depending on whether you want to program the nRF9160 SiP or the nRF52840 SoC component.

  2. Connect the Thingy:91 to the debug out port on a 10-pin external debug probe, for example, nRF9160 DK (Development Kit), using a 10-pin JTAG cable.

    Note

    If you are using nRF9160 DK as the debug probe, make sure that VDD_IO (SW11) is set to 1.8 V on the nRF9160 DK.

  3. Connect the external debug probe to the PC using a USB cable.

  4. Make sure that the Thingy:91 and the external debug probe are powered on.

  1. Program the sample or application to the device using the following command:

    west flash
    

    The device will reset and run the programmed sample or application.