UMQTT & AWS IoT



  • Hi, everyone!

    AN HOW-TO-GUIDE FOR UMQTT WITH AWS IOT.

    I've spent almost two days to figure this out. It's finally working so I want to share it with you guys and girls!

    The goal I had was somewhat simple, but a little tricky because of the lack of detailed documentation and almost no posts about the issues in general. Here on the forum, some have posted parts of my solution but no one directly about UMQTT and SSL connection.

    The posts I found related here on the forum was;
    On UMQTT: https://forum.pycom.io/topic/211/simple-mqtt-tutorial
    On SSL: https://forum.pycom.io/topic/320/q-ussl-usage-for-https-problem
    On AWS IoT: https://forum.pycom.io/topic/352/aws-iot-device-support-for-lopy

    Back to the goal I had. I wanted to do the following;

    1. Get my SiPy to communicate with AWS IoT through UMQTT (Link to umqtt.simple lib: https://goo.gl/0Umf9Y )
    2. Subscribe the UMQTT topic on my AWS account.

    Follow This

    Setup AWS certificates by following the steps in this https://goo.gl/Qu5Zs3 tutorial. I will advise to download the project code and make it run on your machine (PC). This project runs with regular MQTT for Python, when you have this project running you know that certificates on AWS are correct setup.

    The following https://goo.gl/eCFlRq pictures shows how your AWS IoT section should look like after completion of the before mentioned tutorial (commands done with AWS CLI).

    The Code

    Download and look it over. Code: https://github.com/juwul/umqtt_aws_iot

    Some tips I found.

    1. The keepalive param on the MQTT connection should be high because it may take some time for the certificates to be verified.
    2. Do not split up the SSL configurations and the construction of MQTTClient. I saw some example in my search for solutions where first the certification configurations are set and afterward the connection is called or vice versa. Once again I did not have any luck with those type of settings so I will recommend to set it up with ssl_params in the construction call. For reference see the note by user @daniel in this post: https://forum.pycom.io/topic/320/q-ussl-usage-for-https-problem/4
      Daniel explains that the SSL handshake needs to be done while connecting as I do (minor differences because it’s sockets, but you get the point).

    Thanks to

    Mario Cannistrà – Profile: https://www.hackster.io/mariocannistra for the easy step-by-step AWS CLI instructions and to @daniel's note about doing SSL handshake in the right way order.



  • @bucknall Hi and thanks.

    To all following the guide please share results. I did not have a board available when I finished up the code so some confirmation on it running would be great :)


  • administrators

    Hi @juriw

    Thanks for sharing this! I'm sure this will be of great help to many people! :)


Log in to reply
 

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.