Issue - Raspberry Pi Button Data Sending To Cayenne Using API

Hi guys!
I’m having problem with sending data to Cayenne.

I’m using this code: Cayenne, Python and MQTT Tutorials-1 - Digital Input : 7 Steps - Instructables

When I start the script, my raspberry pi connects to cayenne but when I press the button, I’m not getting Button Pressed! message and my widget in cayenne does not change to 1.

@cagriserpin do not create multiple topics.
what does the terminal output message. can you share here.
Also in previous topic you said cayenne python library gave you same issue and did not connect, so is it working now?

Yes it is! I don’t know why but it’s working now :smiley:
Here is the terminal output:
Connecting to mqtt.mydevices.com:1883
Connected with result code 0
SUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/cmd/+

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/sys/model
Python

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/sys/version
1.1.0

can you provide more output from the terminal? does it output anything when the button is pressed?

Like I said first, no. Just this and nothing else. I’m pretty sure that i connected button right. If you want I can send you a picture of my connection.

UPDATE:
Somehow I’m getting message when I press the button but issue still continues. Here is the output:

Connecting to mqtt.mydevices.com:1883
Connected with result code 0
SUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/cmd/+

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/sys/model
Python

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/sys/version
1.1.0

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/data/3
1

Button pressed

PUB v1/53494ac0-0dd8-11e9-a056-c5cffe7f75f9/things/aefa5470-338c-11e9-8cb9-732fc93af22b/data/3
0

Button released

this is correct. what is the issue now? you should see a widget auto created on the dashboard.

Nope. Widget is not changing :confused:

If you want I can give you my TeamViewer id and password, so you can check what is wrong easily?

Oh I realised something. I can see changes in android app but I can’t see it on web.

First delete the widget from the dashboard then make the following changes in your code and run it. next, it will auto create a green temporary widget add it by pressing + on top right of the widget.

def send_on():
      client.virtualWrite(3, 1, "digital_sensor", "d") #Publish "1" to Cayenne MQTT Broker Channel 3
      print("Button pressed\n")

def send_off():
  client.virtualWrite(3, 0, "digital_sensor", "d") #Publish "0" to Cayenne MQTT Broker Channel 3
  print("Button released\n")

Thank you so much. It works now! You’re the best!

2 Likes