I am trying to publish a multiple random data using mqtt to send data from raspberry pi to thingspeaks. i want to publish the 10 values of temp to thingspeaks field but it limits me to one value every 15 seconds. so is there anyway to send a list of values every 15 second to graph it with time in thingspeaks channels??
temp = []
current = []
while(1):
# get the system performance data over 20 seconds.
for i in range(10):
temp.append(random.randint(0, 100))
current.append(random.randint(0, 100))
# build the payload string.
payload = "field1=" + str(temp) + "&field2=" + str(current)
# attempt to publish this data to the topic
try:
publish.single(topic, payload, hostname=mqttHost, transport=tTransport, port=tPort,auth=
{'username':mqttUsername,'password':mqttAPIKey})
print (" Published temp =",temp," current =", current," to host: " , mqttHost , " clientID= " , clientID)
except (KeyboardInterrupt):
break
except:
print ("There was an error while publishing the data.")
time.sleep(15)