Skip to content

Cookie preferences

We use cookies for our own analytics, to see how our campaigns perform and, if you allow it, to load content from other services such as the Google site search. We never sell your data. Necessary cookies keep the site working and cannot be switched off. See our Cookie Policy for details and our Privacy Policy for how we handle personal data.

Security, load balancing and remembering your cookie choice.

Show us which pages people read, how they find the site and where they get stuck, so we can improve it (Google Analytics, Microsoft Clarity).

Show us which of our ad campaigns bring visitors to the site and remember the campaign or partner link you arrived from (Google Ads, LinkedIn, Meta, partner program). We do not use these cookies to build advertising profiles.

Load the site search from Google when you use it. Google sets its own cookies and shows ads in the search results.

© 2026 The ThingsBoard Authors
180 Try for free

ThingsBoard Cloud

Choose your data region

Your data stays in the region you choose, for residency and compliance. No credit card required.

Rather run it yourself? Install on your own servers

Send Telemetry to Edge via MQTT

Send sensor readings from a Python script to ThingsBoard Edge over MQTT using the paho-mqtt client. Devices connect directly to the Edge instance — use the hostname or IP address of your Edge instance in place of the ThingsBoard Server URL.

  1. Install paho-mqtt:

    Terminal window
    pip install paho-mqtt
  2. Copy your device’s Access Token from Entities → Devices → [device] → Copy access token on the Edge instance.

import paho.mqtt.client as mqtt
import json
import time
EDGE_HOST = "192.168.1.100" # replace with your Edge host
ACCESS_TOKEN = "YOUR_ACCESS_TOKEN"
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION1)
client.username_pw_set(ACCESS_TOKEN)
client.connect(EDGE_HOST, 1883, 60)
client.loop_start()
try:
while True:
payload = json.dumps({"temperature": 22.5, "humidity": 60})
client.publish("v1/devices/me/telemetry", payload, qos=1)
print(f"Sent: {payload}")
time.sleep(5)
finally:
client.loop_stop()
client.disconnect()

The script publishes a JSON telemetry payload every 5 seconds. Edge stores readings locally and forwards them to the ThingsBoard Server through the root rule chain when a cloud connection is available.

  1. Log in to the Edge instance and go to Entities → Devices.
  2. Open the device and click the Latest telemetry tab.
  3. Confirm that temperature and humidity values appear.

For the full list of MQTT topics and payload formats, see MQTT API.