Connect Pico LTE to Azure IoT Hub

Connect the Pico LTE to Azure IoT Hub over MQTT on the cellular connection, with X.509 certificates: publish to the device twin and receive cloud-to-device messages.

These examples connect the Pico LTE to Azure IoT Hub over MQTT on the cellular connection: they publish device-to-cloud data to the device twin and receive cloud-to-device messages. The board authenticates with X.509 certificates.

Before you begin

Required

Hardware

  • Sixfab Pico LTE or Pico LTE 2Registered and active in Sixfab Connect, connected to the computer with the micro USB cable.

Software

Create IoT hub

  1. Start new IoT hub.

    In the Azure portal, search for IoT Hub, open the service and click Create IoT Hub.

  2. Set resource group and name.

    Select a resource group, or click Create new, and name the hub: the IoT hub name goes into config.json. Check the other settings, such as the pricing in the Management tab, and click Review + create.

  3. Create hub.

    Review the settings and click Create. When Azure has deployed the hub, click Go to resource.

Create certificates and device

  1. Create certificates.

  2. Add intermediate CA certificate to hub.

    In the hub’s menu, search for Certificates and open it, then click Add.

    Enter a certificate name, select certificateDirectory/certs/azure-iot-test-only.intermediate.cert.pem, tick Set certificate status to verified on upload and click Save.

  3. Add device.

    In the hub’s menu, search for Devices, open it and click Add Device.

    Enter the device ID, the device name used when you created its certificate; it also goes into config.json. Select X.509 CA Signed as the authentication type and click Save.

  4. Download root certificate.

    Download the DigiCert Global Root G2 certificate, the root certificate of Azure IoT Hub, and save it as cacert.pem.

Upload certificates to board

  1. Create folder named cert.

    Outside the certificate directory of the previous section.

  2. Copy certificates into it, renamed.

    • certificateDirectory/certs/[DEVICE_NAME].cert.pem → client.pem
    • certificateDirectory/private/[DEVICE_NAME].key.pem → user_key.pem
    • the downloaded root certificate, cacert.pem
  3. Upload cert folder to root of board.

On the first run, the SDK moves the certificates into the module’s secure storage and deletes them from the board’s file system.

Run examples

The scripts are in the examples/azure folder of the SDK repository.