This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Thingy:91 + Azure IoT Hub


Hi,

I am trying to use the thingy91 to publish some sensor data to an Azure IoT Hub, I've tried to look at mqtt_simple and modified "asset_tracker" application but I couldn't succeed.

so is there any example showing how to publish data to Azure IoT Hub (MQTT broker) using thingy91?

Thank you in advance...

Parents
  • Hello, 

    Can you provide some more information on what is failing? Are you able to connect the server? Do you get any errors?

    We have an unofficial example project called Bifravst which will connect the Thingy:91 to Azure. This is however work in progress, and I urge to read through what is documented.

    Kind regards,
    Øyvind

  • You may also want to look at this github PR which will be part of NCS 1.4.0, when that is released.
    -Øyvind

  • Hello, 

    Deri said:
    sorry for late replay, I was reading and learning how to use Zephyr API and kernel services to communicate with peripherals.

    No worries, fully understand the prioritization.  

    Deri said:
    1-I need to run #west flash twice to flash the build successfully.

     Can you elaborate? Are you getting an error?

    Deri said:
    2-The first device "Thingy91" works properly and send data to Azure when pressing the button , while the other one showing an error  "ERROR: mqtt_connect -95" , I've tried to update the FW of modem and debug this issue by AT commands, but still didn't figure out how to solve it. I've attached a log file for this issue. 

     error  -95 is often seen when there is an issue with the certificates. Have followed the steps for Prerequisites for connecting to Azure IoT Hub and Provisioning of the certificates?

    Thanks!
    -Øyvind

  • Hi,

    1-I need to run #west flash twice to flash the build successfully: Assum the Thingy91 has been flashed with an asset tracker application or any other image, after that, I've compiled my simple MQTT code using:
    #west build -b thingy91_nrf9160ns -d build

    then I run the flash command at first time #west flash,I noticed that Thingy91 gets stuck(not able to boot) and there is no data showing on the terminal (puTTY ), I've tried to resetThingy91 several times (power off-on) with no response.

    west flash
    -- west flash: rebuilding
    [0/16] Performing build step for 'spm_subimage'
    ninja: no work to do.
    [1/6] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [2/6] Running utility command for mcuboot_sign_target
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: C:/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/merged.hex
    Parsing hex file.
    Erasing page at address 0x0.
    Erasing page at address 0x1000.
    Erasing page at address 0x2000.
    Erasing page at address 0x3000.
    Erasing page at address 0x4000.
    Erasing page at address 0x5000.
    Erasing page at address 0x6000.
    Erasing page at address 0x7000.
    Erasing page at address 0x8000.
    Erasing page at address 0x9000.
    Erasing page at address 0xC000.
    Erasing page at address 0xD000.
    Erasing page at address 0xE000.
    Erasing page at address 0xF000.
    Erasing page at address 0x10000.
    Erasing page at address 0x11000.
    Erasing page at address 0x12000.
    Erasing page at address 0x13000.
    Erasing page at address 0x14000.
    Erasing page at address 0x15000.
    Erasing page at address 0x16000.
    Erasing page at address 0x17000.
    Erasing page at address 0x18000.
    Erasing page at address 0x19000.
    Erasing page at address 0x1A000.
    Erasing page at address 0x1B000.
    Erasing page at address 0x1C000.
    Erasing page at address 0x1D000.
    Erasing page at address 0x1E000.
    Erasing page at address 0x1F000.
    Erasing page at address 0x20000.
    Erasing page at address 0x21000.
    Erasing page at address 0x22000.
    Erasing page at address 0x23000.
    Erasing page at address 0x24000.
    Erasing page at address 0x25000.
    Erasing page at address 0x26000.
    Erasing page at address 0x27000.
    Erasing page at address 0x28000.
    Erasing page at address 0x29000.
    Erasing page at address 0x2A000.
    Erasing page at address 0x2B000.
    Erasing page at address 0x2C000.
    Erasing page at address 0x2D000.
    Erasing page at address 0x2E000.
    Erasing page at address 0x2F000.
    Erasing page at address 0x30000.
    Erasing page at address 0x31000.
    Erasing page at address 0x32000.
    Erasing page at address 0x33000.
    Erasing page at address 0x34000.
    Erasing page at address 0x35000.
    Erasing page at address 0x36000.
    Erasing page at address 0x37000.
    Erasing page at address 0x38000.
    Erasing page at address 0x39000.
    Erasing page at address 0x3A000.
    Erasing page at address 0x3B000.
    Erasing page at address 0x3C000.
    Erasing page at address 0x3D000.
    Erasing page at address 0x3E000.
    Erasing page at address 0x3F000.
    Erasing page at address 0x40000.
    Erasing page at address 0x41000.
    Erasing page at address 0x42000.
    Erasing page at address 0x43000.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    Applying system reset.
    Run.
    -- runners.nrfjprog: Board with serial number 50103495 flashed successfully.

    when I repeat the same flash command #west flash the device boots up and showing all the data

    west flash
    -- west flash: rebuilding
    [0/16] Performing build step for 'spm_subimage'
    ninja: no work to do.
    [1/6] Performing build step for 'mcuboot_subimage'
    ninja: no work to do.
    [2/6] Running utility command for mcuboot_sign_target
    -- west flash: using runner nrfjprog
    -- runners.nrfjprog: Flashing file: C:/ncs/nrf/samples/nrf9160/mqtt_simple/build/zephyr/merged.hex
    Parsing hex file.
    Erasing page at address 0x0.
    Erasing page at address 0x1000.
    Erasing page at address 0x2000.
    Erasing page at address 0x3000.
    Erasing page at address 0x4000.
    Erasing page at address 0x5000.
    Erasing page at address 0x6000.
    Erasing page at address 0x7000.
    Erasing page at address 0x8000.
    Erasing page at address 0x9000.
    Erasing page at address 0xC000.
    Erasing page at address 0xD000.
    Erasing page at address 0xE000.
    Erasing page at address 0xF000.
    Erasing page at address 0x10000.
    Erasing page at address 0x11000.
    Erasing page at address 0x12000.
    Erasing page at address 0x13000.
    Erasing page at address 0x14000.
    Erasing page at address 0x15000.
    Erasing page at address 0x16000.
    Erasing page at address 0x17000.
    Erasing page at address 0x18000.
    Erasing page at address 0x19000.
    Erasing page at address 0x1A000.
    Erasing page at address 0x1B000.
    Erasing page at address 0x1C000.
    Erasing page at address 0x1D000.
    Erasing page at address 0x1E000.
    Erasing page at address 0x1F000.
    Erasing page at address 0x20000.
    Erasing page at address 0x21000.
    Erasing page at address 0x22000.
    Erasing page at address 0x23000.
    Erasing page at address 0x24000.
    Erasing page at address 0x25000.
    Erasing page at address 0x26000.
    Erasing page at address 0x27000.
    Erasing page at address 0x28000.
    Erasing page at address 0x29000.
    Erasing page at address 0x2A000.
    Erasing page at address 0x2B000.
    Erasing page at address 0x2C000.
    Erasing page at address 0x2D000.
    Erasing page at address 0x2E000.
    Erasing page at address 0x2F000.
    Erasing page at address 0x30000.
    Erasing page at address 0x31000.
    Erasing page at address 0x32000.
    Erasing page at address 0x33000.
    Erasing page at address 0x34000.
    Erasing page at address 0x35000.
    Erasing page at address 0x36000.
    Erasing page at address 0x37000.
    Erasing page at address 0x38000.
    Erasing page at address 0x39000.
    Erasing page at address 0x3A000.
    Erasing page at address 0x3B000.
    Erasing page at address 0x3C000.
    Erasing page at address 0x3D000.
    Erasing page at address 0x3E000.
    Erasing page at address 0x3F000.
    Erasing page at address 0x40000.
    Erasing page at address 0x41000.
    Erasing page at address 0x42000.
    Erasing page at address 0x43000.
    Applying system reset.
    Checking that the area to write is not protected.
    Programming device.
    Applying system reset.
    Run.
    -- runners.nrfjprog: Board with serial number 50103495 flashed successfully.

    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    Flash regions		Domain		Permissions
    00 02 0x00000 0x18000 	Secure		rwxl
    03 31 0x18000 0x100000 	Non-Secure	rwxl
    
    Non-secure callable region 0 placed in flash region 2 with size 32.
    
    SRAM region		Domain		Permissions
    00 07 0x00000 0x10000 	Secure		rwxl
    08 31 0x10000 0x40000 	Non-Secure	rwxl
    
    Peripheral		Domain		Status
    00 NRF_P0               Non-Secure	OK
    01 NRF_CLOCK            Non-Secure	OK
    02 NRF_RTC0             Non-Secure	OK
    03 NRF_RTC1             Non-Secure	OK
    04 NRF_NVMC             Non-Secure	OK
    05 NRF_UARTE1           Non-Secure	OK
    06 NRF_UARTE2           Secure		SKIP
    07 NRF_TWIM2            Non-Secure	OK
    08 NRF_SPIM3            Non-Secure	OK
    09 NRF_TIMER0           Non-Secure	OK
    10 NRF_TIMER1           Non-Secure	OK
    11 NRF_TIMER2           Non-Secure	OK
    12 NRF_SAADC            Non-Secure	OK
    13 NRF_PWM0             Non-Secure	OK
    14 NRF_PWM1             Non-Secure	OK
    15 NRF_PWM2             Non-Secure	OK
    16 NRF_PWM3             Non-Secure	OK
    17 NRF_WDT              Non-Secure	OK
    18 NRF_IPC              Non-Secure	OK
    19 NRF_VMC              Non-Secure	OK
    20 NRF_FPU              Non-Secure	OK
    21 NRF_EGU1             Non-Secure	OK
    22 NRF_EGU2             Non-Secure	OK
    23 NRF_DPPIC            Non-Secure	OK
    24 NRF_GPIOTE1          Non-Secure	OK
    25 NRF_REGULATORS       Non-Secure	OK
    
    SPM: NS image at 0x18200
    SPM: NS MSP at 0x2002e8f0
    SPM: NS reset vector at 0x1d595
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    The MQTT simple for Azure IoT Hub get started
    DNS correctly set
    LTE Link Connecting ...
    [00:00:00.211,944] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    [00:00:00.231,933] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    [00:00:01.545,135] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    
    [00:00:01.557,098] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    +CSCON: 1
    [00:00:01.598,052] <dbg> lte_lc.at_handler: +CSCON notification
    +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    [00:00:03.114,135] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    
    [00:00:03.125,946] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    LTE Link Connected!
    IPv4 Address found 13.79.172.43
    

    so every time I have to run the flash twice to program my device properly. any suggestions to solve this issue?


    2-The first device "Thingy91" works properly on one Thingy91 and showing "ERROR: mqtt_connect -95"  on another device:

    It is the same build image that has been flashed on two devices (Thingy91) and the same SIM card, please look at the log files of both devices to figure out why does it show this error message?

    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    Flash regions		Domain		Permissions
    00 02 0x00000 0x18000 	Secure		rwxl
    03 31 0x18000 0x100000 	Non-Secure	rwxl
    
    Non-secure callable region 0 placed in flash region 2 with size 32.
    
    SRAM region		Domain		Permissions
    00 07 0x00000 0x10000 	Secure		rwxl
    08 31 0x10000 0x40000 	Non-Secure	rwxl
    
    Peripheral		Domain		Status
    00 NRF_P0               Non-Secure	OK
    01 NRF_CLOCK            Non-Secure	OK
    02 NRF_RTC0             Non-Secure	OK
    03 NRF_RTC1             Non-Secure	OK
    04 NRF_NVMC             Non-Secure	OK
    05 NRF_UARTE1           Non-Secure	OK
    06 NRF_UARTE2           Secure		SKIP
    07 NRF_TWIM2            Non-Secure	OK
    08 NRF_SPIM3            Non-Secure	OK
    09 NRF_TIMER0           Non-Secure	OK
    10 NRF_TIMER1           Non-Secure	OK
    11 NRF_TIMER2           Non-Secure	OK
    12 NRF_SAADC            Non-Secure	OK
    13 NRF_PWM0             Non-Secure	OK
    14 NRF_PWM1             Non-Secure	OK
    15 NRF_PWM2             Non-Secure	OK
    16 NRF_PWM3             Non-Secure	OK
    17 NRF_WDT              Non-Secure	OK
    18 NRF_IPC              Non-Secure	OK
    19 NRF_VMC              Non-Secure	OK
    20 NRF_FPU              Non-Secure	OK
    21 NRF_EGU1             Non-Secure	OK
    22 NRF_EGU2             Non-Secure	OK
    23 NRF_DPPIC            Non-Secure	OK
    24 NRF_GPIOTE1          Non-Secure	OK
    25 NRF_REGULATORS       Non-Secure	OK
    
    SPM: NS image at 0x18200
    SPM: NS MSP at 0x2002e8f0
    SPM: NS reset vector at 0x1d595
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    The MQTT simple for Azure IoT Hub get started
    DNS correctly set
    LTE Link Connecting ...
    [00:00:00.211,944] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    [00:00:00.231,933] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    [00:00:01.664,245] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    
    [00:00:01.676,239] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    +CSCON: 1
    [00:00:01.721,130] <dbg> lte_lc.at_handler: +CSCON notification
    +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    [00:00:02.915,222] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    
    [00:00:02.927,032] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    LTE Link Connected!
    IPv4 Address found 13.79.172.43
    username: Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30, size:57
    password: SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&se=3600001600713127, size:145
    MQTT_TRANSPORT_NON_SECURE --1--,0 :
     client_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:236 , err:0
    [mqtt_evt_handler:205] MQTT client connected!
    Subscribing to: /my/subscribe/topic len 19
    sensor shwoing.... 
    { Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415}
    Publishing: { Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415}
    to topic: devices/Thingy91/messages/events/$.ct=application%2Fjson&$.ce=utf-8 len: 67
    Message has been published , msg size is:{ Temperature: 23.960 , Pressure: 99.151 , Humidity: 52.415} 
    sensor shwoing.... 
    { Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368}
    Publishing: { Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368}
    to topic: devices/Thingy91/messages/events/$.ct=application%2Fjson&$.ce=utf-8 len: 67
    Message has been published , msg size is:{ Temperature: 23.880 , Pressure: 99.147 , Humidity: 52.368} 
    +CSCON: 0
    [00:00:30.237,182] <dbg> lte_lc.at_handler: +CSCON notification
    

    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    Flash regions		Domain		Permissions
    00 02 0x00000 0x18000 	Secure		rwxl
    03 31 0x18000 0x100000 	Non-Secure	rwxl
    
    Non-secure callable region 0 placed in flash region 2 with size 32.
    
    SRAM region		Domain		Permissions
    00 07 0x00000 0x10000 	Secure		rwxl
    08 31 0x10000 0x40000 	Non-Secure	rwxl
    
    Peripheral		Domain		Status
    00 NRF_P0               Non-Secure	OK
    01 NRF_CLOCK            Non-Secure	OK
    02 NRF_RTC0             Non-Secure	OK
    03 NRF_RTC1             Non-Secure	OK
    04 NRF_NVMC             Non-Secure	OK
    05 NRF_UARTE1           Non-Secure	OK
    06 NRF_UARTE2           Secure		SKIP
    07 NRF_TWIM2            Non-Secure	OK
    08 NRF_SPIM3            Non-Secure	OK
    09 NRF_TIMER0           Non-Secure	OK
    10 NRF_TIMER1           Non-Secure	OK
    11 NRF_TIMER2           Non-Secure	OK
    12 NRF_SAADC            Non-Secure	OK
    13 NRF_PWM0             Non-Secure	OK
    14 NRF_PWM1             Non-Secure	OK
    15 NRF_PWM2             Non-Secure	OK
    16 NRF_PWM3             Non-Secure	OK
    17 NRF_WDT              Non-Secure	OK
    18 NRF_IPC              Non-Secure	OK
    19 NRF_VMC              Non-Secure	OK
    20 NRF_FPU              Non-Secure	OK
    21 NRF_EGU1             Non-Secure	OK
    22 NRF_EGU2             Non-Secure	OK
    23 NRF_DPPIC            Non-Secure	OK
    24 NRF_GPIOTE1          Non-Secure	OK
    25 NRF_REGULATORS       Non-Secure	OK
    
    SPM: NS image at 0x18200
    SPM: NS MSP at 0x2002e8f0
    SPM: NS reset vector at 0x1d595
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build v2.3.0-rc1-ncs2  ***
    The MQTT simple for Azure IoT Hub get started
    DNS correctly set
    LTE Link Connecting ...
    [00:00:00.213,958] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    [00:00:00.233,947] <dbg> lte_lc.lte_lc_system_mode_set: Sending AT command to set system mode: AT%XSYSTEMMODE=1,0,1,0
    +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    [00:00:01.685,485] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    
    [00:00:01.697,418] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    +CSCON: 1
    [00:00:01.738,403] <dbg> lte_lc.at_handler: +CSCON notification
    +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    [00:00:02.696,472] <dbg> lte_lc.at_handler: +CEREG notification: +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    
    [00:00:02.708,221] <dbg> lte_lc.parse_psm_cfg: TAU: -1 sec, active time: -1 sec
    
    LTE Link Connected!
    IPv4 Address found 13.79.172.43
    username: Nordic.azure-devices.net/Thingy91/?api-version=2018-06-30, size:57
    password: SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&se=3600001600713127, size:145
    MQTT_TRANSPORT_NON_SECURE --1--,0 :
     mqtt_transport_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:93 , err:-95
     client_connect WEST_TOPDIR/zephyr/subsys/net/lib/mqtt/mqtt.c:236 , err:-95
    ERROR: mqtt_connect -95
    

  • Deri said:
    I have to run the flash twice to program my device properly. any suggestions to solve this issue?

    Can you try running west flash --erase?

    Deri said:
    It is the same build image that has been flashed on two devices (Thingy91) and the same SIM card, please look at the log files of both devices to figure out why does it show this error message?

    I will need some more time to look into this case. Have you tried an unmodified version of the Azure IoT Hub sample on both? Only adding relevant information to connect?

      

  • Part 1: # west flash --erase it works correctly, thanks.

    Part 2:I followed the below steps and got some errors:

    #C:\ncs\nrf\samples\nrf9160>git checkout master
    #git pull
    #cd azure_iot_hub
    #copy NUL prj_thingy91_nrf9160ns.conf
    #cd ../../../..
    C:\ncs>
    #set ZEPHYR_TOOLCHAIN_VARIANT=gnuarmemb
    #set GNUARMEMB_TOOLCHAIN_PATH=c:\gnuarmemb
    #zephyr\zephyr-env.cmd
    #cd nrf\samples\nrf9160\azure_iot_hub
    #west build -b thingy91_nrf9160ns -d build
    -- west build: generating a build system
    Including boilerplate (Zephyr base): C:/ncs/zephyr/cmake/app/boilerplate.cmake
    -- Application: C:/ncs/nrf/samples/nrf9160/azure_iot_hub
    -- Zephyr version: 2.3.0-rc1 (C:/ncs/zephyr)
    -- Found Python3: C:/Python38/python.exe (found suitable exact version "3.8.5") found components: Interpreter
    -- Board: thingy91_nrf9160ns
    No board named 'thingy91_nrf9160ns' found
    -- The C compiler identification is unknown
    -- The CXX compiler identification is unknown
    CMake Error at C:/ncs/zephyr/cmake/extensions.cmake:1486 (project):
      No CMAKE_C_COMPILER could be found.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
      the compiler, or to the compiler name if it is in the PATH.
    Call Stack (most recent call first):
      C:/ncs/zephyr/cmake/app/boilerplate.cmake:409 (print_usage)
      C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:9 (find_package)
    
    
    CMake Error at C:/ncs/zephyr/cmake/extensions.cmake:1486 (project):
      No CMAKE_CXX_COMPILER could be found.
    
      Tell CMake where to find the compiler by setting either the environment
      variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
      to the compiler, or to the compiler name if it is in the PATH.
    Call Stack (most recent call first):
      C:/ncs/zephyr/cmake/app/boilerplate.cmake:409 (print_usage)
      C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:24 (include)
      C:/ncs/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:35 (include_boilerplate)
      CMakeLists.txt:9 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    See also "C:/ncs/nrf/samples/nrf9160/azure_iot_hub/build/CMakeFiles/CMakeOutput.log".
    See also "C:/ncs/nrf/samples/nrf9160/azure_iot_hub/build/CMakeFiles/CMakeError.log".
    FATAL ERROR: command exited with status 1: 'C:\Program Files\CMake\bin\cmake.EXE' '-BC:\ncs\nrf\samples\nrf9160\azure_iot_hub\build' '-SC:\ncs\nrf\samples\nrf9160\azure_iot_hub' -GNinja -DBOARD=thingy91_nrf9160ns
    

    -The prj_thingy91_nrf9160ns.conf file filled with below configuration

    #
    # Copyright (c) 2020 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    
    # General config
    CONFIG_LOG=y
    
    # NEWLIB C
    CONFIG_NEWLIB_LIBC=y
    
    # Network
    CONFIG_NETWORKING=y
    CONFIG_NET_NATIVE=n
    
    # LTE link control
    CONFIG_LTE_LINK_CONTROL=y
    CONFIG_LTE_NETWORK_MODE_LTE_M=y
    CONFIG_LTE_AUTO_INIT_AND_CONNECT=n
    
    # BSD library
    CONFIG_BSD_LIBRARY=y
    
    # AT Host
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y
    CONFIG_AT_CMD_THREAD_STACK_SIZE=2048
    
    # Azure IoT Hub library
    CONFIG_AZURE_IOT_HUB=y
    CONFIG_AZURE_IOT_HUB_DEVICE_ID="Thingy91"
    # Host name must be configured if DPS is not used
    CONFIG_AZURE_IOT_HUB_HOSTNAME="Nordic.azure-devices.net"
    # Change the security tag to the tag where Azure IoT Hub certificates
    # are provisioned
    CONFIG_AZURE_IOT_HUB_SEC_TAG=10
    
    # Uncomment and configure the options below to use DPS for device provisioning
    # CONFIG_AZURE_IOT_HUB_DPS=y
    # CONFIG_AZURE_IOT_HUB_DPS_ID_SCOPE=""
    
    # Uncomment to get more verbose logging when debugging
    # CONFIG_AZURE_IOT_HUB_LOG_LEVEL_DBG=y
    
    # LED control
    CONFIG_DK_LIBRARY=y
    CONFIG_DK_LIBRARY_INVERT_LEDS=n
    
    # Heap and stacks
    CONFIG_HEAP_MEM_POOL_SIZE=4096
    
    CONFIG_HW_STACK_PROTECTION=y
    
    # cJSON
    CONFIG_CJSON_LIB=y
    
    # Settings, needed for Azure Device Provisioning Service
    CONFIG_FLASH=y
    CONFIG_FLASH_MAP=y
    CONFIG_FCB=y
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FCB=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    

  • Deri said:
    Part 1: # west flash --erase it works correctly, thanks.

    Excellent!

    Deri said:
    Part 2:I followed the below steps and got some errors:

     Have you run west update after doing git pull?

