Adding external libraries via uiflow


  • M5Stack

    Seems ampy is not working in 1.3.1, I recommend firmware 1.2.2 or 1.2.3 if you want to transfer files via ampy you can check these two videos on our channel for getting started https://www.youtube.com/watch?v=rvP3GixWG1Y&t=109s and https://www.youtube.com/watch?v=V67MY-1ccqM



  • @lukasmaximus I followed the instructions, copied the blynklib into flash/lib folder but receiving the following error:
    AttributeError("module object has no attribute Blynk",)


  • M5Stack

    @ajb2k3 weren't you an world101 able to do some stuff with blynk. Have you tried putting the module on to the flash more than once? I've found ampy to be a little buggy at times, sometimes the copy wasn't successfull sometimes it was.



  • @lukasmaximus Yeh, @world101 had a lib working but I haven't had time to work with it in ages. been having issues with my in house server.



  • @lukasmaximus said in Adding external libraries via uiflow:

    th blynk. Have you tried putting the module on to the flash more than once? I've found ampy to be a little buggy at times, sometimes the copy wasn't successful sometimes it was.

    Yes, flashed it couple of times and also tried by transferring the file via upyLoader. Same result. Blynk is very easy to use and it would be great with the convenience of uiflow and M5stack.



  • I have tried looking into this today but having trouble getting repl to run. @hetzer I have not forgotten about your issue, I have just been too busy to look much into it.



  • @ajb2k3 Thanks hope a built in block comes in the future



  • Is there a tutorial somewhere on how to build the UI-Flow Firmware?
    Would like to add some libraries, like for example paho-mqtt, and I think it would be best to build a custom FW for that.
    https://github.com/EeeeBin/UIFlow-Firmware, referenced from https://github.com/m5stack/M5Stack-Firmware only offers binaries.

    Not sure whether https://github.com/m5stack/M5Stack_MicroPython includes UI-Flow.

    Any pointers?


  • M5Stack

    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



  • 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.



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



  • @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.



  • 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



  • 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



  • This post is deleted!