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

    Adding external libraries via uiflow

    UIFlow
    9
    25
    86.4k
    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.
    • lukasmaximusL
      lukasmaximus
      last edited by

      As far as I know the Uiflow Micropython source is not available yet. Some others have posted guides on how to flash alternative micropython builds with other libraries https://www.hackster.io/andreas-motzek/execute-logo-on-m5stack-esp32-basic-with-micropython-3713fd
      You could try creating your own spiffs image to include the libraries you need
      https://github.com/igrr/mkspiffs although I haven't tried this yet and not sure if you have to add anything extra to make the uiflow firmware recognize the spiffs partition

      1 Reply Last reply Reply Quote 0
      • world101W
        world101
        last edited by

        Since m5stack moved from the Loboris fork of Micropython to the official Micropython v1.11 release, it seems the libs were also moved somewhere. With m5stack firmware v1.2.x, they used to be in /flash/lib, however now with firmware 1.3.x, that directory does not exist. If I try to create /flash/lib with ampy, the m5stack won't boot properly.

        Internal FS (FatFS): Mounted on partition 'internalfs' [size: 2162688; Flash address: 0x1F0000]
        ----------------
        Filesystem size: 2101248 B
                   Used: 1400832 B
                   Free: 700416 B
        ----------------
        Traceback (most recent call last):
          File "boot.py", line 4, in <module>
          File "flowlib/uiflow.py", line 1, in <module>
          File "flowlib/m5stack.py", line 5, in <module>
        ImportError: no module named 'lib.speak'
        Traceback (most recent call last):
          File "main.py", line 17, in <module>
        NameError: name 'rgb' isn't defined
        MicroPython v1.11-112-g5f3c6ee93-dirty on 2019-06-26; ESP32 module with ESP32
        Type "help()" for more information.
        >>>
        

        The above serial output during bootup shows something in flowlib, but I can't seem to access it. If someone could assist with where to put the custom libs, I could probably get Blynk working again.

        ajb2k3A 1 Reply Last reply Reply Quote 0
        • H
          heybin
          last edited by

          UIFLOW most lib post in https://github.com/m5stack/UIFlow-Code, wiki have some api

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

            @world101 said in Adding external libraries via uiflow:

            Since m5stack moved from the Loboris fork of Micropython to the official Micropython v1.11 release, it seems the libs were also moved somewhere. With m5stack firmware v1.2.x, they used to be in /flash/lib, however now with firmware 1.3.x, that directory does not exist. If I try to create /flash/lib with ampy, the m5stack won't boot properly.

            Internal FS (FatFS): Mounted on partition 'internalfs' [size: 2162688; Flash address: 0x1F0000]
            ----------------
            Filesystem size: 2101248 B
                       Used: 1400832 B
                       Free: 700416 B
            ----------------
            Traceback (most recent call last):
              File "boot.py", line 4, in <module>
              File "flowlib/uiflow.py", line 1, in <module>
              File "flowlib/m5stack.py", line 5, in <module>
            ImportError: no module named 'lib.speak'
            Traceback (most recent call last):
              File "main.py", line 17, in <module>
            NameError: name 'rgb' isn't defined
            MicroPython v1.11-112-g5f3c6ee93-dirty on 2019-06-26; ESP32 module with ESP32
            Type "help()" for more information.
            >>>
            

            The above serial output during bootup shows something in flowlib, but I can't seem to access it. If someone could assist with where to put the custom libs, I could probably get Blynk working again.

            I thought that was just me. I too tried to copy over blynk this weekend using vstudio but again had the same boot issue.

            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
            • world101W
              world101
              last edited by world101

              I just got Blynk working again with the latest 0.2.0 release from Github.

              git clone https://github.com/vshymanskyy/blynk-library-python.git
              cd blynk-library-python
              ampy -p /dev/tty.SLAB_USBtoUART -b 115200 mkdir /flash/blynk
              ampy -p /dev/tty.SLAB_USBtoUART -b 115200 put BlynkLib.py /flash/blynk/BlynkLib.py
              ampy -p /dev/tty.SLAB_USBtoUART -b 115200 get /flash/boot.py > boot.py
              

              Use vi to edit the first few lines of boot.py to look like this:

              import sys
              sys.path.append('flowlib/lib')
              sys.path.append('/flash/blynk')
              
              import machine, time, m5base, uiflow, BlynkLib
              

              Copy the modified boot.py back to the m5stack:

              ampy -p /dev/tty.SLAB_USBtoUART -b 115200 put boot.py /flash/boot.py
              

              Connect to the serial interface via screen and reboot the m5stack. You should see the Blynk lib load at bootup.

              Internal FS (FatFS): Mounted on partition 'internalfs' [size: 2162688; Flash address: 0x1F0000]
              ----------------
              Filesystem size: 2101248 B
                         Used: 1409024 B
                         Free: 692224 B
              ----------------
              I (413) [TFTSPI]: attached display device, speed=8000000
              I (413) [TFTSPI]: bus uses native pins: false
              W (1296) sdspi_host: spi bus changed (1 -> 2)
              [ M5 ] init sd card Fail
              [ M5 ] node id:30aea449cd9c, api key:1CAA42CC
              
                  ___  __          __
                 / _ )/ /_ _____  / /__
                / _  / / // / _ \/  '_/
               /____/_/\_, /_//_/_/\_\
                      /___/ for Python v0.2.0 (esp32)
              
              I (2284) modsocket: Initializing
              I (7288) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
              I (7288) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
              I (7392) phy: phy_version: 4100, 2a5dd04, Jan 23 2019, 21:00:07, 0, 0
              
              

              Reference thread: http://forum.m5stack.com/topic/575/blynk-on-m5stack-via-uiflow-and-block-maker

              1 Reply Last reply Reply Quote 0
              • world101W
                world101
                last edited by world101

                By the way, you should be able to follow a similar procedure to load any custom library. Just create the directory /flash/custom and then reference it with sys.path.append('/flash/custom') in boot.py.

                ampy -p /dev/tty.SLAB_USBtoUART -b 115200 mkdir /flash/custom
                ampy -p /dev/tty.SLAB_USBtoUART -b 115200 put customLib.py /flash/custom/customLib.py
                

                in boot.py:

                import sys
                sys.path.append('flowlib/lib')
                sys.path.append('/flash/custom')
                

                Then with uiFlow, you can use the execute block to have the choice when it gets imported (so you don't import it automatically when your program doesn't need it).
                0_1562066480425_Screen Shot 2019-07-02 at 7.20.47 AM.png

                H 1 Reply Last reply Reply Quote 0
                • H
                  hetzer @world101
                  last edited by

                  This post is deleted!
                  1 Reply Last reply Reply Quote 0
                  • A
                    ATU
                    last edited by

                    Hello, world101 I am very new here in the forum and want to control my M5STACK with "blynk" via UIflow symbols.
                    I use:
                    UiFlow V1.4.3
                    F5STACK fire, the red one.
                    blynk for Python v0.2.1 (esp32_LoBo)
                    MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32

                    I have successfully worked through all the above points.
                    However, the dispaly from my M5STACK shows the following error message:

                    error
                    ImportError("no module named 'uiflow'",)

                    I think that I have not installed the above mentioned elements:
                    "machine, time, m5base, uiflow"

                    In the boot.py I have edited the following, as you have described above:
                    import sys
                    sys.path.append('flowlib/lib')
                    sys.path.append('/flash/blynk')
                    import machine, time, m5base, uiflow, BlynkLib

                    I would like to implement remote monitoring via iphon of my groundwater pump.
                    It would be nice if you could help me, please.

                    world101W 1 Reply Last reply Reply Quote 0
                    • world101W
                      world101 @ATU
                      last edited by

                      @atu said in Adding external libraries via uiflow:

                      Hello, world101 I am very new here in the forum and want to control my M5STACK with "blynk" via UIflow symbols.
                      I use:
                      UiFlow V1.4.3
                      F5STACK fire, the red one.
                      blynk for Python v0.2.1 (esp32_LoBo)
                      MicroPython ESP32_LoBo_v3.2.24 - 2018-09-06 on M5Stack with ESP32

                      I have successfully worked through all the above points.
                      However, the dispaly from my M5STACK shows the following error message:

                      error
                      ImportError("no module named 'uiflow'",)

                      I think that I have not installed the above mentioned elements:
                      "machine, time, m5base, uiflow"

                      In the boot.py I have edited the following, as you have described above:
                      import sys
                      sys.path.append('flowlib/lib')
                      sys.path.append('/flash/blynk')
                      import machine, time, m5base, uiflow, BlynkLib

                      I would like to implement remote monitoring via iphon of my groundwater pump.
                      It would be nice if you could help me, please.

                      You’re not going to (easily) be able to use LoBo Micropython and the later versions of UIFlow. I think uiFlow v1.2.3 was the latest that LoBo was supported. Best thing would be to flash the official v1.4.4 firmware from M5Stack and use uiFlow v1.4.4.

                      Try that first, then try to import the Blynk libs and see if it works.

                      1 Reply Last reply Reply Quote 0
                      • A
                        ATU
                        last edited by

                        Thank you, world101, for your quick response.
                        Now Blynk works at my M5STACK.
                        Your Blynk.m5b has five UiFlow blocks for only three virtual functions.
                        But Blynk offers much more features.
                        Has anyone already generated more UiFLOW blocks they can share?

                        1 Reply Last reply Reply Quote 0
                        • J
                          jesuslg123
                          last edited by

                          Is this method valid to replace libraries like urequests? I found a "bug" on the current implementation and I would like to replace the one that comes with the UIFlow firmware to workaround the issue. Is that possible or in any other way?
                          Thanks!

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

                            @jesuslg123 If you use a programs like VStudio, Thonny and mu that you can add library directly to the M5Stack

                            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!

                            J 1 Reply Last reply Reply Quote 0
                            • J
                              jesuslg123 @ajb2k3
                              last edited by

                              @ajb2k3 said in Adding external libraries via uiflow:

                              @jesuslg123 If you use a programs like VStudio, Thonny and mu that you can add library directly to the M5Stack

                              Thanks, for the this project I was using the UIFlow editor with the UI programming language, do you think I can also replace the urequest version that is using this?
                              Also can you share with me how to upload with Visual Studio? Thanks

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

                                UIFlow is based on Micropython 1.11 so switching isn't that hard.
                                Check out https://www.youtube.com/channel/UCozgFVglWYQXbvTmGyS739w luke made a useful vid on it.

                                The great thing about UIFlow/Micropython is that you can build most of the program in UIFlow and then switch to Micropython to make final adjustments.
                                The only issue is that you can't change back to UIFlow after adjusting because the code blocks won't exist for you added code.

                                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 1
                                • R
                                  robalstona
                                  last edited by

                                  If you use Visual Code you could install this extension

                                  https://marketplace.visualstudio.com/items?itemName=curdeveryday.vscode-m5stack-mpy

                                  Then transfer your modified library to flash. It would be good to change the name to another one, so that the import function does not load the built-in urequests library. Alternatively, you would have to look in what order and from which locations the libraries are imported.

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