Hi,
I’ve got the errno121 with this code, any ideas?:
#This programe reads sensor DHT12 and sends the data to Cayenne trought MQTT
import paho.mqtt.client as mqtt
import time
import sys
import smbus
addr = 0x5C
bus = smbus.SMBus(1)
time.sleep(1) #Sleep to allow wireless to connect before starting MQTT
username = "MQTT Username From Dashboard"
password = "MQTT Passsword From Dashboard"
clientid = "MQTT Client ID From Dashboard"
mqttc = mqtt.Client(client_id=clientid)
mqttc.username_pw_set(username, password=password)
mqttc.connect("mqtt.mydevices.com", port=1883, keepalive=60)
mqttc.loop_start()
topic_dht12_temp = "v1/" + username + "/things/" + clientid + "/data/1"
topic_dht12_humidity = "v1/" + username + "/things/" + clientid + "/data/2"
while True:
try:
data = bus.read_i2c_block_data(addr,0x00,5)
temp12=str(data[2]) #+ str(data[3])
humidity12=str(data[0])# + str(data[1])
if temp12 is not None:
temp12 = "temp,c=" + str(temp12)
mqttc.publish(topic_dht12_temp, payload=temp12, retain=True)
if humidity12 is not None:
humidity12 = "rel_hum,p=" + str(humidity12)
mqttc.publish(topic_dht12_humidity, payload=humidity12, retain=True)
time.sleep(1)
except (EOFError, SystemExit, KeyboardInterrupt):
mqttc.disconnect()
sys.exit()