Reply Children
  • I have succeeded to compile my code after running #west update , but I got an error to connect to Azure IoT hub:

    Please look at the log file.

    +CSCON: 0
    RRC mode: Idle
    *** Booting Zephyr OS build zephyr-v2.4.0-198-ga4ead9805140  ***
    Flash regions		Domain		Permissions
    00 00 0x00000 0x08000 	Secure		rwxl
    01 31 0x08000 0x100000 	Non-Secure	rwxl
    
    Non-secure callable region 0 placed in flash region 0 with size 32.
    
    SRAM region		Domain		Permissions
    00 07 0x00000 0x10000 	Secure		rwxl
    08 31 0x10000 0x40000 	Non-Secure	rwxl
    
    Peripheral		Domain		Status
    00 NRF_P0               Non-Secure	OK
    01 NRF_CLOCK            Non-Secure	OK
    02 NRF_RTC0             Non-Secure	OK
    03 NRF_RTC1             Non-Secure	OK
    04 NRF_NVMC             Non-Secure	OK
    05 NRF_UARTE1           Non-Secure	OK
    06 NRF_UARTE2           Secure		SKIP
    07 NRF_TWIM2            Non-Secure	OK
    08 NRF_SPIM3            Non-Secure	OK
    09 NRF_TIMER0           Non-Secure	OK
    10 NRF_TIMER1           Non-Secure	OK
    11 NRF_TIMER2           Non-Secure	OK
    12 NRF_SAADC            Non-Secure	OK
    13 NRF_PWM0             Non-Secure	OK
    14 NRF_PWM1             Non-Secure	OK
    15 NRF_PWM2             Non-Secure	OK
    16 NRF_PWM3             Non-Secure	OK
    17 NRF_WDT              Non-Secure	OK
    18 NRF_IPC              Non-Secure	OK
    19 NRF_VMC              Non-Secure	OK
    20 NRF_FPU              Non-Secure	OK
    21 NRF_EGU1             Non-Secure	OK
    22 NRF_EGU2             Non-Secure	OK
    23 NRF_DPPIC            Non-Secure	OK
    24 NRF_GPIOTE1          Non-Secure	OK
    25 NRF_REGULATORS       Non-Secure	OK
    
    SPM: NS image at 0xc000
    SPM: NS MSP at 0x200271c8
    SPM: NS reset vector at 0x1077d
    SPM: prepare to jump to Non-Secure image.
    *** Booting Zephyr OS build zephyr-v2.4.0-198-ga4ead9805140  ***
    Azure IoT Hub sample started
    Connecting to LTE network
    +CEREG: 2,"8602","04CAA80A",7,0,0,"11100000","11100000"
    LTE cell changed: Cell ID: 80390154, Tracking area: 34306
    PSM parameter update: TAU: -1, Active time: -1
    +CSCON: 1
    RRC mode: Connected
    +CEREG: 1,"8602","04CAA80A",7,,,"11100000","11100000"
    Network registration status: Connected - home network
    Connected to LTE network
    AZURE_IOT_HUB_EVT_CONNECTING
    azure_iot_hub_connect failed: -95
    [00:00:03.208,160] <dbg> azure_iot_hub.broker_init: IPv4 Address found 13.79.172.43
    [00:00:03.793,762] <err> azure_iot_hub: mqtt_connect, error: -95
    +CSCON: 0
    RRC mode: Idle
    

    I've added the below to prj_thingy91_nrf9160ns.conf

    CONFIG_AZURE_IOT_HUB_DEVICE_ID="Thingy91"
    CONFIG_AZURE_IOT_HUB_HOSTNAME="Nordic.azure-devices.net"
    In addition to , I've added the password into azure_iot_hub.c as follows:
    static int client_broker_init(struct mqtt_client *const client, bool dps)
    {
    	int err;
    	static sec_tag_t sec_tag_list[] = { CONFIG_AZURE_IOT_HUB_SEC_TAG };
    	struct mqtt_sec_config *tls_cfg = &(client->transport).tls.config;
    
    	mqtt_client_init(client);
    
    	err = broker_init(dps);
    	if (err) {
    		return err;
    	}
    
    	/* The following parameters differ between DPS and IoT hub:
    	 *	client->user_name
    	 *	tls_cfg->hostname
    	 */
    	
    	char * token ="SharedAccessSignature sr=Nordic.azure-devices.net%2Fdevices%2FThingy91&sig=JH5dvWZ98gjAnUIEDm%2B8sN3ZBHmPzDvaZbFT%2FYdQOa0%3D&se=3600001600713127";
    	struct mqtt_utf8 pass;
    	pass.utf8 = (uint8_t*)token ;
    	pass.size = (uint32_t)strlen(token);
    
    	client->broker			= &broker;
    	client->evt_cb			= mqtt_evt_handler;
    	client->client_id.utf8	= conn_config.device_id;
    	client->client_id.size	= strlen(conn_config.device_id);
    	client->password		= &pass;
  • Hi,

    Is there any update about my case using the "Azure IoT Hub sample"? are there missing configurations should I add to prj_thingy91_nrf9160ns.conf? I got the same results using both devices of Thingy91.

  • Looks like you still have an issue with your certificates, often giving -95 (EOPNOTSUPP). 

    #define EOPNOTSUPP 95 /* Operation not supported on transport endpoint */

    Have you added the certificates correctly to nrf\samples\nrf9160\azure_iot_hub\certs\certificates.h?

  • yes, Please look at certificates.h


    /*
     * Copyright (c) 2020 Nordic Semiconductor ASA
     *
     * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
     */
    //#include "ca-cert.pem"
    static const unsigned char ca_certificate[] =
    "-----BEGIN CERTIFICATE-----\r\n"
    "MIIDdzCCAl+gAwIBAgIEAgAAuTANBgkqhkiG9w0BAQUFADBaMQswCQYDVQQGEwJJ\r\n"
    "RTESMBAGA1UEChMJQmFsdGltb3JlMRMwEQYDVQQLEwpDeWJlclRydXN0MSIwIAYD\r\n"
    "VQQDExlCYWx0aW1vcmUgQ3liZXJUcnVzdCBSb290MB4XDTAwMDUxMjE4NDYwMFoX\r\n"
    "DTI1MDUxMjIzNTkwMFowWjELMAkGA1UEBhMCSUUxEjAQBgNVBAoTCUJhbHRpbW9y\r\n"
    "ZTETMBEGA1UECxMKQ3liZXJUcnVzdDEiMCAGA1UEAxMZQmFsdGltb3JlIEN5YmVy\r\n"
    "VHJ1c3QgUm9vdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAKMEuyKr\r\n"
    "mD1X6CZymrV51Cni4eiVgLGw41uOKymaZN+hXe2wCQVt2yguzmKiYv60iNoS6zjr\r\n"
    "IZ3AQSsBUnuId9Mcj8e6uYi1agnnc+gRQKfRzMpijS3ljwumUNKoUMMo6vWrJYeK\r\n"
    "mpYcqWe4PwzV9/lSEy/CG9VwcPCPwBLKBsua4dnKM3p31vjsufFoREJIE9LAwqSu\r\n"
    "XmD+tqYF/LTdB1kC1FkYmGP1pWPgkAx9XbIGevOF6uvUA65ehD5f/xXtabz5OTZy\r\n"
    "dc93Uk3zyZAsuT3lySNTPx8kmCFcB5kpvcY67Oduhjprl3RjM71oGDHweI12v/ye\r\n"
    "jl0qhqdNkNwnGjkCAwEAAaNFMEMwHQYDVR0OBBYEFOWdWTCCR1jMrPoIVDaGezq1\r\n"
    "BE3wMBIGA1UdEwEB/wQIMAYBAf8CAQMwDgYDVR0PAQH/BAQDAgEGMA0GCSqGSIb3\r\n"
    "DQEBBQUAA4IBAQCFDF2O5G9RaEIFoN27TyclhAO992T9Ldcw46QQF+vaKSm2eT92\r\n"
    "9hkTI7gQCvlYpNRhcL0EYWoSihfVCr3FvDB81ukMJY2GQE/szKN+OMY3EU/t3Wgx\r\n"
    "jkzSswF07r51XgdIGn9w/xZchMB5hbgF/X++ZRGjD8ACtPhSNzkE1akxehi/oCr0\r\n"
    "Epn3o0WC4zxe9Z2etciefC7IpJ5OCBRLbf1wbWsaY71k5h+3zvDyny67G7fyUIhz\r\n"
    "ksLi4xaNmjICq44Y3ekQEe5+NauQrz4wlHrQMz2nZQ/1/I6eYs9HRCwBXbsdtTLS\r\n"
    "R9I4LtD+gdwyah617jzV/OeBHRnDJELqYzmp\r\n"
    "-----END CERTIFICATE-----\r\n"
    ;
    
    static const unsigned char private_key[] = {
    #include "private-key.pem"
    };
    
    static const unsigned char device_certificate[] = {
    #include "client-cert.pem"
    };
    

Related