Search code examples
pythonraspberry-piibm-cloudiot

IoT Python app with a Raspberry Pi and Bluemix: Pushing the button doesn't work


I did the following tutorial to connect my Raspberry Pi with an application on Bluemix using the IoT Foundation:

https://developer.ibm.com/bluemix/2015/04/02/tutorial-using-a-raspberry-pi-python-iot-twilio-bluemix/

I have the following problem:

If I press the button on my Pi it only prints out "Button pushed" in the Pi terminal.

I don't get any SMS send on my phone and there is now entry in the Log from Twilio.


Solution

  • Turns out the IBM IoT Foundation library changed in the way it parses JSON... Also, I had the code hardcoded to expect USA phone numbers. I added a check for USA phone numbers as well.

    Change line 25

    buttonPushed = cmd.payload["d"]["buttonPushed"]
    

    to

    payload = json.loads(cmd.payload)
    buttonPushed = payload["buttonPushed"]