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

    ENV Hat 3 and StickC Plus 2 [Wire.513] requestFrom(): i2cRead returned Error 263

    M5 Stick/StickC
    3
    17
    1.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.
    • felmueF
      felmue @ajb2k3
      last edited by felmue

      @PascalS

      the only difference between Hat and Unit (apart from the different GPIOs it uses as @ajb2k3 pointed out) is that the Hat is powered by 3.3 V from M5StickCPlus2 whereas the Unit is powerd by 5 V (with an internal DC/DC converter).

      I used the M5Unit-ENV library, copied the code you posted and manually wired the Unit to the Hat port. In other word I used exactly the code you posted without any modifications.

      Sorry, at this point I have not more ideas as to why it wouldn't work on your side.

      Thanks
      Felix

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

      P 1 Reply Last reply Reply Quote 0
      • P
        PascalS @felmue
        last edited by

        @felmue From your posts, I get the feeling that you have a lot of knowledge. :)

        As a last ressort, I tried to find a I2C scanner sketch and ended up with the following code.

        /*********
          Rui Santos
          Complete project details at https://randomnerdtutorials.com  
        *********/
        
        #include <Wire.h>
         
        void setup() {
          Wire.begin();
          Serial.begin(115200);
          Serial.println("\nI2C Scanner");
        }
         
        void loop() {
          byte error, address;
          int nDevices;
          Serial.println("Scanning...");
          nDevices = 0;
          for(address = 1; address < 127; address++ ) {
            Wire.beginTransmission(address);
            error = Wire.endTransmission();
            if (error == 0) {
              Serial.print("I2C device found at address 0x");
              if (address<16) {
                Serial.print("0");
              }
              Serial.println(address,HEX);
              nDevices++;
            }
            else if (error==4) {
              Serial.print("Unknow error at address 0x");
              if (address<16) {
                Serial.print("0");
              }
              Serial.println(address,HEX);
            }    
          }
          if (nDevices == 0) {
            Serial.println("No I2C devices found\n");
          }
          else {
            Serial.println("done\n");
          }
          delay(5000);          
        }
        

        I was not sure, but in all the sketches they used sda=0 and scl=26.

        If I scan those, I cant get any devices found. However, if I scan the standard sda/scl = 21/22, then I find two devices (propably build into the Stick itself).

        Is this a sign for an hardware failure?

        Greetings Pascal

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

          Hello @PascalS

          from your first log I think the ENV III Hat was recognized properly else the log would have ended with either of the "Couldn't find ...".

          Anyways, please find an I2C scanner for internal, Groove and Hat here.

          Thanks
          Felix

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

          P 2 Replies Last reply Reply Quote 0
          • P
            PascalS @felmue
            last edited by

            @felmue Thanks for the link.

            Strangely, they are now not showing up (not found is now in the log). That wasnt before.

            1 Reply Last reply Reply Quote 0
            • P
              PascalS @felmue
              last edited by

              @felmue

              The port scan went as expect, only internals are found.

              I2C Scan - internal
              ................................................................................0x51 ......................0x68 ......................
              I2C Scan - Groove Port
              ..............................................................................................................................
              I2C Scan - Hat Port
              ..............................................................................................................................

              Does that mean a hardware error?

              Greetings Pascal

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

                Hello @PascalS

                hmm, have you tried to power cycle M5StickCPlus2?

                1. disconnect USB
                2. remove HAT
                3. press and hold power button until green LED lights up
                4. release power button - green LED goes dark - M5StickCPlus2 is now off
                5. re-attach HAT
                6. re-connect USB - M5StickCPlus2 powers on
                7. re-test

                Thanks
                Felix

                P.S. if that doesn't make the HAT show up in the I2C scan or make it work with the original program then I am afraid that yes, there might be a hardware issue.

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

                P 2 Replies Last reply Reply Quote 0
                • P
                  PascalS @felmue
                  last edited by

                  @felmue Thanks for your help :)

                  Propably it is a hardware failure, I do not get any i2c signals back.

                  Wil return it and run it with new hardware. I update the thread when I heard back from the seller.

                  Thanks for your help!

                  Greetings Pascal

                  1 Reply Last reply Reply Quote 0
                  • P
                    PascalS @felmue
                    last edited by

                    @felmue Unfortunately, also a newly bought M5Stick and a newly bought ENV hat didn´t change anything.

                    Could it be that the hat port uses another Wire?

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

                      Hello @PascalS

                      hmm, that is really strange. Do you have any other hat to try if the hat port works for you in general?

                      ENV III hat is supported in UIFlow2. Maybe try with UIFlow2? Just to see if it works that way.

                      Thanks
                      Felix

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

                      P 1 Reply Last reply Reply Quote 0
                      • P
                        PascalS @felmue
                        last edited by

                        @felmue You were right, in UIFlow 2 it worked perfectly fine. However, I need them to work in Arduino, so that it fits with our current framework.

                        Do you know were the difference between UIFlow 2 and Arduino is?

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

                          Hello @PascalS

                          at least we know now that the hardware is ok.

                          Apart from that I am stumped. Sorry.

                          Thanks
                          Felix

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

                          P 1 Reply Last reply Reply Quote 0
                          • P
                            PascalS @felmue
                            last edited by

                            @felmue Finally I got the solution using separate Wires and PlattformIO to manage my libraries :)

                            With the following ini file (PlattformIO config file)

                            [env:miniscale]
                            platform = espressif32@6.1.0
                            board = m5stick-c
                            framework = arduino
                            lib_ldf_mode = deep
                            monitor_speed = 115200
                            build_flags = 
                            	-DCORE_DEBUG_LEVEL=0
                            	-Wl,--allow-multiple-definition
                            lib_deps = 
                            	https://github.com/m5stack/M5StickCPlus2.git
                            	m5stack/M5Unit-ENV@^1.0.1
                            

                            Not knowing why, but I need the "-Wl" to run at all and the "--allow-multiple-definition" flag for the hat to work in conjunction with sensors mounted to the groove port.
                            It worked, however, I need to change the I2C begin call from "Wire0" (just called Wire) to the secondary I2C channel Wire1

                            Before:

                            while (!qmp.begin(&Wire, QMP6988_SLAVE_ADDRESS_L, 0, 26, 400000U)) {
                                 Serial.println("QMP6988 not found");
                             }
                            

                            After:

                            while (!qmp.begin(&Wire1, QMP6988_SLAVE_ADDRESS_L, 0, 26, 400000U)) {
                                 Serial.println("QMP6988 not found");
                             }
                            

                            Maybe this helps someone in the future :)

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

                              @PascalS Now I see the problem.
                              Wire is hard defined and set to internal.

                              You need to use Wire1 to access the external devices.
                              I vaguely remember reading about this issue before but as I don't have arduino I had forgotten about it.
                              Thanks for the reminder.

                              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