great. but the dial for the ADS1015 and the graph didn’t move at all
Cayenne authentication info. This should be obtained from the Cayenne Dashboard.
MQTT_USERNAME = “lalala”
MQTT_PASSWORD = “lilili”
MQTT_CLIENT_ID = “lululu”
The callback for when a message is received from Cayenne.
def on_message(message):
print("message received: " + str(message))
# If there is an error processing the message return an error string, otherwise return nothing.
client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)
For a secure connection use port 8883 when calling client.begin:
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883, loglevel=logging.INFO)
i = 0
timestamp = 0
adc = ADS1015()
channel = 0
gain = 1
t = 0
while True:
client.loop()
data = adc.read_adc(channel, gain)
t += 0.1
time.sleep(0.1)
client.virtualWrite(1, data)
timestamp = time.time()
first of all what is -15 value of ads? Also can you private message me your account email id
yes -15 is correct
once you run the code, do you see green widgets on the dashboard?
also do this change in your code:
timestamp = 0
while True:
client.loop()
if (time.time() > timestamp + 10):
data = adc.read_adc(channel, gain)
t += 0.1
client.virtualWrite(1, data)
timestamp = time.time()
you might need to check indentation for the above code.
I found the widget. I is at the nonexistant Arduino. and it shows values! but very static values. and I cannot change it to a tachometer
to change widget type, you need to specify the data type. for it change this in your code:
client.virtualWrite(1, data, "analog_sensor", "null")
once done, run the code. you will see a green widget. on the top right of the green widget, there will be a “+”. Click it, to make it permanent. once done, you see a clog wheel, on the top right of the widget. Click it, to open the setting and change the widget type to gauge or any type you want.
Yeah looks much better this way