This guide provides the steps to take to get your devices up and running on nRF Cloud. The bulk of the content is centered around device security and credentials, which is a complex though essential topic. See also the Authentication sections of the MQTT API or the REST API.
If you are using an nRF9160 DK or Thingy:91, see the Other Docs and Tools page for links to Getting Started Guides specifically designed for these products. The information below complements those guides.
- Create a free account on nRFCloud.com.
- Read the documentation on device provisioning and adding and removing devices. This will give you an understanding of the various ways you can get your devices connected to your nRF Cloud account. Refer to the steps below for generating device credentials depending upon your use case.
- Read the documentation on our APIs to decide upon your next steps.
- Install nRF Connect for Desktop and the LTE Link Monitor modem client application.
Make sure you have modem firmware v1.3.x or later.
The modem can securely generate credentials using the
KEYGEN AT command. This method can be considered more secure because the private key is not exposed and never leaves the modem.
To ensure the modem is deactivated, send the following AT command:
In the output,
<sec_tag>is the slot in the modem where the credentials will be stored. The default
<sec_tag>for nRF Cloud credentials is
16842753. In most cases, this slot already contains the credentials. You must delete these to flash new credentials in the steps that follow. Otherwise, you may use a different slot.
To see which slots are currently used, use the
If you intend to use slot
16842753, you most likely have to delete the existing certificate and private key by sending these AT commands one at a time:
When you see
OKin the terminal, issue the following command:
If you resend
AT%CMNG=1, you see a value only for type 0 (CA certificate). This is expected, as you are not flashing a new CA certificate.
To generate a private key in the modem and receive the associated certificate signing request (CSR), execute the following AT command:
If you are not using the slot
16842753, substitute the correct value.
KEYGENcommand uses the default value, the nRF9160's UUID, for the
CNin the credential. If you are using a different device ID or MQTT client ID, update your
KEYGENcommand to use the ID as the
The output of a successful
KEYGENcommand is a base64-encoded CBOR object.
If you are manually copying and pasting the KEYGEN output, make sure to copy all characters of the base64 string that is enclosed in double quotes.
This step requires a CA certificate (and its private key). If you do not already have one, use the create_ca_cert.py script to create a CA and a key that you can use to sign all your device certificates.
If the device uses MQTT to connect to nRF Cloud, write the device certificate to the device using the same
<sec_tag>you used for the
KEYGENcommand. See Managing and Flashing Credentials for details.
After flashing the credentials, your device contains the private key in the
<sec_tag>provided to the
KEYGENcommand, as well as a device certificate.
To communicate with nRF Cloud your device also needs an AWS Root CA certificate.
Write the AWS Root CA certificate to your device, using the same
<sec_tag>you used for the
The device now has the credentials it needs to use all of the nRF Cloud APIs:
- a AWS CA certificate
- a private key
- a device certificate for MQTT
Tell nRF Cloud about the certificate or public key, depending upon your broad use case:
Devices that use MQTT or the nRF Cloud FOTA service must be provisioned. If this applies, use the ProvisionDevices endpoint to upload the device certificate, provision the device on nRF Cloud, and add it to your nRF Cloud account.
If the device does not need to be provisioned but uses nRF Cloud REST APIs that require JWTs, you must register its public key through the RegisterPublicKeys endpoint.
Assuming your device has an active SIM card installed, you should see the device in your account and connected after a restart.
You can create credentials created off-device and later load them into the device. This method can be considered less secure, because it exposes the private key.
To create a device certificate and a key pair (public key and private key), use the create_device_credentials.py script. See the README for additional details. For the
-cnparameter (Common Name) to
create_device_credentials.pyuse your device's nRF Cloud device ID. If you wish to use the device's internal UUID, see How to obtain the nRF9160's UUID.
This step requires a CA certificate (and its private key). If you do not already have one, use the create_ca_cert.py script to create a CA and key that you can use to sign all your device certificates.
Provision the device certificate to the ProvisionDevices endpoint.
A successful call to
ProvisionDeviceswill result in a device which is both provisioned and associated with your nRF Cloud account. Devices that use MQTT or the nRF Cloud FOTA service must be provisioned and associated. If the device does not need to be provisioned but needs to use certain nRF Cloud REST APIs, provide the public key generated above to the RegisterPublicKeys endpoint.
Write the private key to your device so that it can communicate with nRF Cloud through MQTT (for mTLS) or REST (for signing JWTs). Use the the desired
16842753for nRF Cloud. See Managing and Flashing Credentials for details.
If the device uses MQTT to connect to nRF Cloud then it needs the device certificate generated above. Write the device certificate to your device, using the same
The device now has:
- an AWS CA certificate
- a private key,
- a device certificate for MQTT
It is ready to interact with nRF Cloud through REST or MQTT.
Manage the credentials using the
CMNG AT command, either through the AT command directly or the LTE Link Monitor Certificate Manager.
To use the Certificate Manager, perform the following steps:
Copy and paste the CA certificate into the top box, labeled
Copy and paste the device certificate into the middle box, labeled
Copy and paste the private key into the bottom box, labeled
If you used
KEYGENto generate a private key, do not input any data into the
Private Keybox. This would overwrite the key created by
KEYGENand you would need to start the process over.
This screenshot of the LTE Link Monitor Certificate Manager depicts flashing a new client (device) certificate to
Click Update certificates. The terminal returns the following:
These commands are difficult to use with the LTE Link Monitor Terminal, because it does not properly format the line breaks. If you are using the LTE Link Monitor, use its Certificate Manager.
To write a CA certificate to your device, give the following AT command:
To write a device certificate to your device, give the following AT command:
To write a private key to your device, give the following AT command: