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

    [Solved] Connecting 3 ENV units via 1 to 3 Hub to M5 Stack

    General
    11
    20
    27.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.
    • m5stackM
      m5stack @thbonk
      last edited by

      @thbonk yes use Pahub(the 1 to 6 Expansion Unit) would be a best choice to connect more than one ENV unit to a M5 Stack device.

      thbonkT 1 Reply Last reply Reply Quote 1
      • thbonkT
        thbonk @m5stack
        last edited by

        @m5stack Do you have a link to an example to access the ENV sensors via I2C hub? I'm using the Arduino IDE.

        m5stackM 1 Reply Last reply Reply Quote 0
        • sysdl132S
          sysdl132
          last edited by

          Maybe you can use the ENV example,then set the ENV I2C Address(to their port I2C address).You can see the examples of ENV and PaHub.Like:

          // Defines
          #define PaHub_I2C_ADDRESS	0x70
          #define ENV1_ADD	<Your I2C address>
          #define ENV2_ADD	<Your I2C address>
          #define ENV3_ADD	<Your I2C address>
          #define ENV4_ADD	<Your I2C address>
          ...
          
          

          Baudrate for M5 core/Stick/camera:115200/921600
          For M5StickC:115200/230400/750000/1500000
          For M5StickV:115200/921600/1500000
          For Atom:115200/230400/921600

          1 Reply Last reply Reply Quote 0
          • m5stackM
            m5stack @thbonk
            last edited by

            @thbonk You can refer to these examples. Then combine them

            ENV:https://github.com/m5stack/M5Stack/tree/master/examples/Unit/ENV
            PaHUB:https://github.com/m5stack/M5Stack/tree/master/examples/Unit/PaHUB

            1 Reply Last reply Reply Quote 0
            • thbonkT
              thbonk
              last edited by

              @m5stack @sysdl132 I don't get it working. I have connected the PaHUB to my M5Stack and two ENV sensors to the PaHUB.

              When I run the PaHUB demo, it shows the addresses 0x5C, 0x70, 0x75 and 0x76 for channel 0 and 1, and 0x5C, 0x70, 0x75 for the remaining channels.

              I my own program, I added the class TCA9548A and DHT22 (I renamed TCA9548A to PaHUB).

              My setup function looks like this:

              #define PaHub_I2C_ADDRESS  0x70
              #define ENV_I2C_ADDRESS    0x76
              
              PaHUB pahub;
              
              void setup() {
                ez.begin();
                Wire.begin();
                pahub.address(PaHub_I2C_ADDRESS);
              }
              

              I defined a struct for my sensors:

              struct Sensor {
                uint8_t channel;
                DHT12   device;
                char*   name;
              };
              

              and an array of the struct which is initialized that way:

              struct Sensor sensors[] = {
                {0, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Left"},
                {1, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Hotspot"},
                {2, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Right"},
                {3, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Left"},
                {4, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Hotspot"},
                {5, DHT12(CELSIUS, ENV_I2C_ADDRESS), "Right"}
              };
              

              This is how I'm reading the sensors:

              struct SensorValues readSensor(int channel) {
                struct SensorValues sensorValues;
                struct Sensor sensor = sensors[channel];
                uint8_t returnCode = pahub.selectChannel(sensor.channel);
              
                Serial.println(" ---------- readSensor() ----------");
                Serial.print("pahub.selectChannel(");
                Serial.print(sensor.channel);
                Serial.print(") = ");
                Serial.println(returnCode);
              
                if (returnCode == 0) {
                  sensorValues.temperature = sensor.device.readTemperature();
                  sensorValues.humidity = sensor.device.readHumidity(); 
                }
              
                Serial.println(" ---------- readSensor() ----------");
              
                return sensorValues;
              }
              

              Unfortunately I'm receiving always 0 for both the temperature and the humidity.
              Could anybody please give me a hint what I'm doing wrong?

              Thanks & Best regards
              Thomas

              m5stackM 1 Reply Last reply Reply Quote 0
              • m5stackM
                m5stack @thbonk
                last edited by

                @thbonk actually , the ENV Unit build-in two sensor IC. they I2C address is DHT12(0x5C) , BMP280(0x76), i saw your code. you was only define a 0x76 , but it is the BMP280 I2C address.

                thbonkT 1 Reply Last reply Reply Quote 1
                • thbonkT
                  thbonk @m5stack
                  last edited by

                  @m5stack I only want to read the temperature and the humidity of the sensors connected to the PaHUB.

                  The M5Stck was connected to the Base BTC. The PaHUB was connected to the red Grove port and two ENV sensors were connected to channels 0 and 1 of the PaHUB. I then installed my application, but the ENV sensors connected to the PaHUB didn't deliver any values. When I queried the channels 2-5 of PaHUB I received values, but all were the same.

                  So I disconnected the M5Stack from the Base BTC; afterwards I received the temperature and humidity of the two ENV sensors connected to channels 0 and 1 of the PaHUB.

                  Is it somehow possible to connect the M5Stack to the Base BTC but read the sensors connected to the PaHUB? Or do I need the PbHUB to achieve this?

                  Best regards
                  Thomas

                  m5stackM 1 Reply Last reply Reply Quote 0
                  • m5stackM
                    m5stack @thbonk
                    last edited by

                    @thbonk in the I2C bus, you can't use two same address device at the same time. so if you connect the BTC to the BASIC, when the PaHUB switch channal select ENV Unit, it will working not normal. beacuse BTC and ENV all used DHT12, also has same I2C address

                    1 Reply Last reply Reply Quote 1
                    • O
                      OffLineR
                      last edited by

                      I keep finding this thread whenever I search using ENV II over PaHUB, so instead of openning a new one I wanted to continue on this.

                      I am new to development boards however I am an experienced platform developer.

                      I have a Core2 and I want to use PaHUB and add couple of more units to read. I have no problem reading data via using Wire command over PaHUB like using 4way Relay.

                      However, I have no idea how to use BMP and SHT over PaHUB. I have tried combining examples without any luck and tried above without any luck.

                      Question is after portselect, how come bmp access to right address? If you can point me to any direcon, I will be grateful.

                      Cheers.

                      1 Reply Last reply Reply Quote 0
                      • R
                        roccoskye @world101
                        last edited by

                        @world101 so the 1 to 3 Hub is used for 3 different i2C addresses?

                        C 1 Reply Last reply Reply Quote 0
                        • C
                          capacious @roccoskye
                          last edited by

                          @roccoskye Yes, the HUB makes it possible to connect more diferent I2C devices to the same port A. They all need to have different I2C addressess. The PaHub makes it possible to connect several sensors with the same I2C address and use them. On a HUB they would conflict and the system would know what sensor you'd be referencing to.

                          R 1 Reply Last reply Reply Quote 0
                          • R
                            roccoskye @capacious
                            last edited by

                            @capacious Ah ok thanks. Do you know how to use the 1 to 3 Hub because when i connect 3 devices to the hub i get the error message: Please change unit to other grove. Do I need to select custom ports for these devices?

                            1 Reply Last reply Reply Quote 0
                            • K
                              Kivlow
                              last edited by

                              @m5stack said in [Solved] Connecting 3 ENV units via 1 to 3 Hub to M5 Stack:

                              0x76

                              Hello,
                              i get a problem with Pa.HUB i connected to it ENV.III. I get Temp and Hum ok but i get -482827.3 for pressure.
                              What is wrong ??

                              teastainT 1 Reply Last reply Reply Quote 0
                              • teastainT
                                teastain @Kivlow
                                last edited by

                                @kivlow Hi! I have some experience with the PaHub and ENV sensors.
                                Could you post your code (if it is Arduino IDE) or if it is too big, email me?

                                Cheers, Terry!

                                100% M5Stack addict with several drawers full of product!

                                1 Reply Last reply Reply Quote 0
                                • K
                                  Kivlow
                                  last edited by Kivlow

                                  I use UIFlow
                                  i get weard readings like -482827.3 when connect to pa.hub but connected direct to core 2 ewerything is ok

                                  1 Reply Last reply Reply Quote 0
                                  • C
                                    Cmon169
                                    last edited by

                                    Hello,
                                    I just started learning how to code and would like to connect ENVIII Unit and Mini TVOC/eCO2 Gas Unit with the PA.HUB to the BASIC kit using the Arduino IDE.
                                    Is there a simple tutorial in how to use the addresses provided in PA.HUB git?

                                    Thanks

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

                                      There is generic information on the PAHubs product information page.
                                      An almost identical project was on my list for last week but didn’t get around to it

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