Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    AWS IoT Core and Shadow on WiPy

    Scheduled Pinned Locked Moved WiPy 2&3
    11 Posts 4 Posters 121 Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B Offline
      bitvijays
      last edited by

      What are the errors you are facing? Are you using threading?

      M 1 Reply Last reply Reply Quote 0
      • M Offline
        milan-nikolic
        last edited by

        This post is deleted!
        1 Reply Last reply Reply Quote 0
        • M Offline
          milan-nikolic @bitvijays
          last edited by

          @bitvijays In the project I am using threading but the error happens even when it is not used.
          The error I get is:

          Socket receive error:  [Errno -76] MBEDTLS_ERR_NET_RECV_FAILED
          

          And it just writes it out a billion times.
          When I use threading to send messages to topic messages are still going out even when error is repeatedly shown, and the shadow is also updated regardless of the error.

          For reading from topic I don't get any errors since I haven't found a way to do it.

          B D 2 Replies Last reply Reply Quote 0
          • B Offline
            bitvijays @milan-nikolic
            last edited by

            @milan-nikolic said in AWS IoT Core and Shadow on WiPy:

            MBEDTLS_ERR_NET_RECV_FAILED

            According to Net Socket Documentation it is Reading information from the socket failed

            Which probably means that either AWS closed your connection or your WiFy is disconnected

            D 1 Reply Last reply Reply Quote 0
            • G Offline
              Gijs
              last edited by

              Hi,
              Im not completely sure on this as I've never tried AWS, but I believe the library is from 2017 and not completely up to par with the latest firmware and AWS API. Did you try the AWS IoT feature through Pybytes (pybytes.pycom.io) and if that works for you?

              M 1 Reply Last reply Reply Quote 0
              • M Offline
                milan-nikolic @Gijs
                last edited by

                @Gijs
                Yes I did try to connect to AWS core over pybytes and it works, at least for sending messages to a topic. I didn't try the shadow feature (if it even exists over pybytes).

                1 Reply Last reply Reply Quote 0
                • M Offline
                  milan-nikolic
                  last edited by

                  Update
                  I managed to connect to both the topic I want to post to and use IoT Shadows, now the only problem I have is that I can't read anything from device shadow or any other topic. Has anyone solved this?

                  1 Reply Last reply Reply Quote 0
                  • D Offline
                    dbada @bitvijays
                    last edited by

                    This post is deleted!
                    1 Reply Last reply Reply Quote 0
                    • D Offline
                      dbada @milan-nikolic
                      last edited by

                      @milan-nikolic Did you manage to solve this issue? I am experiencing the same problem.

                      M 1 Reply Last reply Reply Quote 0
                      • M Offline
                        milan-nikolic @dbada
                        last edited by

                        @dbada Sorry for the late reply. Yes for me the first problem was that I tried to make two MQTT connections one for sub/pub topics one for shadows. You need to first init the AWSIoTMQTTShadowClientand than access the MQTT client with

                        pycomAwsMQTTShadowClient.getMQTTConnection()
                        

                        The next thing is to make sure that the certificate is Activeted. Go to AWS IoT Core console, your thing/security/certificates/Action/Activate

                        And then it works.

                        Code for setting up AWS

                            pycomAwsMQTTShadowClient = AWSIoTMQTTShadowClient(CLIENT_ID)
                            pycomAwsMQTTShadowClient.configureEndpoint(AWS_HOST, AWS_PORT)
                            pycomAwsMQTTShadowClient.configureCredentials(AWS_ROOT_CA, AWS_PRIVATE_KEY, AWS_CLIENT_CERT)
                        
                            pycomAwsMQTTShadowClient.configureConnectDisconnectTimeout(CONN_DISCONN_TIMEOUT)
                            pycomAwsMQTTShadowClient.configureMQTTOperationTimeout(MQTT_OPER_TIMEOUT)
                        
                            
                            pycomAwsMQTTClient = pycomAwsMQTTShadowClient.getMQTTConnection()
                            pycomAwsMQTTClient.configureOfflinePublishQueueing(OFFLINE_QUEUE_SIZE)
                            pycomAwsMQTTClient.configureDrainingFrequency(DRAINING_FREQ)
                            pycomAwsMQTTClient.configureConnectDisconnectTimeout(CONN_DISCONN_TIMEOUT)
                            pycomAwsMQTTClient.configureMQTTOperationTimeout(MQTT_OPER_TIMEOUT)
                            pycomAwsMQTTClient.configureLastWill(LAST_WILL_TOPIC, LAST_WILL_MSG, 1)
                            
                            print("Trying to connect to AWS")
                            try:
                                while not pycomAwsMQTTClient.connect():
                                    print("Connecting to AWS...")
                                    time.sleep(0.5)
                            except Exception as e:
                                print("Exception: Can't connect to AWS")
                                print(e)
                            print('AWS connection succeeded')
                        

                        I am planning on writing a detailed Medium Article, I'll link it here if you have any more problems.

                        1 Reply Last reply Reply Quote 0

                        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                        With your input, this post could be even better 💗

                        Register Login
                        • 1 / 1
                        • First post
                          Last post

                        Pycom on Twitter

                        Pycom