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

Software

Create channel

  1. Open your channels.

    Sign in to ThingSpeak with your MathWorks account, or create one, and open Channels → My Channels.

  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.

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.

  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.

  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.

    The password is shown only once: save it now.

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.