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.
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 |
Using LTE Link Monitor
You can use the LTE Link Monitor application to get debug output and send AT commands to the Thingy:91. In the case of LTE Link Monitor or Trace Collector, the baud rate for the communication is set automatically.
To connect to the Thingy:91 using LTE Link Monitor, complete the following steps:
Open nRF Connect for Desktop.
Find LTE Link Monitor in the list of applications and click Install.
Connect the Thingy:91 to a computer with a micro-Universal Serial Bus (USB) cable.
Make sure that the Thingy:91 is powered on.
Launch the LTE Link Monitor application.
In the navigation bar, click Select device. A drop-down menu appears.
In the menu, select Thingy:91.
In the LTE Link Monitor terminal, send an AT command to the modem. If the connection is working, the modem responds with OK.
The terminal view shows all of the Asset Tracker v2 debug output as well as the AT commands and their results. For information on the available AT commands, see nRF91 AT Commands Reference Guide.
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 |
|
nRF52840 SoC |
|
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
, andnrf52840_pca20035
.In nRF Connect SDK releases ranging from v1.3.0 to v1.6.1, the build target
thingy91_nrf9160_ns
was namedthingy91_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 |
|
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 VS Code extension
The nRF Connect for Visual Studio 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.
Building and programming using SEGGER Embedded Studio
Complete the following steps to build nRF Connect SDK projects with SES after installing SEGGER Embedded Studio and completing the first time setup:
Start SEGGER Embedded Studio.
If you have installed the nRF Connect SDK using the Toolchain Manager, click the Open Segger Embedded Studio button next to the version you installed to start SES. If you have installed SES manually, run the
emStudio
executable file from thebin
directory.Select File > Open nRF Connect SDK Project.
To add a project to SES, you must specify the following information:
nRF Connect SDK Release - Select the nRF Connect SDK version that you want to work with.
The drop-down list contains the current version of all nRF Connect SDK installation directories that SES knows about. To add a missing nRF Connect SDK installation directory to that list, run
west zephyr-export
in the installation repository or define the Zephyr base to point to the directory (see Set up the build environment in SES).nRF Connect Toolchain Version - If you used the Toolchain Manager to install the nRF Connect SDK, select the version of the toolchain that works with the selected nRF Connect SDK version. Otherwise, select NONE and make sure that your SES environment is configured correctly (see Set up the build environment in SES).
Note
The drop-down list contains only toolchain versions that are compatible with the selected nRF Connect SDK version.
Projects - Select the project that you want to work with.
The drop-down list contains a selection of applications from the sdk-nrf and sdk-zephyr repositories. Select any of the checkboxes underneath to add the applications from that area to the drop-down list. To add projects to the drop-down list, for example, your own custom projects, click … and select the folder that contains the projects that you want to add.
Board Name - Select the board that you want to work with.
The drop-down list contains the build targets for all Nordic Semiconductor boards that are defined in the sdk-nrf and sdk-zephyr repositories. Select any of the checkboxes underneath to add the build targets from that area to the drop-down list. To add build targets to the drop-down list, for example, targets for your own custom board, click … and select the folder that contains the board definitions.
Build Directory - Select the folder in which to run the build. The field is filled automatically based on the selected board name, but you can specify a different directory.
Clean Build Directory - Select this option to ensure that you are not building with an outdated build cache.
Extended Settings - Select this option to display a field where you can specify additional CMake options to be used for building. See Providing CMake options.
Note
The Board Directory folder can be found in the following location:
ncs/nrf/boards/arm
.
Click OK to import the project into SES. You can now work with the project in the IDE.
Note
At this stage, you might get an error indicating a project load failure. For example:
Can't load project file The project file <filepath> is invalid. The reported error is 'solution load command failed (1)'
This issue might be caused by a variety of problems, such as incorrectly specified project file paths. SES helps you to identify the source of the issue by providing a text output with detailed information about the error. Make sure to click OK on the error pop-up message and then inspect the text output in SES.
To build the sample or application:
Select your project in the Project Explorer.
From the menu, select Build > Build Solution. This builds the project.
You can find the output of the build, which includes the merged HEX file containing both the application and the SPM, in the
zephyr
subfolder in the build directory.
To program the sample or application:
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.
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.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Thingy:91 and the external debug probe are powered on.
In SES, select Target > Connect J-Link.
Select Target > Download zephyr/merged.hex to program the sample or application onto Thingy:91.
The device will reset and run the programmed sample or application.
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:
Open a terminal window.
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 andncs/nrf/applications/connectivity_bridge
when building the source code for the Connectivity bridge application on the nRF52840 SoC component.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.
To get the rest of the dependencies, run the
west update
command as follows:west update
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
orthingy91_nrf9160_ns
if building for the nRF9160 SiP component andthingy91_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/
.
To program the sample or application:
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.
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.
Connect the external debug probe to the PC using a USB cable.
Make sure that the Thingy:91 and the external debug probe are powered on.
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.