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

    Blynk on M5Stack via uiFlow and block-maker

    PROJECTS
    5
    32
    128.2k
    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.
    • world101W
      world101 @ajb2k3
      last edited by

      @ajb2k3 said in Blynk on M5Stack via uiFlow and block-maker:

      What is ampy?

      It stands for Adafruit MicroPython tool. I recommend watching the video that I linked to above.

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

        @world101
        Thanks.

        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
        • L
          LastCaress
          last edited by

          Blynk and m5stack is an awesome combination! I will be watching this thread!

          1 Reply Last reply Reply Quote 0
          • L
            LastCaress
            last edited by

            Tried this and got AttributeError "module object has no attribute blynk" :|

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

              @lastcaress said in Blynk on M5Stack via uiFlow and block-maker:

              Tried this and got AttributeError "module object has no attribute blynk" :|

              Not sure exactly where it failed for you. Can you provide more detail on how far you got before seeing the error?

              L 1 Reply Last reply Reply Quote 0
              • L
                LastCaress @world101
                last edited by

                @world101 I managed to copy the blinklyb file to the m5stack, and the m5f and m5b files you provided. I think this error refers to :
                blynk = BlynkLib.Blynk(BLYNK_AUTH)
                I don't think it understands this line!
                Thanks

                1 Reply Last reply Reply Quote 0
                • L
                  LastCaress
                  last edited by

                  It manages to import the library, it just doesn't understand that attribute!

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

                    @lastcaress

                    If it doesn’t understand that line it may not have imported the library correctly. Did you put it in the /flash/lib directory on the m5stack? Also, just wanted to make sure you are running the latest v1.1.2 firmware.

                    Did you paste your Blynk Auth Key into the flow before running it in uiFlow?

                    Also, are you able to access the REPL prompt? If not I can show you how. It’s good for troubleshooting.

                    1 Reply Last reply Reply Quote 0
                    • L
                      LastCaress
                      last edited by

                      I am running the latest firmware and I uploaded the BlynkLib.py file from the git repo you linked using rshell to /flash/lib :P I used a raspbian os to it as I've never been able to use ampy! The import BlynkLib line of code doesn't cause any error. I did paste the auth key :D
                      I do not know how to access the repl prompt though!

                      1 Reply Last reply Reply Quote 0
                      • L
                        LastCaress
                        last edited by

                        So I got hold of a macbook and tried via ampy and.. it works!! I should've tried this before as my attemps at using the blynk python library probably didn't work before because I used rshell and maybe it sends the file in a different format? This is very nice!

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

                          @lastcaress said in Blynk on M5Stack via uiFlow and block-maker:

                          So I got hold of a macbook and tried via ampy and.. it works!! I should've tried this before as my attemps at using the blynk python library probably didn't work before because I used rshell and maybe it sends the file in a different format? This is very nice!

                          Ampy didn't work on my macbook pro and it took me ages to find out that my pythone was P3 but I hadn't set up the enviroment shell correctly.
                          Glad it works.

                          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

                            Sweet, I got this to work as well.
                            Looks like something else to add to the project list.

                            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

                              @ajb2k3, @LastCaress

                              Glad you all got it working. To access REPL, you can do this from the Mac Terminal with the M5Stack connected to a USB port.

                              screen /dev/tty.SLAB_USBtoUART 115200

                              You may not see anything at first, so you can press CTRL+C on the keyboard to drop you into the REPL prompt (>>>). From there, you can do your regular MicroPython commands. For example...

                              >>> os.listdir()
                              ['image_app', 'main.py', 'emoji', 'sys_lib', 'config.py', 'lib', 'res', 'flow.py', 'blocks', 'apps', 'debug.py', 'modeconfig.json', 'boot.py', 'img']
                              >>> os.listdir('lib')
                              ['servo.py', 'square.py', 'step_motor.py', 'm5_pin.py', 'm5bala.py', 'wave.mpy', 'lego_board.py', 'bmp280.mpy', 'dht12.mpy', 'mpu6050.py', 'chunk.mpy', 'pid.py', 'lego.py', 'BlynkLib.py']
                              >>> import BlynkLib
                              
                                  ___  __          __
                                 / _ )/ /_ _____  / /__
                                / _  / / // / _ \/  '_/
                               /____/_/\_, /_//_/_/\_\
                                      /___/ for Python v0.2.0
                              
                              >>> help()
                              Welcome to LoBo MicroPython for the ESP32
                              
                              For online documentation please visit the Wiki pages:
                              https://github.com/loboris/MicroPython_ESP32_psRAM_LoBo/wiki
                              
                              Based on official MicroPython, this port brings many new features:
                              
                               - support for two cores and 4MB SPIRAM (psRAM)
                               - improved 'network' module
                               - greatly improved thread support
                               - support for 3 different internal file systems on top of ESP32 VFS
                               - ESP32 native support for SD Card
                               - built-in FTP & Telnet servers
                               - support for OTA updates
                               - many new and improved hardware access modules implemented in C
                               and many more...
                              
                              Control commands:
                                CTRL-A        -- on a blank line, enter raw REPL mode
                                CTRL-B        -- on a blank line, enter normal REPL mode
                                CTRL-C        -- interrupt a running program
                                CTRL-D        -- on a blank line, do a soft reset of the board
                                CTRL-E        -- on a blank line, enter paste mode
                              
                              For further help on a specific object, type help(obj)
                              For a list of available modules, type help('modules')
                              >>> help('modules')
                              __main__          m5flow/m5mqtt     math              uerrno
                              _thread           m5flow/m5stack    microWebSocket    uhashlib
                              ak8963            m5flow/peripheral microWebSrv       uheapq
                              array             m5flow/simple     microWebTemplate  uio
                              binascii          m5flow/ubutton    micropython       ujson
                              btree             m5flow/unit/adc   mpu6500           uos
                              builtins          m5flow/unit/button                  mpu9250           upip
                              cmath             m5flow/unit/color network           upip_utarfile
                              collections       m5flow/unit/dac   os                upysh
                              display           m5flow/unit/dual_button             pye               urandom
                              errno             m5flow/unit/ext_io                  random            ure
                              freesans20        m5flow/unit/ir    re                urequests
                              functools         m5flow/unit/ncir  select            uselect
                              gc                m5flow/unit/relay socket            usocket
                              hashlib           m5flow/unit/rgb_  ssd1306           ussl
                              heapq             m5flow/unit/tof   ssl               ustruct
                              io                m5flow/units      struct            utime
                              json              m5flow/utils      sys               utimeq
                              logging           m5flow/wifichoose time              uzlib
                              m5base            m5flow/wificonfig tpcalib           websocket
                              m5flow/app_manage m5flow/wifisetup  ubinascii         writer
                              m5flow/i2c_bus    m5ui              ucollections      ymodem
                              m5flow/m5cloud    machine           uctypes           zlib
                              Plus any modules on the filesystem
                              >>> 
                              
                              

                              etc...

                              Or if you don't go into the REPL prompt, but still have the screen session connected, you can see the serial logs from the m5stack. Reboot the M5stack and you should see the Blynk start up, plus some other useful information (network connection, connection to M5cloud, etc.).

                              To exit the screen session press CTRL+A then CTRL+\ then y.

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

                                By the way, I haven't found a way to import existing m5b files into block-maker.m5stack.com, so here are the ones I created. Feel free to play around with them and even create some new ones! The official Blynk colors are here: http://docs.blynk.cc/#blynk-main-operations-change-widget-properties

                                Blynk Init:
                                0_1549395441904_blynk_init.png

                                import BlynkLib
                                BLYNK_AUTH = ${auth_token}
                                blynk = BlynkLib.Blynk(BLYNK_AUTH)
                                

                                Blynk Run:
                                0_1549395472566_blynk_run.png

                                blynk.run()
                                

                                Uptime:
                                0_1549395486257_uptime.png

                                @blynk.VIRTUAL_READ(${pin})
                                def v${pin}_read_handler():
                                    time_val = time.ticks_ms() // 1000
                                    blynk.virtual_write(${pin}, time_val)
                                    lcd.textClear(${x}, ${y}, '      ', lcd.${bg_color})
                                    lcd.print(time_val, ${x}, ${y}, lcd.${fg_color})
                                

                                Slider: (Note, this is slightly different than the tutorial above. I was experimenting with passing a variable into the block. Feel free to adjust it as needed)
                                0_1549395507104_slider.png

                                @blynk.VIRTUAL_WRITE(${pin})
                                def v${pin}_write_handler(value):
                                    lcd.textClear(${x}, ${y}, '    ', lcd.${bg_color})
                                    ${variable} = '{}'.format(value).strip("['']")
                                    lcd.print(${variable}, ${x}, ${y}, lcd.${fg_color}, transparent=True, fixedwidth=True)
                                

                                Push Notification:
                                0_1549395564695_push_notification.png

                                @blynk.VIRTUAL_WRITE(${pin})
                                def v${pin}_write_handler(value):
                                    if value:
                                        blynk.notify(${text})
                                

                                I'm really interested in how to link blocks together, like the m5stack team did for the MQTT blocks. But I'll start a new thread on that soon.

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

                                  Can you pm me your real name as I would like to credit you in my book for all the hard work on M5Blynk

                                  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
                                  • K
                                    kmo
                                    last edited by

                                    Very cool! Can't wait to try it out!

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

                                      I just noticed the Blynk developers released a new version 0.2.0 of blynk-library-python on git hub. I seems to have some additional advanced features like

                                      • debug logging
                                      • custom server
                                      • changing heartbeat
                                      • connected/disconnected events
                                      • generic virtual pin events
                                      • BlynkTimer

                                      I have not tried this out yet, but plan to in the next week or so. In case you wanted to try the older version of the library, here is the commit:
                                      https://github.com/vshymanskyy/blynk-library-python/commit/4cbf641fade72a11e797436a8656ebf28f239801

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

                                        @world101 I managed to build a private server on Saturday but having auto startup issues.
                                        I’ve tried the guide but still have to manually start the server

                                        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!

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

                                          @ajb2k3 said in Blynk on M5Stack via uiFlow and block-maker:

                                          @world101 I managed to build a private server on Saturday but having auto startup issues.
                                          I’ve tried the guide but still have to manually start the server

                                          What platform did you build the local server on (Linux, RPi, etc)?

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

                                            @world101 RPI 2B

                                            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!

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