I want to send data to ThingsBoard and display it in widget On dashboard.

By Following this tutorial I have:

  1. Created Device on ThingsBoard by logging into Tenant Administrator.

Device Description:

enter image description here

Device created sucessfully:

enter image description here

Device Access Token:

enter image description here

  1. Created MQTT client in python with the access token of my device and publish data there.

But Data was not received on the platform as my devices latest telemetry was not showing any data.

Image showing DH11 Device latest telemetry:

enter image description here

Python Code:

import paho.mqtt.client as paho             #mqtt library
import os
import json
import time
from datetime import datetime

ACCESS_TOKEN='NN7QEiWaX6mxPRnVdJsQ'                 #Token of your device
broker="demo.thingsboard.io"                #host name
port=1883                       #data listening port

def on_publish(client,userdata,result):             #create function for 
    print("data published to thingsboard \n")
client1= paho.Client("control1")                    #create client object
client1.on_publish = on_publish                     #assign function to 
client1.username_pw_set(ACCESS_TOKEN)               #access token from 
thingsboard device
client1.connect(broker,port,keepalive=60)           #establish connection

while True:

   ret= client1.publish("v1/devices/me/telemetry",payload) #topic- 
   print("Please check LATEST TELEMETRY field of your device")

What might be the issue? I am looking ahead for your suggestions in fixing it. Thanks in Advance.

EDIT: I have reported this Issue on github as well


I'm not familiar with this application, but if security allows use MQTT.fx to subscribe to this topic and sniff what is being published. Could be malformed JSON? Considering they don't appear to require TLS this should be possible.

Also, it's been awhile since I've used Python, but your semicolons confuse me.

  • Upvote for the semicolons. That's not Python :-) – Mawg Jun 3 at 7:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.