1

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 
    callback
    print("data published to thingsboard \n")
    pass
client1= paho.Client("control1")                    #create client object
client1.on_publish = on_publish                     #assign function to 
callback
client1.username_pw_set(ACCESS_TOKEN)               #access token from 
thingsboard device
client1.connect(broker,port,keepalive=60)           #establish connection

while True:

   payload="{"
   payload+="\"Humidity\":60,"; 
   payload+="\"Temperature\":25"; 
   payload+="}"
   ret= client1.publish("v1/devices/me/telemetry",payload) #topic- 
   v1/devices/me/telemetry
   print("Please check LATEST TELEMETRY field of your device")
   print(payload);
   time.sleep(5)

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

1

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.