Configuring Devices

With Cloud IoT Core, you can control a device by modifying its configuration. A device configuration is an arbitrary, user-defined blob of data. After a configuration has been applied to a device, the device can report its state to Cloud IoT Core.

Device configuration works differently in the MQTT and HTTP bridges. See below for details.

For more information, see Devices, Configuration, and State.

Limits

Configuration updates are limited to 1 update per second, per device. However, for best results, device configuration should be updated much less often — at most, once every 10 seconds.

The update rate is calculated as the time between the most recent server acknowledgment and the next update request.

Protocol differences

MQTT

Devices using MQTT can subscribe to a special MQTT topic for configuration updates:

/devices/{device-id}/config

When a device subscribes to the configuration topic, the MQTT bridge responds with an MQTT SUBACK message, which contains the granted QoS for the config topic (0 or 1), or 128 if an error occurred.

After initially subscribing, the device receives the latest configuration in a message's payload, and will receive additional configuration updates as they are pushed to Cloud IoT Core.

HTTP

If you're using the HTTP bridge, devices must explicitly request new configurations.

Updating device configuration

You can update device configuration using Cloud Platform Console, the Cloud IoT Core API, or gcloud.

Console

  1. Go to the Device registries page in Cloud Platform Console.

    Go to the Device registries page

  2. Click the ID of the registry that contains the device.

  3. On the Registry details page, click the ID of the device whose configuration you want to update.

  4. At the top of the page, click Update config.

  5. Select a format for the configuration and paste the data in the Configuration box.

  6. Click Send to device.

See Protocol differences for information on how devices receive the new configuration.

gcloud

To update a device configuration, run the gcloud beta iot devices configs update command:

gcloud beta iot devices configs update \
  ( --config-data=CONFIG_DATA | --config-file=CONFIG_FILE ) \
  --device=DEVICE_ID \
  --registry=REGISTRY_ID \
  --region=REGION \
  [--version-to-update=VERSION_TO_UPDATE]

Devices will be updated according to the protocol they use.

API

To update device configuration via the API:

Reviewing device configuration

You can review the last 10 versions of a device configuration using Cloud Platform Console, the API, or gcloud.

Console

  1. Go to the Device registries page in Cloud Platform Console.

    Go to the Device registries page

  2. Click the ID of the registry that contains the device whose configuration you want to update.

  3. On the Registry details page, click the ID of the device whose configuration you want to update.

  4. Click Configuration & state history.

Use the checkboxes to control whether configuration history or state history is shown, or both histories. Click Compare to see whether configuration and state match as you expect them to.

gcloud

To get recent configurations, run the gcloud beta iot devices configs list and describe commands:

gcloud beta iot devices configs list DEVICE_ID \
  --registry=REGISTRY_ID \
  --region=REGION \
  [--filter=EXPRESSION]
  [--limit=LIMIT]
  [--sort-by=[FIELD,...]]

gcloud beta iot devices configs describe DEVICE_ID \
  --registry=REGISTRY_ID \
  --region=REGION

API

To review device configuration via the API, use a Device configVersions.list request.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...

Google Cloud Internet of Things Core