---
title: "Connect Pico LTE to Azure IoT Hub"
description: "Connect the Pico LTE to Azure IoT Hub over MQTT with X.509 certificates: publish to the device twin and receive cloud-to-device messages."
url: "https://docs.sixfab.com/cellular/pico-lte/micropython-sdk/azure-iot-hub/"
last_updated: "2026-10-12"
---

# 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 2**: Registered and active in Sixfab Connect, connected to the computer with the micro USB cable.

**Software**

- **Thonny with MicroPython and the Pico LTE SDK**: Set up as in the [quickstart](https://docs.sixfab.com/cellular/pico-lte/quickstart/).
- **config.json**: In the root of the board: [Prepare the configuration file](https://docs.sixfab.com/cellular/pico-lte/micropython-sdk/configuration-file/).
- **Azure account**: [Sign in or register](https://portal.azure.com/#home) at the Azure portal.
- **OpenSSL**: On the computer, to create the certificates.

## Create IoT hub

1. **Start new IoT hub.**

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

   ![Azure portal search for IoT Hub with the IoT Hub service selected](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-1.png)

   ![Azure IoT Hub page with no hubs and the Create IoT hub button marked](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-2.png)

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**.

   ![Azure Create IoT hub Basics tab with Resource group, IoT hub name, Region and Review + create marked](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-3.png)

3. **Create hub.**

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

   ![Azure IoT hub review page for pico-lte hub with the Create button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-4.png)

## Create certificates and device

1. **Create certificates.**

   Follow these steps of Microsoft’s X.509 tutorial on the computer:

   - [Set up the X.509 OpenSSL environment](https://learn.microsoft.com/en-us/azure/iot-dps/tutorial-custom-hsm-enrollment-group-x509?tabs=linux&pivots=programming-language-ansi-c#set-up-the-x509-openssl-environment)
   - [Create the root CA certificate](https://learn.microsoft.com/en-us/azure/iot-dps/tutorial-custom-hsm-enrollment-group-x509?tabs=linux&pivots=programming-language-ansi-c#create-the-root-ca-certificate)
   - [Create the intermediate CA certificate](https://learn.microsoft.com/en-us/azure/iot-dps/tutorial-custom-hsm-enrollment-group-x509?tabs=linux&pivots=programming-language-ansi-c#create-the-intermediate-ca-certificate)
   - [Create the device certificates](https://learn.microsoft.com/en-us/azure/iot-dps/tutorial-custom-hsm-enrollment-group-x509?tabs=linux&pivots=programming-language-ansi-c#create-the-device-certificates)

2. **Add intermediate CA certificate to hub.**

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

   ![Azure IoT Hub menu searched for Certificates, with Certificates under Security settings highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-1.png)

   ![Certificates page of an Azure IoT Hub with the Add button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-2.png)

   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**.

   ![Azure Add certificate panel with name, pem file, verified on upload checked and Save highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-3.png)

3. **Add device.**

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

   ![Azure IoT Hub menu searched for devices, with Devices under Device management highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-4.png)

   ![Devices page of an Azure IoT Hub with the Add Device button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-5.png)

   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**.

   ![Azure Create a device panel with Device ID, X.509 CA Signed authentication and Save highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-Creating-Certificates-6.png)

4. **Download root certificate.**

   Download the [DigiCert Global Root G2](https://cacerts.digicert.com/DigiCertGlobalRootG2.crt.pem) 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.**

   ![Thonny Files panel with the cert folder right-clicked and Upload to / highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/ixfab-Pico-LTE-Azure-IoT-Hub-Connection-Upload-Certificates-1.jpg)

   ![Thonny showing the cert folder uploaded to the Raspberry Pi Pico file system](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/ixfab-Pico-LTE-Azure-IoT-Hub-Connection-Upload-Certificates-2.jpg)

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](https://github.com/sixfab/pico_lte_micropython-sdk).

**Publish**

1. **Set hub and device in config.json.**

   ```json
   {
       "azure": {
           "hub_name": "YOUR_AZURE_IOT_HUB_NAME",
           "device_id": "YOUR_DEVICE_ID"
       }
   }
   ```

2. **Run mqtt_publish.py.**

   Open `examples/azure/mqtt_publish.py` in Thonny and click **Run**.

   ![Azure mqtt_publish.py example open in Thonny IDE](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico-LTE-Azure-IoT-Hub-Connection-MQTT-Publish.png)

   ```text
   INFO: Publishing data to Azure IoT Hub...
   INFO: Certificates uploaded secure storage. Deleting from file system...
   INFO: Certificates found in modem.
   INFO: Result {'status': 0, 'response': ['OK'], 'interval': 0}
   ```

3. **Check device twin.**

   In the hub, open **Devices**, select the device and click **Device Twin**.

   ![Azure IoT Hub device page for first_device with the Device twin button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-5.png)

   The device twin is a JSON document of the device’s configuration and data: the published data is under `reported`. Click **Refresh** if it does not show yet.

   ![Azure Device twin JSON showing the reported property App: Azure MQTT Example](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-6.png)

**Subscribe**

1. **Set hub, device and topic in config.json.**

   ```json
   {
       "azure": {
           "hub_name": "YOUR_AZURE_IOT_HUB_NAME",
           "device_id": "YOUR_DEVICE_ID",
           "mqtts": {
               "sub_topics": [
                   ["[SUB_TOPIC/1]", [QOS]],
                   ["[SUB_TOPIC/2]", [QOS]]
               ]
           }
       }
   }
   ```

   The cloud-to-device topic is `devices/[DEVICE_ID]/messages/devicebound/#`: `"sub_topics": [["devices/[DEVICE_ID]/messages/devicebound/#", 1]]`.

2. **Open Message to Device.**

   In the hub, open **Devices**, select the device and click **Message to Device**: the form sends a cloud-to-device message.

   ![Azure IoT Hub device page with the Message to Device button highlighted](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Sixfab-Pico-LTE-Azure-IoT-Hub-Connection-7.png)

3. **Run mqtt_subscribe.py.**

   Open `examples/azure/mqtt_subscribe.py` in Thonny and click **Run**.

   ![Azure mqtt_subscribe.py example open in Thonny IDE](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico-LTE-Azure-IoT-Hub-Connection-MQTT-Subscribe.png)

4. **Send message.**

   Send a message from the **Message to Device** form. The log shows it:

   ```text
   INFO: Subscribing to topics...
   INFO: {'status': 0, 'response': ['+QMTSUB: 0,1,0,1'], 'interval': 0}
   INFO: Reading messages from subscribed topics...
   INFO: []
   INFO: []
   INFO:
   ['4,"devices/first_device/messages/devicebound/%24.to=%2Fdevices%2Ffirst_device%2Fmessages%2FdeviceBound&%24.ct=text%2Fplain%3B%20charset%3DUTF-8&%24.ce=utf-8","Hello Pico"']
   ```
