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

    Nesting of multiple PAhubs

    UIFlow
    2
    11
    1.6k
    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.
    • U
      UP_BIM
      last edited by

      Re: 2x PaHUB mit UIFlow
      I think this is related to a very old post, but there was no reply to it, so I opened a new topic:

      I wish to nest PAhubs (PAhub2) to expand the number of i2c sensor unit inputs beyond 6, by plugging in secondary PAhub(s) onto a primary PAhub. From what I gather, the hardware is able to do this and several websites selling the hubs specifically mentions the example of connecting 6 PaHubs to a primary hub to support 36 sensor units. It is also biefly mentioned in one of the official m5stack tutorial videos.

      But in UiFlow, how do I access the sensor units that are connected to the secondary PAhub(s)? It is easy to get addess assignment for the sensor units on the primary PAhub, but not for the secondary hubs. Any suggestions?

      1 Reply Last reply Reply Quote 0
      • felmueF
        felmue
        last edited by

        Hello @UP_BIM

        are you sure the examples you found are talking about nested PaHubs?

        Could it be that they mean connecting multiple PaHubs (with different I2C addresses) in parallel? E.g.

        Core I2C master ----------|------------|------------|------------|----~
                            PaHub(0x70)  PaHub(0x71)  PaHub(0x72)  PaHub(0x73)
        

        BTW: I don't think UIFlow supports nested PaHubs.

        Thanks
        Felix

        GPIO translation table M5Stack / M5Core2
        Information about various M5Stack products.
        Code examples

        1 Reply Last reply Reply Quote 0
        • U
          UP_BIM
          last edited by

          Thank you Felix

          Here is an example that mentions expansion to 36 I2C ports using 7 PAhubs:

          https://www.bastelgarage.ch/m5stack-pa-hub-2-i2c-expansion-unit-1-to-6

          "...For example, you can wire PaHUBs with the Root-PaHUB to get more places for your I2C slave devices. If you have seven of them, you can extend up to 36 I2C GROVE ports."

          So, I gather this is a nesting using two levels: 1 "Root PaHUB" (6x channels) and 6 secondary hubs (each with 6 channels).

          I anybody had success with this inside Uiflow or some other method, any advice will be appreciated.

          (I have the need to log data from about 15 sensors, some that are of the same type)

          1 Reply Last reply Reply Quote 0
          • felmueF
            felmue
            last edited by

            Hello @UP_BIM

            ok, I see, thanks for posting the example.

            How many of the sensors have a unique I2C address? All of those can be connected directly to the core (i2c master) in paralell. Only the sensors which share the same i2c address need to go behind a PaHub (unless there is a way to change the i2c address of those sensors). For instance like this:

            Core I2C master ----|----------|----------|---~ ~----|
                          PaHub(0x70)  S1(addr1)  S2(addr2)  S6(addr6)
                                |
                                | -- 1: S10 (addr10)
                                | -- 2: S10 (addr10)
                                ~
                                | -- 5: S10 (addr10)
                                | -- 6: S10 (addr10)
            

            Thanks
            Felix

            GPIO translation table M5Stack / M5Core2
            Information about various M5Stack products.
            Code examples

            U 1 Reply Last reply Reply Quote 0
            • U
              UP_BIM @felmue
              last edited by

              Hello @felmue (Felix)

              Measurements from several device types (ENV IV x 7 , CO2 x 2, Dlight x 4 , Voltmeter x3 etc ) are required. The ENV sensors on their own will need more than one PaHUB: so either a parallel, or nested approach is needed.

              Either way (parallel or nested), I am unable to correctly add the sensors in UiFlow or in python. By default sensors are assigned to a PaHUB with address (0x70) via this python command (example an ENV 4 unit is added):

              env4_0 = unit.get(unit.ENV4, unit.PAHUB0) ----------- [1]

              "unit.PAHUB0" refers to channel 0 of the hub connected to port A that has an address of (0x70).

              To add other PaHubs is easy (in this case the hub's address was altered via hardwiring to 0x71):

              pahub_0 = unit.get(unit.PAHUB, unit.PORTA, 0x71) ----------- [2]

              But it is unclear how to add sensors to such a hub. I am looking for the correct python syntax in line [1] to refer to a PaHUB that has an address other than (0x70).

              1 Reply Last reply Reply Quote 0
              • felmueF
                felmue
                last edited by

                Hello @UP_BIM

                from the syntax I gather you are using UIFlow1 (and not UIFlow2), correct?

                I already tried in the past to use a PaHub with non default I2C address in UIFlow1, but I wasn't successful. I don't think it is possible - but I could be wrong. In UIFlow2 I found a solution. Please see here.

                Thanks
                Felix

                GPIO translation table M5Stack / M5Core2
                Information about various M5Stack products.
                Code examples

                U 2 Replies Last reply Reply Quote 0
                • U
                  UP_BIM @felmue
                  last edited by

                  Thanks @felmue (Felix)
                  I think that will do the trick. Much appreciated!

                  1 Reply Last reply Reply Quote 0
                  • felmueF
                    felmue
                    last edited by felmue

                    Hello @UP_BIM

                    it just occurred to me; except for the 7th ENV IV unit you could get away with only one PaHub like this:

                    Core I2C Master --- PaHub
                                         |
                                        [0]- ENV IV - DLight - VMeter - CO2
                                        [1]- ENV IV - DLight - VMeter - CO2
                                        [2]- ENV IV - DLight - VMeter
                                        [3]- ENV IV - DLight
                                        [4]- ENV IV
                                        [5]- ENV IV
                    

                    Thanks
                    Felix

                    GPIO translation table M5Stack / M5Core2
                    Information about various M5Stack products.
                    Code examples

                    1 Reply Last reply Reply Quote 0
                    • U
                      UP_BIM @felmue
                      last edited by

                      Hi @felmue
                      Thank you for your advice. With a Core 2, I get a "PAHUBUnit isn't defined" error with this line of code:

                      env4_0 = ENVUnit(i2c=PAHUBUnit(i2c=i2c0, channel=0 , address=0x71), type=4)

                      UIFlow2 also creates the same micropython line (just without the 0x71 address allocation), with the same error. In UiFlow 1 this is not a problem.

                      I have not yet been able to attempt this with other M5 cores. In your solution, which M5 core did you use?

                      I am wondering if there is not a different call for Core 2's

                      1 Reply Last reply Reply Quote 0
                      • felmueF
                        felmue
                        last edited by

                        Hello @UP_BIM

                        yes, I noticed that error too. Try adding an Init pahub_0 block manually.

                        See Project Zone example: M5Tough_PaHub_Multiple_Units_UIFlow2.0.5

                        Thanks
                        Felix

                        GPIO translation table M5Stack / M5Core2
                        Information about various M5Stack products.
                        Code examples

                        U 1 Reply Last reply Reply Quote 0
                        • U
                          UP_BIM @felmue
                          last edited by

                          hi @felmue
                          Yes, thank you! Manual adding of the Init pahub_0 block has solved this.

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