🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Atom Matrix with FW 1.13.1 not connecting to AWS

    UIFlow
    2
    13
    3.8k
    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.
    • C
      chr1g1
      last edited by chr1g1

      Meanwhile I upgraded to 1.13.2 and still got the same error.
      I then added the AWS subscribe block to subscribe to some topic and the error is gone...
      However, I don't get any data on AWS IoT Core.
      I enabled CloudWatch Log for IoT Core (Settings) and set the log level to debug. I do not see my device connecting?!

      1 Reply Last reply Reply Quote 0
      • ajb2k3A
        ajb2k3
        last edited by ajb2k3

        EBADF means that the client on the atom is trying to send to a closed connection.

        At one point I had to store the Public and private keys generated by amazon along with the cert on the client to get a connection.

        Try setting Keep alive to 500.

        Will need to see the full code to work out what's happening.

        AWS is constantly changing so my guides are probably out of date and need updating. I hate AWS as it a Pain.

        UIFlow, so easy an adult can learn it!
        If I don't know it, be patient!
        I've ether not learned it or am too drunk to remember it!
        Author of the WIP UIFlow Handbook!
        M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

        1 Reply Last reply Reply Quote 0
        • C
          chr1g1
          last edited by

          It is still not working... Due to the fact that I'm not receiving anything on AWS, I believe it is connected to the networking on the device.
          I see a number of contradicting information and unclear guidance. Here the current approach and questions:
          1/ Internet Mode vs. App Mode. Is MQTT/IOT supposed to work in both modes?
          2/ How I'm supposed to configure networking on the new firmwares? I see the following options:
          wifiCfg.autoConnect(lcdShow=False)
          wifiCfg.reconnect()
          wifiCfg.doConnect('', '')
          wlan.connect('', '')
          3/ Playing with different firmwares because I believe this is buggy.

          1 Reply Last reply Reply Quote 0
          • ajb2k3A
            ajb2k3
            last edited by

            Ah I see the Issue now.
            So in Internet mode the WIFI connection is already active because UIFLOW is using it to send and test programs where as in APP mode the WIFI connection is not activated because you haven't opened the connection.

            In App mode you must add the wifi configuration and setup blocks to the code for the Wireless connection to work.

            Sorry, I have been battling a chest infection and so wasn't able to clearly see the solution. While I did write the crappy book on IOT found on amazon, things have changed and I am already writing an update while working on the other deep guides.

            UIFlow, so easy an adult can learn it!
            If I don't know it, be patient!
            I've ether not learned it or am too drunk to remember it!
            Author of the WIP UIFlow Handbook!
            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

            1 Reply Last reply Reply Quote 0
            • ajb2k3A
              ajb2k3
              last edited by

              Your setup need to look like this:
              0_1707306503809_Screenshot 2024-02-07 at 11.47.53.png

              UIFlow, so easy an adult can learn it!
              If I don't know it, be patient!
              I've ether not learned it or am too drunk to remember it!
              Author of the WIP UIFlow Handbook!
              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

              1 Reply Last reply Reply Quote 0
              • C
                chr1g1
                last edited by chr1g1

                Still have the problem. I rebuilt the whole program to make sure there are no "old" blocks in there. Don't even see a connection attempt on AWS (IoT Core with enabled debug logging)

                ATOM Matrix
                Firmware: 1.13.2

                Both in Internet and App mode

                -- Code --
                from m5stack import *
                from m5ui import *
                from uiflow import *
                import wifiCfg
                import time
                from IoTcloud.AWS import AWS
                from libs.json_py import *
                import unit

                rgb.set_screen([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0])
                tvoc_0 = unit.get(unit.TVOC, unit.PORTA)

                CO2 = None
                TVOC = None
                H2 = None
                Ethanol = None

                wifiCfg.doConnect('Guest', 'xxx')
                wifiCfg.autoConnect(lcdShow=False)
                wait(5)
                aws = AWS(things_name='CO2SENSOR', host='xxx.iot.eu-central-1.amazonaws.com', port=8883, keepalive=500, cert_file_path="/flash/res/certificate.pem.crt", private_key_path="/flash/res/private.pem.key")
                aws.start()
                while True:
                CO2 = tvoc_0.eCO2
                TVOC = tvoc_0.TVOC
                H2 = tvoc_0.H2
                Ethanol = tvoc_0.Ethanol
                aws.publish(str('m5stack/bla'),str((py_2_json({'CO2':CO2,'TVOC':TVOC,'H2':H2,'Ethanol':Ethanol}))))
                print('submitted to AWS')
                wait(5)

                — Serial Log --

                submitted to AWS
                [10490] MQTTException -> [Errno 9] EBADF
                reconnect start ...
                reconnect finish ...
                [14075] MQTTException -> [Errno 9] EBADF
                reconnect start ...
                reconnect finish ...
                submitted to AWS
                [17541] MQTTException -> [Errno 9] EBADF
                reconnect start ...
                reconnect finish ...
                submitted to AWS
                [20998] MQTTException -> [Errno 9] EBADF
                reconnect start ...
                reconnect finish ...
                [24577] MQTTException -> [Errno 9] EBADF
                reconnect start ...
                reconnect finish ...
                submitted to AWS

                1 Reply Last reply Reply Quote 0
                • C
                  chr1g1
                  last edited by

                  Okay - testet the very same code with an MStickC. Runs very smooth without issues. Either there are bugs in the code of the Atom Matrix or the device has just too less resources to handle an external sensor along with an IoT connection.

                  1 Reply Last reply Reply Quote 1
                  • ajb2k3A
                    ajb2k3
                    last edited by

                    Nice work keeping at it. there is one more thing I can think of which is basically a last thing to try.

                    Add
                    import gc

                    to the import code and then at the beginning of the loop add

                    gc.collect()

                    This forces garbage collection in micropython on each pass emptying the memory on each loop.

                    Look up Micropython Garbage collection function for more information on this.

                    unfortunately I can't get into my AWS account and so haven't been able to test but it could be that you have genuinely found an issue in the Atom firmware.

                    UIFlow, so easy an adult can learn it!
                    If I don't know it, be patient!
                    I've ether not learned it or am too drunk to remember it!
                    Author of the WIP UIFlow Handbook!
                    M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                    1 Reply Last reply Reply Quote 0
                    • C
                      chr1g1
                      last edited by

                      added it as directed above. Still weird behaviour of the Atom Matrix on FW 1.13.2.
                      Here is the log:
                      I print out "submitted to aws" after the publish block in the loop.

                      APIKEY: xxx
                      submitted to aws
                      [17797] MQTTException -> 128
                      reconnect start ...
                      reconnect finish ...
                      submitted to aws
                      submitted to aws
                      submitted to aws
                      submitted to aws
                      submitted to aws

                      ajb2k3A 1 Reply Last reply Reply Quote 0
                      • C
                        chr1g1
                        last edited by

                        okay some more learnings...
                        All S3 devices are supported by UIFlow 2.0 only. And UIFlow 2.0 is not yet supporting AWS IoT unless I missed something.
                        M5StickC Plus is working as a charm. Like M5StickC. I guess I stick with those.

                        My summary as of Feb 2024 and Firmware 1.13.2 and UIFlow 2.0 (Alpha 29):

                        Forget all new devices that are supported by UIFlow 2.0 only (e.g. *S3) and the small ATOMs if you wanna do AWS IoT stuff. Hope you find this before you bought too many devices...

                        1 Reply Last reply Reply Quote 0
                        • C
                          chr1g1
                          last edited by

                          and for completness here my working setup with M5StickC / Plus
                          Will also followup with AWS details.
                          0_1707493802415_Screenshot 2024-02-09 at 16.48.48.png

                          1 Reply Last reply Reply Quote 0
                          • ajb2k3A
                            ajb2k3 @chr1g1
                            last edited by

                            @chr1g1 said in Atom Matrix with FW 1.13.1 not connecting to AWS:

                            added it as directed above. Still weird behaviour of the Atom Matrix on FW 1.13.2.
                            Here is the log:
                            I print out "submitted to aws" after the publish block in the loop.

                            APIKEY: xxx
                            submitted to aws
                            [17797] MQTTException -> 128
                            reconnect start ...
                            reconnect finish ...
                            submitted to aws
                            submitted to aws
                            submitted to aws
                            submitted to aws
                            submitted to aws

                            Well there is an improvement as you are no longer getting the [24577] MQTTException -> [Errno 9] EBADF
                            Which means the Atom is now working

                            Error 128 means that it tried to subscribe to the AWS topic before the connection was made.
                            If you make a subscribe and a call, according to your log it should be present.

                            add a 5 second delay after the AWS start.

                            UIFlow, so easy an adult can learn it!
                            If I don't know it, be patient!
                            I've ether not learned it or am too drunk to remember it!
                            Author of the WIP UIFlow Handbook!
                            M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post