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

    SSL Connection to AWS IoT from ESP8266(Micropython)

    Scheduled Pinned Locked Moved MicroPython
    micropythonawssslmqtt
    19 Posts 3 Posters 6.1k Views 3 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.
    • S Offline
      sunrise17 @livius
      last edited by

      @livius Today, i have received ESP32 but still i am getting same error as "Error in mqtt connect: [Exception] TypeError: extra keyword arguments given". print(self.ssl_params) in mqtt.py is printing as i expected. I have not understood the issue??

      Code in main.py;

      KEY_PATH = "/flash/cert/deviceCert.key"
      CERT_PATH = "/flash/cert/deviceCertAndCACert.pem"
      CACERT_PATH = "/flash/cert/root.pem"
      MQTT_HOST = "yourSpecificEndPointHere.iot.eu-west-1.amazonaws.com"
      MQTT_CLIENT_ID = "23876283476233" 
      
      client = MQTTClient(client_id=MQTT_CLIENT_ID, server=MQTT_HOST, port=MQTT_PORT, keepalive=10000, ssl=True, ssl_params={"keyfile":KEY_PATH, "certfile":CERT_PATH, "ca_certs":CACERT_PATH})
      

      Code in mqtt.py;

      def connect(self, clean_session=True):
          self.sock = socket.socket()
          addr = socket.getaddrinfo(self.server, self.port)[0][-1]
          self.sock.connect(addr)
          # print(self.ssl_params) // it prints: {'keyfile': '/flash/cert/deviceCert.key', 'certfile': '/flash/cert/deviceCertAndCACert.pem', 'ca_certs': '/flash/cert/root.pem'}
          if self.ssl:
              import ussl
              self.sock = ussl.wrap_socket(self.sock, **self.ssl_params)
      
          premsg = bytearray(b"\x10\0\0\0\0\0")
          msg = bytearray(b"\x04MQTT\x04\x02\0\0")
          ...
      
      L 1 Reply Last reply Reply Quote 0
      • L Offline
        livius @sunrise17
        last edited by

        @sunrise17
        I do not suppose that this is releated because you get error on wrap_socket
        but from where do you get MQTTClient.py?
        I ask because it is now in frozen modules - try removing MQT releated files from flash and try again

        think about people first, then computers

        S 1 Reply Last reply Reply Quote 0
        • S Offline
          sunrise17 @livius
          last edited by

          @livius Thanks for your quick response, you can find complete code of mqtt.py where i get the MQTTClient.py.0_1518175187007_mqtt.py

          L 1 Reply Last reply Reply Quote 0
          • L Offline
            livius @sunrise17
            last edited by

            @sunrise17
            It looks really different
            try to remove all MQT files from card and use internal one.

            internal files are already on your device as frozen modules.

            think about people first, then computers

            S 1 Reply Last reply Reply Quote 0
            • S Offline
              sunrise17 @livius
              last edited by sunrise17

              Dear @livius i have downloaded simple.py from following link below and added file into my board.
              https://github.com/micropython/micropython-lib/tree/master/umqtt.simple/umqtt
              I have imported library as follows;

              from simple import MQTTClient
              

              Error as follows;

              (2378) wifi: connected with ASUS_5G_2.4G_EXT, channel 4
              (2378) network: event 4
              (3268) event: sta ip: 192.168.1.169, mask: 255.255.255.0, gw: 192.168.1.1
              (3268) network: GOT_IP
              (5098) wifi: pm start, type:0
              
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] TypeError: extra keyword arguments given
              Mqtt Broker connected
              Error in mqtt connect: [Exception] OSError: 23
              Mqtt Broker connected
              Error in mqtt connect: [Exception] OSError: 23
              Mqtt Broker connected
              

              Do you have any idea about this error, why it could be happened?

              L 1 Reply Last reply Reply Quote 0
              • L Offline
                livius @sunrise17
                last edited by livius

                @sunrise17
                I do not know and becouse of that try first internal one.
                Remove all mqt files from your flash and do simple

                from MQTTClient import MQTTClient
                

                and use it then

                think about people first, then computers

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  sunrise17 @livius
                  last edited by

                  @livius Yes i have tried it also but after i got this error i have left it. "ImportError: no module named 'MQTTClient''. Because mqtt lib is not coming with Esp32 Firmware in default.

                  L 1 Reply Last reply Reply Quote 0
                  • L Offline
                    livius @sunrise17
                    last edited by

                    @sunrise17 said in SSL Connection to AWS IoT from ESP8266(Micropython):

                    Esp32

                    it come with pycom firmware
                    what firmware version do you have?

                    import os
                    os.uname()
                    

                    think about people first, then computers

                    S 1 Reply Last reply Reply Quote 0
                    • S Offline
                      sunrise17 @livius
                      last edited by

                      @livius

                      OS Info as follows;
                      (sysname='esp32', nodename='esp32', release='1.9.3', version='v1.9.3-286-gbbb08431 on 2018-02-09', machine='ESP32 module with ESP32')

                      L 1 Reply Last reply Reply Quote 0
                      • L Offline
                        livius @sunrise17
                        last edited by livius

                        @sunrise17
                        You must update the firmware first.
                        https://pycom.io/downloads/

                        You have 1.9 but current is 1.15 and frozen mqt go with 1.10

                        think about people first, then computers

                        S 1 Reply Last reply Reply Quote 0
                        • S Offline
                          sunrise17 @livius
                          last edited by sunrise17

                          @livius, i am using oem esp32, is it possible to update it with pycom firmware update?0_1518180601323_IMG_7127.JPG,

                          I have tried but it has not been updated

                          L 1 Reply Last reply Reply Quote 0
                          • L Offline
                            livius @sunrise17
                            last edited by livius

                            @sunrise17

                            sysname='esp32', nodename='esp32',

                            then you are on the wrong forum, for this device better go to micropython forum

                            is it possible to update it with pycom firmware

                            it is possible to flash it with custom pycom firmware
                            i say custom because you must modify firmware first, especially about chip revision.

                            think about people first, then computers

                            S 1 Reply Last reply Reply Quote 0
                            • S Offline
                              sunrise17 @livius
                              last edited by

                              Dear @livius , is there some guide to upload custom pycom firmware to ESP-WRoom-32 board? Because you have mentioned that it is necessary to adjust chip revision. I will be glad if you let me know about some guide to flash my board with pycom firmware. Thanks...

                              L 1 Reply Last reply Reply Quote 0
                              • L Offline
                                livius @sunrise17
                                last edited by

                                @sunrise17
                                you must modify esp_get_revision - i do not have guide but on the forum you can find such posted by
                                @robert-hh
                                https://forum.pycom.io/post/13828

                                think about people first, then computers

                                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