Deploying IoT Data Streams to Ubidots

Stream sensor data from ALPON X5 AI or ALPON X4 to Ubidots over MQTT: create a Ubidots device and token, package a paho-mqtt publisher as an arm64 container, deploy it through ALPON Cloud, and watch the values arrive in real time.

Stream IoT data to Ubidots from ALPON

Monitor your device’s data from anywhere with a few clicks. This guide connects an ALPON X5 AI or ALPON X4 to Ubidots over MQTT: you create a device and token in Ubidots, package a small paho-mqtt publisher as an arm64 container, deploy it through ALPON Cloud, and see temperature and humidity values arrive in real time.

ALPON X5 AI ALPON X4 Ubidots MQTT
ALPON · Tutorial · Cloud integration · MQTT
How do I send data from ALPON to Ubidots?

Create a Blank Device in Ubidots, add its variables, and generate a device token. Then build a Python container that publishes JSON to industrial.api.ubidots.com:1883 on the topic /v1.6/devices/<DEVICE_LABEL> using the token as the MQTT username, push it to your Sixfab Container Registry, and deploy it from the Applications → Deploy panel on ALPON Cloud with the API_TOKEN and DEVICE_NAME environment variables. The values appear on the device page in Ubidots within seconds.

Overview

Ubidots is a user-friendly IoT platform for collecting, visualizing, and analyzing device data in real time. A Ubidots device represents the data your ALPON sends; its variables (for example temperature and humidity) are what you plot on dashboards. This guide walks through creating that device, then packaging an MQTT publisher as a container so it runs consistently on the ALPON and is managed from ALPON Cloud.

The steps below are identical on ALPON X4 and ALPON X5 AI.

Ubidots web dashboard showing temperature and humidity widgets fed by an ALPON device
A Ubidots dashboard visualizing the values published by the ALPON.
Before you start

