Skip to main content

Using the device shadow

This page explains operations with the device shadow.

Using the device shadow in the nRF Cloud portal

This section explains device shadow management operations available through the nRF Cloud portal. You can view the full shadow in the portal, but the only section you can edit through the portal is config.

To view the device shadow in the nRF Cloud portal:

  1. Log in to the nRF Cloud portal.

  2. Select Device Management from the left sidebar.

    A panel opens to the right.

  3. Select Devices.

  4. Click the ID of the desired device.

    The device view opens.

  5. Click the Shadow tab under the Device Information card. This is the full device shadow, with "reported" and "desired" sections.

Getting the device shadow

This section explains how to get data from the device shadow using REST or MQTT.

You can retrieve a device shadow by calling the FetchDevice or ListDevices endpoints. If using ListDevices, set the includeState parameter to true.

Updating the device shadow

This section explains how to update the device shadow.

You can update a device shadow through the UpdateDeviceState endpoint.

Example: enabling FOTA

If you want to enable the nRF Cloud firmware over-the-air (FOTA) update service, you must configure your device for FOTA. This means the device must contain a reported.device.serviceInfo.fota_v2 array in its shadow, for example:

...
"reported": {
"device": {
"serviceInfo": {
"fota_v2": [
"APP",
"MODEM",
"BOOT"
]
}
}
}

See the REST preparations section of the FOTA documentation for REST API instructions.

To do this over MQTT, send the following message to the /shadow/update topic (include the state field):

{
"state": {
"reported": {
"device": {
"serviceInfo": {
"fota_v2": ["APP", "MODEM", "BOOT"]
}
}
}
}
}