nrf_cloud not connecting in thingy91X

Hello Nordic team,

I’m working with the following setup:

  • Board: Thingy:91X (nRF9161)

  • nRF Connect SDK version: v2.9.0

  • Modem firmware version: mfw_nrf91x1_2.0.2

  • Lesson being followed: Intermediate SDK Lesson L9_E6

  • Application working successfully: nrf_cloud_multiple_services


Issue:

The nrf_cloud_multiple_services sample connects successfully to nRF Cloud (I see MQTT and location data working).

However, when running the L9_E6 lesson application, I get the following output (see attached image), specifically:

Thank you,

José

Parents
  • Hi! The -128 error you are seeing is typical for invalid credentials. I suspect that for the nRF Cloud Multi Service sample, you are using the UUID as client ID. To connect the sample from the lesson, you would need to do the same. The device certificate is tied to one specific client ID. At the moment, you are using nrf-<IMEI> as device ID. This kind of device ID is not available for Thingy:91 X, as it is reserved for the old JITP certificates used by older development kits. You can try the kconfig option "CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID". If you feel the need to re-register your device, you can follow the guide here: https://github.com/nRFCloud/utils

    Let me know if that solves the issue!

  • YES! Right on point! The device ID was previously set to nrf-<IMEI>, but now it correctly matches the one expected by nRF Cloud, as shown in the screenshots. The fix was simply updating the prj.conf with the following settings:


    # Enable modem-based JSON Web Token (JWT) generation required for nRF Cloud authentication
    CONFIG_MODEM_JWT=y
    
    # Configure the nRF Cloud library to use the device's internal UUID as the client ID
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y


    Now the ID in the provisioned device using the Multiple-Services example

    Matches my code (L9_E6 of ncs-intermediate):
    Thank you for your assistant if it is not much trouble why do i get the Failed to save session state?
    [00:02:50.471,282] <err> nrf_cloud_transport: Failed to save session state: -2
  • That's the first time I see this error message. Tracing it down in the source code suggests a problem with the settings subsystem. Do you have all the kconfigs needed for persistent settings storage?

