In this training, you will learn the basics of the Internet of Things. In this part, you will learn how to customize a dashboard to be able to visualize sensor data.
Send random data to the dashboard
import time
import random
import requests
from requests.structures import CaseInsensitiveDict
url = "https://demo.thingsboard.io/api/v1/your_divice_token/telemetry/"
headers = CaseInsensitiveDict()
headers["Content-Type"] = "application/json"
while True:
temp = random.randrange(70)
print(temp)
data = {"temperature": temp}
resp = requests.post(url, headers=headers, data=str(data))
time.sleep(5)
0 comment