I want to send data to ThingsBoard and display it in widget On dashboard.
By Following this tutorial I have:
- Created Device on ThingsBoard by logging into Tenant Administrator.
Device Description:
Device created sucessfully:
Device Access Token:
- 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:
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