Reply Children
  • Greetings, thank you for you response, this is my prj.conf:

    #
    # Copyright (c) 2022 Nordic Semiconductor ASA
    #
    # SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
    #

    # General config
    CONFIG_EVENTS=y
    CONFIG_PICOLIBC_IO_FLOAT=y

    # Heap and stacks
    # Extended AT host/monitor stack/heap sizes since some nrf_cloud credentials are longer than 1024 bytes.
    CONFIG_AT_MONITOR_HEAP_SIZE=2048
    CONFIG_AT_HOST_STACK_SIZE=2048
    # Extended memory heap size needed both for PGPS and for encoding JSON-based nRF Cloud Device Messages.
    CONFIG_HEAP_MEM_POOL_SIZE=24576
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=4096

    # Enable Networking and Connection Manager.
    CONFIG_NETWORKING=y
    CONFIG_NET_SOCKETS=y
    CONFIG_NET_SOCKETS_OFFLOAD=y
    CONFIG_NET_MGMT_EVENT_STACK_SIZE=2048
    CONFIG_NET_CONNECTION_MANAGER_MONITOR_STACK_SIZE=1024
    CONFIG_MAIN_STACK_SIZE=2048

    # Enable LTE Connectivity using Connection Manager
    CONFIG_NET_IPV4=y
    CONFIG_NET_IPV6=y
    CONFIG_NET_IPV6_NBR_CACHE=n
    CONFIG_NET_IPV6_MLD=n
    CONFIG_NET_CONNECTION_MANAGER=y
    CONFIG_NRF_MODEM_LIB_NET_IF=y
    CONFIG_NRF_MODEM_LIB_NET_IF_AUTO_DOWN=y
    CONFIG_NRF_MODEM_LIB_NET_IF_DOWN_DEFAULT_LTE_DISCONNECT=y

    # Modem library
    CONFIG_NRF_MODEM_LIB=y

    # AT commands interface
    CONFIG_UART_INTERRUPT_DRIVEN=y
    CONFIG_AT_HOST_LIBRARY=y

    # nRF Cloud
    CONFIG_NRF_CLOUD_MQTT=y # This also enables FOTA by implicitly setting CONFIG_NRF_CLOUD_FOTA=y

    # MQTT
    CONFIG_MQTT_KEEPALIVE=120

    # MCUBOOT - Needed by FOTA
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUBOOT_IMG_MANAGER=y
    CONFIG_STREAM_FLASH_ERASE=y
    CONFIG_MODEM_INFO=y
    CONFIG_MODEM_INFO_ADD_NETWORK=y

    # Date Time lib - Used by PGPS and main application
    CONFIG_DATE_TIME=y

    # LTE link control - used by PGPS and main application
    CONFIG_LTE_LINK_CONTROL=y

    # Download Client - used by FOTA and PGPS
    CONFIG_DOWNLOAD_CLIENT=y
    CONFIG_DOWNLOAD_CLIENT_HTTP_FRAG_SIZE_1024=y
    CONFIG_DOWNLOAD_CLIENT_STACK_SIZE=4096
    CONFIG_DOWNLOAD_CLIENT_BUF_SIZE=2300
    CONFIG_DOWNLOAD_CLIENT_MAX_HOSTNAME_SIZE=128

    # Flash - Used by FOTA and PGPS
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_STREAM_FLASH=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
    CONFIG_NRF_CLOUD_ALERT=y
    CONFIG_NRF_CLOUD_LOG_DIRECT=y
    CONFIG_NRF_CLOUD_LOG_OUTPUT_LEVEL=3

    # On initial connection to the cloud, add info sections to the shadow
    CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS=y
    CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_NETWORK=y
    CONFIG_NRF_CLOUD_SEND_DEVICE_STATUS_SIM=y
    CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_FOTA=y
    CONFIG_NRF_CLOUD_SEND_SERVICE_INFO_UI=y

    CONFIG_LOG=y
    CONFIG_LOG_MODE_IMMEDIATE=y

    # STEP 2 - Enable FOTA for nRF Cloud
    CONFIG_NRF_CLOUD_FOTA=y
    # USE UUID
    # Enable modem-based JSON Web Token (JWT) generation required for nRF Cloud authentication
    CONFIG_MODEM_JWT=y

    # Configure the nRF Cloud library to use the device's internal UUID as the client ID
    CONFIG_NRF_CLOUD_CLIENT_ID_SRC_INTERNAL_UUID=y
    # 91x
    CONFIG_BOOTLOADER_MCUBOOT=y
  • Have you tried:

    # Settings - used by nRF Cloud library and PGPS
    CONFIG_SETTINGS=y
    CONFIG_SETTINGS_FCB=y
    CONFIG_FCB=y
  • That did it! Thank you very much, i thought this parcel already enabled the flash:

    # Flash - Used by FOTA and PGPS
    CONFIG_FLASH=y
    CONFIG_FLASH_PAGE_LAYOUT=y
    CONFIG_FLASH_MAP=y
    CONFIG_STREAM_FLASH=y
    CONFIG_MPU_ALLOW_FLASH_WRITE=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n
    CONFIG_NRF_CLOUD_ALERT=y
    CONFIG_NRF_CLOUD_LOG_DIRECT=y
    CONFIG_NRF_CLOUD_LOG_OUTPUT_LEVEL=3

    But now I see the missing piece was enabling the Zephyr Settings subsystem, which is essential for storing persistent data like PGPS predictions and other nRF Cloud-related state:

    # Settings - used by nRF Cloud library and PGPS
    CONFIG_SETTINGS=y                # Enables the Zephyr Settings subsystem
    CONFIG_SETTINGS_FCB=y           # Uses FCB (Flash Circular Buffer) as the backend
    CONFIG_FCB=y                    # Core support for Flash Circular Buffer

Related