Search code examples
nrf52openthread

Starting point for building OpenThread applications using the nRF52840


I'm new to the nRF52840 and OpenThread platform and I'm looking for example code building a sensor application with an nRF52840 Micro Dev Kit USB Dongle.

I managed to set up a Raspberry Pi as border router, to build and flash the ot-cli-ftd, and to set up an OpenThread network with the NCP and two other nodes.

What I did not find on the OpenThread or nRF web sites is a "maker-friendly" example application, e.g. combining the OpenThread-CLI and some custom code for reading sensor data via I2C or SPI and sending data via MQTT (or MQTT-SN).

Is there an example how to build such an application for an nRF52840 Dongle?

I understand that I have to be careful to add USB and boot loader support in my firmware images to avoid "bricking" the dongles (they have no JLink interface, so AFAIK the only way to flash them is via the DFU boot loader), so I would prefer to start with some working example.


Solution

  • Thank you for your interest in Nordic nRF52840 and OpenThread.

    Generally, there are many examples provided in the nRF5 SDK for Thread and Zigbee. nRF52840 Dongle is also known as PCA10059, SDK provides examples that are running on it. I think that the Full Thread Device, Commandline Interface is a good starting point (examples/thread/cli/ftd/usb/). There are quite many other examples, even with MQTT-SN. They do not support the Dongle with the bootloader but having information that I will try to pass below you will be able to achieve such configuration.

    You are right that there is a difference in the memory layout.

    Dongle with the MBR and the Bootloader - PCA10059 variant: thread_cli_ftd_usb_gcc_nrf52.ld

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0xdb000
      RAM (rwx) :  ORIGIN = 0x20000008, LENGTH = 0x3fff8
      ot_flash_data (r) : ORIGIN = 0xdc000, LENGTH = 0x4000
    }
    

    Development Kit without the MBR and the Bootloader - PCA10056 variant: thread_cli_ftd_usb_gcc_nrf52.ld:

    MEMORY
    {
      FLASH (rx) : ORIGIN = 0x0, LENGTH = 0xfc000
      RAM (rwx) :  ORIGIN = 0x20000000, LENGTH = 0x40000
      ot_flash_data (r) : ORIGIN = 0xfc000, LENGTH = 0x4000
    }
    

    You can find details in the Memory layout section. Please note that the Multiprotocol examples use Softdevice while the Thread-only do not need it and use that space for the application.

    There is a way to unbrick the dongle, actually even two of them. One is a cable with a needle connector - TC2050-IDC-NL. The second option is soldering a 10-pin connector at the back of the dongle and using a ribbon cable. Having any of them enables you to connect the programmer and flash the MBR and the Bootloader which are available with the SDK mentioned above.

    For future nRF related questions I highly recommend Nordic Devzone where you can get help from engineers working with Nordic Semiconductor.