Skip to content

Thingy:91#

Integrate your Nordic Thingy:91 board with Coiote IoT DM using the Anjay LwM2M client.

Thingy:91

Prerequisites#

  • The Thingy:91 board with a USB cable and SIM card.
  • Installed minicom or RealTerm (for Linux or Mac) or PuTTy (for Windows) or other serial communication program.
  • A user with access to the Coiote IoT Device Management platform.

Prepare binaries#

Use an already built binary#

To get the latest binary file and flash the board:

  1. Go to Anjay-zephyr-client.
  2. Download the demo_thingy91_app_signed.hex file.
  3. Jump to the flashing part of the tutorial.

Start development using samples#

Note

If you've gone through the Use an already built binary step, you can jump to Connect to the LwM2M Server.

Part 1: Get Zephyr and Python dependencies#

To get the Zephyr SDK and dependencies follow the first 4 steps of the instruction provided by the Zephyr Project.

  1. Select and Update OS
  2. Install dependencies
  3. Get Zephyr and install Python dependencies
  4. Install Zephyr SDK

Part 2: Clone the Anjay Zephyr repository#

Open the command line interface on your machine, then paste and run the following command:

git clone https://github.com/AVSystem/Anjay-zephyr-client

Part 3: Compile the demo project#

  1. Connect the Thingy:91 board to a USB port of your machine.
  2. Set West manifest path to Anjay-zephyr-client/demo, manifest file to west-nrf.yml, and run west update:

    west config manifest.path Anjay-zephyr-client/demo
    west config manifest.file west-nrf.yml
    west update
    
  3. Go to the directory Anjay-zephyr-client/demo.

  4. Compile the project for Thingy:91 using the command:

    west build -b thingy91_nrf9160ns
    

    Note

    [Optional] Configuration of the Anjay client can be done using menuconfig. This allows you, among others, to enable the GPS and cell-based location services. To open the configuration menu, run the command:

    west build -b thingy91_nrf9160ns -p -t menuconfig
    

    A config screen will open:

    menuconfig

    After making the configuration changes, close the config menu by pressing Q and save it by pressing the key Y.

    To build the project using the new configuration, run:

    west build
    

  5. Find the app_signed.hex file under the build/zephyr directory in the project folder.

Flash the binaries#

To program the board, go through the process of flashing Thingy:91. Use the nRF Connect Programmer with the downloaded .hex file and follow the program the nRF9160 SiP application section.

After successful flashing, reboot the board and go to the next step.

Connect to the LwM2M Server#

To connect to Coiote IoT Device Management platform, please register at https://eu.iot.avsystem.cloud.

To connect the board:

  1. Log in to Coiote IoT DM and from the left side menu, select Device Inventory.
  2. In Device Inventory, click Add device.
  3. Select the Connect your LwM2M device directly via the Management server tile. Add via Mgmt
  4. In the Device credentials step:

    • In the Endpoint name field, enter your board endpoint name e.g. test_device (remember to set the same name in the next section). Device credentials step
    • In the Security mode section, select the Pre-Shared Key mode:
      • In the Key identity field, type the same name as in the Endpoint name field.
      • In the Key field, type a shared secret used for the device-server authentication.

        Note

        This is your password which you create yourself, you will need it in the next steps.

  5. Click the Add device button and Confirm in the confirmation pop-up.

  6. While in the Connect your device step, follow the next section to run the client and connect it to the server.

Configure the Client#

  1. With the board still connected to a serial port interface, open a serial communication program.

  2. Use the anjay command to list possible options:

    Anjay commands

    Tip

    To show available subcommands, use the Tab key.

  3. Check your default credentials by following the instructions in the program:

    anjay config show
    

    Anjay Configuration

  4. Update your device credentials:

    • To make any changes to the configuration, stop the client:

      anjay stop
      
    • To update the endpoint name run the command:

      anjay config set endpoint <endpoint name>
      
    • To update the Pre-Shared Key, run the command

      anjay config set psk <key>
      
  5. Start the client using the new configurations:

    anjay start
    
  6. Go to the Coiote IoT DM to check if your device is connected. Registered device

Note

When Anjay has no connection with the server or network for a long time, warning at_monitor: No heap space for incoming notification: <notification> may appear. It does not affect the operation of the application and will no longer appear after reconnection.

Next Steps#

After configuring the Anjay Client, you can use the nRF Cloud Location Service to enable cell-based location services, or assisted GPS. Learn how to do it here.

Note

Thingy:91 uses the same radio for GPS and LTE connectivity. GPS signal is caught between LTE transmissions and in case GPS "cold" fix acquisition takes too much time, Anjay turns off LTE transmissions for the time of fix acquisition. It can be seen by the following warning: gps_nrf: GPS was interrupted multiple times by the LTE modem when producing a fix. Anjay is notified by it, enters offline mode and reconnects when the first fix is acquired and LTE is enabled back.


Last update: May 14, 2024