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

    Code works when I press play but not when I download on device

    General
    5
    11
    6.7k
    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.
    • B
      braamconradie
      last edited by

      I am super impressed with m5flow coding blocks. Only problem is that on the m5core my code below only works when I press play, but not when I download the code on the device (it fails to connect to MQTT when code is downloaded but works fine when I just press play). Any help will be appreciated!

      from m5ui import *
      from uiflow import *
      from m5mqtt import M5mqtt
      
      
      setScreenColor(0x222222)
      
      
      mqcount = None
      angle = None
      
      
      
      label0 = M5TextBox(8, 215, "Alive", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      alivecount = M5TextBox(69, 215, "0", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      circle0 = M5Circle(15, 113, 15, 0xFFFFFF, 0xFFFFFF)
      label1 = M5TextBox(138, 156, "label1", lcd.FONT_Default, 0xFFFFFF, rotate=0)
      
      from numbers import Number
      
      
      
      def fun_f3f2_(topic_data):
        global mqcount, angle
        mqcount = (mqcount if isinstance(mqcount, Number) else 0) + 1
        alivecount.setText(str(mqcount))
        pass
      
      @timerSch.event('timer1')
      def ttimer1():
        global mqcount, angle
        m5mqtt.publish(str('f3f2'), str('alive'), 0)
        pass
      
      @timerSch.event('timer2')
      def ttimer2():
        global mqcount, angle
        angle = (angle if isinstance(angle, Number) else 0) + 0.1
        label1.setText(str(angle))
        pass
      
      
      m5mqtt = M5mqtt('f3f2', 'broker.emqx.io', 1883, '', '', 300)
      m5mqtt.subscribe(str('f3f2'), fun_f3f2_)
      m5mqtt.start()
      mqcount = 0
      angle = 0
      timerSch.run('timer1', 1000, 0x00)
      timerSch.run('timer2', 10, 0x00)```
      1 Reply Last reply Reply Quote 0
      • H
        holofloh
        last edited by

        you need to configure you wifi in code. at least a wifi connect has to be set in the beginning of your code to use the wifi configured in firmware.

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

          You need to set up the WIFI functions to connect to a local network in program mode whereas, in test mode it uses the active default wifi setting the memory Is already using.

          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
          • D
            DaGloom
            last edited by DaGloom

            Have the same problem here. If I run the UiFlow Code over the web (Play-Button) it works fine, but if I try to download the code to the Core2 it shows just a black screen and no reaction from the device.

            Now, I even tried to add the suggested WIFI connection:

            0_1676231868286_M5Flow.png.png

            But with no success. Even after a reboot or power-loss (removed the battery because of using the Extension Port Module), everything remains black...

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

              @dagloom Did you actually fill in the Wifi SSID and password?

              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!

              D 1 Reply Last reply Reply Quote 0
              • D
                DaGloom @ajb2k3
                last edited by

                @ajb2k3 sure, but I‘m not going to show the credentials here 😉

                1 Reply Last reply Reply Quote 0
                • H
                  holofloh
                  last edited by

                  it is possible to have more than one script on the device. In the firmware menu it is possible to choose the default one. Maybe you have a wrong one set as default? It may help to clear the flash and burn the latest firmware. If the download still not work try some demo code to see if this runs as intended.

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

                    Well for a start, I can’t see any GUI functions in that screenshot to show on screen

                    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
                    • D
                      DaGloom @holofloh
                      last edited by

                      I was able to figure it out.

                      It seems, that my setup with two ENVIII sensors connected (1st port A, 2nd Port B via ExtPort 2) does not load the sensors properly and the program crashes.

                      As comparison the program runs without a problem if the 2nd sensor is not connected into the Extension Port Module...

                      What are your experiences to connect two ENVIII sensors to a Core2 at the same time?

                      I found some hubs which could maybe help in that situation:

                      • 1 to 3 mini Hub
                      • Pa.Hub2
                      • Pb.Hub

                      Any recommendation? Do you have experiences with some of them?

                      teastainT ajb2k3A 2 Replies Last reply Reply Quote 0
                      • teastainT
                        teastain @DaGloom
                        last edited by teastain

                        @dagloom the PaHub 2 works beautifully with several ENVs.
                        I made a GitHub repository with an Arduino example, here:
                        https://github.com/teastainGit/Simple-PaHub-example.
                        Cheers, Terry

                        P.S. the other two hubs will NOT work at all with ENV

                        Cheers, Terry!

                        100% M5Stack addict with several drawers full of product!

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

                          @dagloom Ok, now we are getting somewhere.
                          In UIFLow You can't connect the ENVIII sensor to PortB. ENVIII is an I2C device and has a red connector, PortB is for analog devices and has a black connector.
                          Both ENVIII sensors have to be connected to PortA via the PAhub2 and then you need to make sure in the config that there are set to the individual PaHub ports not the Cores ports.
                          The you need GUI labels to show the incoming data from the ENVIII sensors.
                          0_1676440930453_Screenshot 2023-02-15 at 06.00.31.png

                          The 1to3 mini hub is only usable if the I2C devices have different I2C hubs and the PortBHub is only usable for devices with the black "analog" connector.

                          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
                          • First post
                            Last post