---
title: "Send Pico LTE data to ThingSpeak over MQTT"
description: "Publish data from the Pico LTE to a ThingSpeak channel over MQTT, and subscribe to its fields, over the cellular connection."
url: "https://docs.sixfab.com/cellular/pico-lte/micropython-sdk/thingspeak-mqtt/"
last_updated: "2026-10-12"
---

# Send Pico LTE data to ThingSpeak over MQTT

Publish data from the Pico LTE to a ThingSpeak channel over MQTT, and subscribe to its fields, over the cellular connection.

These examples publish data from the Pico LTE to a [ThingSpeak](https://thingspeak.com/) channel over MQTT, and subscribe to the channel’s fields, over the cellular connection. No extra hardware is needed.

## 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/).
- **ThingSpeak account**: A MathWorks account.

## Create channel

1. **Open your channels.**

   Sign in to [ThingSpeak](https://thingspeak.com/login) with your MathWorks account, or create one, and open **Channels → My Channels**.

   ![ThingSpeak Channels menu open with an arrow pointing to My Channels](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_My_Channels.webp)

2. **Create channel.**

   Click **New Channel**, tick **Field 1** and **Field 2**, set the other values as you need (they can be changed later) and click **Save Channel**.

   ![ThingSpeak New Channel form named Pico LTE with Field 1 test1 and Field 2 test2 enabled](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_New_Channel.webp)

The channel has these tabs: **Private View** (only you see it), **Public View** (selected fields and charts, if the channel is public), **Channel Settings** (edit, clear or delete the channel), **Sharing** (private, public or shared with given users), **API Keys** (to read and write the channel) and **Data Import/Export**. The channel ID is shown on the channel page.

## Create MQTT device

A ThingSpeak MQTT device holds the credentials of your MQTT client and the channels it may use.

1. **Open MQTT devices.**

   In the ThingSpeak menu, click **Devices → MQTT**, then **Add a new device**.

   ![ThingSpeak Devices menu open with an arrow pointing to MQTT](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_MQTT_Devices.webp)

   ![ThingSpeak MQTT Devices page with an arrow pointing to the Add a new device button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_Add_a_new_Device_MQTT_Devices.jpg)

2. **Describe device.**

   Enter a name and, optionally, a description. Under **Authorize Channels**, select your channel and click **Add Channel**; repeat for each channel, and allow publish and subscribe as needed. Click **Add Device**.

   ![ThingSpeak Add a new device dialog: name Pico LTE, channel Pico LTE authorized to publish and subscribe](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_Add_a_new_Device_MQTT_Devices_Information.webp)

3. **Save credentials.**

   ThingSpeak shows the client ID, the username and the password of the device. Click **Download Credentials → Plain Text** and keep the file, then click **Done**.

   > [!WARNING]
   > The password is shown only once: save it now.

   ![ThingSpeak New Device Added dialog with MQTT Client ID, Username, Password and Download Credentials button](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico_LTE_ThingSpeak_MQTT_Credentials.webp)

The device is listed on the MQTT Devices page; **Edit** changes its settings and channels.

## Run examples

The scripts are in the `examples/thingspeak` folder of the [SDK repository](https://github.com/sixfab/pico_lte_micropython-sdk).

**Publish**

1. **Set channel and credentials in config.json.**

   ```json
   {
       "thingspeak": {
           "channel_id": "YOUR_CHANNEL_ID",
           "mqtts": {
               "client_id": "DEVICE_MQTT_CLIENT_ID",
               "username": "DEVICE_MQTT_USERNAME",
               "password": "DEVICE_MQTT_PASSWORD",
               "pub_topic": "YOUR_MQTT_TOPIC"
           }
       }
   }
   ```

   The publish topic is `channels/[CHANNEL_ID]/publish`.

2. **Run mqtt_publish.py.**

   Open `examples/thingspeak/mqtt_publish.py` in Thonny and click **Run**. It publishes 30 to field 1 and 40 to field 2.

   ![Thonny with the ThingSpeak mqtt_publish.py example of the Pico LTE SDK open](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico-LTE-ThingSpeak-with-MQTT-Publish.png)

   ```text
   INFO: Publishing data to ThingSpeak...
   INFO: Result: {'status': 0, 'response': ['OK'], 'interval': 0}
   ```

3. **Check channel.**

   The values appear in the channel’s charts.

   ![ThingSpeak channel Pico LTE with Field 1 at 30 and Field 2 at 40 in the channel charts](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico-LTE-ThingSpeak-Publishing-Data.jpg)

**Subscribe**

1. **Set channel, credentials and topics in config.json.**

   ```json
   {
       "thingspeak": {
           "channel_id": "YOUR_CHANNEL_ID",
           "mqtts": {
               "client_id": "DEVICE_MQTT_CLIENT_ID",
               "username": "DEVICE_MQTT_USERNAME",
               "password": "DEVICE_MQTT_PASSWORD",
               "sub_topics": [
                   ["YOUR_MQTT_TOPIC", QOS]
               ]
           }
       }
   }
   ```

   - ThingSpeak MQTT supports QoS 0 only.
   - `[["channels/[CHANNEL_ID]/subscribe/fields/+", 0]]` subscribes to all fields of the channel.
   - `[["channels/[CHANNEL_ID]/subscribe/fields/[FIELD_NAME]", 0]]` subscribes to one field, such as `field1`.

2. **Run mqtt_subscribe.py.**

   Open `examples/thingspeak/mqtt_subscribe.py` in Thonny and click **Run**. The log shows the messages of the subscribed fields:

   ![Thonny with the ThingSpeak mqtt_subscribe.py example of the Pico LTE SDK open](https://docs.sixfab.com/wp-content/uploads/sixfab-docs/Pico-LTE-ThingSpeak-with-MQTT-Subscribe.png)

   ```text
   INFO: Subscribing to topics...
   INFO: Result: {'status': 0, 'response': ['+QMTSUB: 0,1,0,0'], 'interval': 0}
   INFO: Reading messages from subscribed topics...
   INFO: [{'message id': 0, 'topic': 'channels/.../subscribe/fields/...', 'message': '30'}]
   ```