You need an ALPON X5 AI or ALPON X4 registered on ALPON Cloud, a Ubidots account (the free plan is enough; paid plans add features), and Docker installed on your build machine to build and push the image. New to container deployment? Start with Containerize Apps for ALPON.

  1. 1

    Log in to your Ubidots account

    Open the Ubidots website and sign in with your username and password. If you don’t have an account yet, create one for free. Once logged in, you land on the Ubidots dashboard (control panel).

    Ubidots sign-in page
    Signing in to Ubidots.
  2. 2

    Create a device in Ubidots

    Open the Devices section

    In the Ubidots dashboard, click the Devices tab in the top menu. The page lists any existing devices. To create a new one, click the Create Device button or the + icon in the top-right corner.

    Ubidots Devices page with the Create Device button
    The Devices page in Ubidots.

    Select the device type

    Ubidots prompts you to choose a device type. Select Blank Device — it lets the ALPON send data without a predefined template — and proceed.

    Ubidots device type selection with Blank Device highlighted
    Choosing Blank Device as the device type.
    Official device creation guide

    For further details on creating a virtual device, see the Ubidots Device Creation Guide.

    Enter the device details

    In the form, name your device (e.g. ALPON X4). Ubidots auto-generates a unique Device Label for API use (e.g. alpon-x4); you can edit it. Click Next to finish. Note the label — the MQTT topic in step 6 is built from it.

    Ubidots device creation form with the device name and Device Label fields
    Naming the device and setting its Device Label.
  3. 3

    Verify the device and add variables

    After creation, Ubidots redirects you to the new device’s page, where you can view its basic information (name, label, creation date, and so on).

    Ubidots device page showing the new device's name, label, and creation date
    The device page right after creation.

    Define one variable per value the ALPON sends. The client in this guide publishes temperature and humidity, so create two variables:

    1. From the Devices page, click your ALPON device to open its details.
    2. Click the + Add Variable button (or the + icon in the top-right corner, then + Add Variable) to add a Raw variable.
    3. A variable named New variable appears. Click its name to edit it: set the name (Temperature for one, Humidity for the other) and, optionally, the description, color, or API label.
    4. Repeat so that both Temperature and Humidity exist.
    5. Save your changes. The device is ready to receive data.
    Ubidots device page with Temperature and Humidity raw variables added
    The device with its Temperature and Humidity variables.
  4. 4

    Obtain a device token

    The ALPON authenticates to Ubidots with a device token, which the MQTT client sends as its username:

    1. From the top navigation bar, go to Devices → Devices.
    2. Click your ALPON device to select it.
    3. In the device options, click Manage Device Tokens.
    4. A drawer slides out from the right. Click + Add new token.
    5. Give the token a name and select one, both, or neither of the available permissions (leave blank for no permissions).
    6. Click the green checkmark to confirm, then copy the token.
    Keep the token confidential

    Do not share the token or commit it to source control. If it is compromised, generate a new one from the same drawer. For more on managing tokens, see Ubidots Security: Managing Device Tokens.

  5. 5

    Write the Dockerfile

    Packaging the publisher as a container makes it run the same way on every device. On your build machine, create a new project directory and, inside it, a file called Dockerfile with this content:

    Dockerfile
    FROM python:3.11-slim
    
    RUN pip install --no-cache-dir paho-mqtt
    
    WORKDIR /app
    
    COPY send_to_ubidots.py .
    
    CMD ["python", "send_to_ubidots.py"]

    This tells Docker to start from a lightweight Python 3.11 image, install the paho-mqtt library, set up a working directory, copy the script into the container, and run it when the container starts.

  6. 6

    Write the MQTT client script

    The client talks to the Ubidots MQTT broker with these settings; the token and device label are read from environment variables so the image contains no secrets:

    Broker industrial.api.ubidots.com
    Port 1883
    Topic /v1.6/devices/<DEVICE_NAME> — filled from the DEVICE_NAME environment variable (your Ubidots Device Label from step 2).
    Client ID alpon_x4_client
    Username The device token from step 4, read from API_TOKEN.
    Password Empty string.

    In the same directory as the Dockerfile, create send_to_ubidots.py and paste the following code:

    python · send_to_ubidots.py
    import time
    import os
    from paho.mqtt import client as mqtt_client
    
    broker = 'industrial.api.ubidots.com'
    port = 1883
    topic = f"/v1.6/devices/{os.getenv('DEVICE_NAME', 'default_device_name')}"
    client_id = "alpon_x4_client"
    username = os.getenv('API_TOKEN', 'default_api_token')
    password = ""
    
    def connect_mqtt():
        def on_connect(client, userdata, flags, rc):
            if rc == 0:
                print("Connected to MQTT Broker!")
            else:
                print(f"Failed to connect, return code {rc}\
    ")
    
        client = mqtt_client.Client(client_id)
        client.username_pw_set(username, password)
        client.on_connect = on_connect
        client.connect(broker, port)
        return client
    
    def publish(client):
        while True:
            time.sleep(2)
            msg = '{"temperature": 25, "humidity": 60}'
            result = client.publish(topic, msg)
            status = result[0]
            if status == 0:
                print(f"Sent: `{msg}`")
            else:
                print(f"Failed to send message to topic {topic}")
    
    def run():
        client = connect_mqtt()
        client.loop_start()
        publish(client)
    
    if __name__ == '__main__':
        run()

    The script connects to the Ubidots MQTT broker, publishes a JSON payload with temperature and humidity every 2 seconds, and prints a line each time a message is sent successfully. Replace the constant values with your own sensor readings when you adapt it.

  7. 7

    Build the image and push it to the Sixfab Container Registry

    The ALPON runs an arm64 processor, so build the image for that architecture from the project directory on your computer:

    bash · build the image
    docker buildx build --platform=linux/arm64 -t ubidots-mqtt-client:latest .

    This creates an image named ubidots-mqtt-client built for the ALPON’s ARM64 architecture. Then log in to ALPON Cloud, open the Sixfab Container Registry page, click + Add Container, and follow the prompts to push the image.

    Deploy Applications

    Visit the Deploy Applications page for all the details on pushing your container image to the Sixfab Container Registry.

  8. 8

    Deploy the container on ALPON

    Once the image is in the registry, open your device in ALPON Cloud, go to the Applications section, and click + Deploy. In the Deploy Container window, use these settings:

    Container Name The application name, e.g. ubidots-mqtt-client.
    Image The ubidots-mqtt-client image and tag you pushed to the Sixfab Container Registry.
    Environment Click + Add More in the environment section and add the two variables in the table below.
    KeyValue
    API_TOKEN<your-token-here> — the device token from step 4
    DEVICE_NAME<your-device-name-here> — the Device Label from step 2

    Click + Deploy to start the container on the ALPON.

    ALPON Cloud Deploy Container window with the ubidots-mqtt-client image and API_TOKEN and DEVICE_NAME environment variables
    The Deploy Container window in ALPON Cloud with the environment variables set.
  9. 9

    View the data on Ubidots

    Now confirm that the device is publishing. Log in to your Ubidots account and go to the Devices section.

    Ubidots Devices list showing the ALPON device with a recent last activity time
    The ALPON device listed under Devices with recent activity.

    Select your device (e.g. ALPON_X4) and check that temperature and humidity values are appearing in real time.

    Ubidots device page showing live temperature and humidity values from the ALPON
    Temperature and humidity values arriving from the ALPON.

    If the data is flowing in, your ALPON is successfully connected to Ubidots. Build a dashboard from the variables to visualize them.

Ready when…
  • The ubidots-mqtt-client container shows as running in the Applications section and its logs print Connected to MQTT Broker! followed by Sent: lines.
  • The Temperature and Humidity variables on the Ubidots device page update every few seconds.

The ALPON is now streaming data to Ubidots. Swap the constant values in send_to_ubidots.py for real sensor readings and add dashboard widgets for the variables.

Production image policy: Replace floating :latest references with a reviewed immutable tag or digest, then record the selected version for rollback.


Did this page help you?