12 Replies Latest reply on Feb 4, 2016 1:10 PM by user_305201620 Branched to a new discussion.

    How to publish data to AWS IoT

    raghu_vrb

      Hello abirjepatil vikr user_305201620

       

      I am able to build publish demo app and load it on to device. I have created my AWS account, created thing and downloaded the certificates. The downloaded certificates have different names and different extensions than those certificates in resources/apps/aws_iot and resources_apps/secure_mqtt..

       

      Firstly, what are the certificates that i should be placing and in which folder and with what name and extension?

       

      Thanks,

      Raghu

        • 1. Re: How to publish data to AWS IoT
          mifo

          Take a look at the following doc: Creating an AWS WICED IoT solution

           

          I believe page 53 has the information you are looking for related to loading the certs.

          • 2. Re: How to publish data to AWS IoT
            abirjepatil

            Hey Raghu,

             

            You need to rename the files downloaded from AWS in the following way:-

             

            1d1afde412-certificate.pem.crt will be renamed to client.cer

            1d1afde412-private.pem.crt has to be renamed to privkey.cer.

             

            [1d1afde412-certificate.pem.crt is just an example. Your files will have a different string before -certificate.pem.crt]

             

            Once you have renamed the files, you need to place them in the resources->apps->aws_iot folder.

             

            You dont need to replace the rootca.cer.

             

            All you need is the client.cer and privkey.cer to get the demo working.

             

            Hope that helps.

             

            Best Regards,

            Abhishek

            • 3. Re: How to publish data to AWS IoT
              raghu_vrb

              Hi Abhishek,

               

              thanks a lot for your reply. But, still i am not sure if my data getting pushed to my account correctly. I created a name called thing1, in publisher.c, WICED_TOPIC and CLIENT_ID both i named as "thing1". Is this fine?

               

              Also, how about port number? Do i need to change the port number somewhere in the code??

               

              Also, what is the best way to see the data i pushed on AWS console?

              • 4. Re: How to publish data to AWS IoT
                raghu_vrb

                Abhishek,

                 

                small correction.. i created a thing in aws console called "thing1".. for which i generated certificates and the same are replaced with existing ones as u suggested..

                 

                thanks,

                raghu

                • 5. Re: How to publish data to AWS IoT
                  abirjepatil

                  Hey Raghu,

                   

                  To verify if your messages are being published to the AWS you can use the AWS MQTT Client.

                   

                  Steps:-

                  1. Go to AWS IoT.

                  2. Click on MQTT Client.

                  mqttclient.png

                   

                  3. Select Generate Client ID

                  mqtt_client_connect.png

                   

                   

                  4. Enter the topic name that you have assigned to your publisher.['thing1']. In my case, it is WICED_BULB

                  mqttckue.png

                   

                  5. You will see messages being published for the topic subscribed in the left hand side corner.

                  messages.png

                   

                   

                  Let me know if that works.

                   

                  Thanks,

                  Abhishek.

                  • 6. Re: How to publish data to AWS IoT
                    raghu_vrb

                    Hi Abhishek,

                     

                    Once again thanks a lot for your help... I followed the exact steps mentioned by you and the result is same as shown in the last picture you posted... it's saying 'YOU DONT HAVE ANY MESSAGES IN THIS SUBSCRIPTION'...

                     

                    what else could be missing??

                     

                    Regards,

                    Raghu

                    • 7. Re: How to publish data to AWS IoT
                      abirjepatil

                      Hey Raghu,

                       

                      In order for the board to publish messages to the AWS IoT, you need to press the SW2.

                      I am not sure, which board you are using.

                      You can try both the buttons till you see, publishing message on the UART.

                       

                      Let me know if that works.

                       

                      Best Regards,

                      Abhishek.

                      • 8. Re: How to publish data to AWS IoT
                        raghu_vrb

                        Hi Abhishek,

                         

                        In my code, i have removed what comes with example. As per the code i am running now, it will publish the data continuosuly.. in fact, on the debug terminal i can see the prints saying publish success.... The messages are going out for sure.. but to where is my question??

                         

                        I have two things to confirm with you again... if my name is thing1, is the topic name also same or do i need to append something? Also, what should i be using for client id in the code??

                         

                        Thanks,

                        Raghu

                        • 9. Re: How to publish data to AWS IoT
                          abirjepatil

                          Well, to subscribe for the messages that you are publishing you do not need to create a thing. The topic name that you have hardcoded must match the one that you use to subscribe the messages in the mqtt client part.

                          If you are trying to see the publisher and subscriber part, I would recommend using the demo->aws_iot->publisher application.

                          It would be a good starting point for what you are trying to achieve.

                           

                          Best Regards,

                          Abhishek.

                          • 10. Re: How to publish data to AWS IoT
                            raghu_vrb

                            Hi Abhishek,

                             

                            Sorry if my questions are confusing. Yes, i am using the aws_iot/pub_sub/publisher example only and modified the code such that the program will start publishing the data continuously without requiring any user intervention like button press.

                             

                            Now, in the code i have named the topic as "thing1", the thing name which i created in AWS... for client id also i used as "thing1" only... now that i have all the certificates in place as you suggested... i am sure data is going out to AWS, but why i am not able to see the data when i subscribe to same topic in MQTT client section?

                             

                            Thanks,

                            Raghu

                            • 11. Re: How to publish data to AWS IoT
                              raghu_vrb

                              Hi Abhishek,

                               

                              I am still not able to conclude the thing that whether my messages are reaching AWS or not? Any further suggestions are appreciated...

                               

                              Thanks,

                              Raghu

                              • 12. Re: How to publish data to AWS IoT
                                user_305201620

                                I would make sure you have everything good to go on the AWS IoT side of things before trying anything out with WICED SDK.  You can verify this using a PC-run MQTT client such as MQTT.fx.

                                 

                                AWS has a link to a replay of a "Getting Started with AWS IoT" Webinar posted to YouTube:

                                AWS January 2016 Webinar Series - Getting Started with AWS IoT - YouTube

                                 

                                Skip forward to about the 25:00 mark; at that point the material starts to cover the whole process of generating certificates and publishing / subscribing to topics in more detail.  If possible, I recommend downloading and installing MQTT.fx - this is a utility you can run that will let you publish and subscribe to topics on AWS IoT and the YouTube video gives you the exact steps necessary to configure MQTT.fx such that it works properly.  Once you've verified connectivity using MQTT.fx, you can attempt to publish and subscribe with with the WICED SDK apps.

                                 

                                Basically you need to do the following:

                                - Create your "Thing" in AWS

                                - Create certificates in AWS, mark them ACTIVE and then associate them with your "Thing"

                                - Define a Policy in AWS

                                 

                                The video above goes over all these steps.  If you skip something you'll likely run into the issues you're seeing.