ENV Hat 3 and StickC Plus 2 [Wire.513] requestFrom(): i2cRead returned Error 263
-
@felmue Thanks for your test.
Unfortunately I cant get either of them to connect.
Is their a difference between Hat and Unit? Which library versions did you use?
-
@PascalS HATS use different pins to UNITS
-
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 -
@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
-
-
@felmue Thanks for the link.
Strangely, they are now not showing up (not found is now in the log). That wasnt before.
-
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
-
Hello @PascalS
hmm, have you tried to power cycle M5StickCPlus2?
- disconnect USB
- remove HAT
- press and hold power button until green LED lights up
- release power button - green LED goes dark - M5StickCPlus2 is now off
- re-attach HAT
- re-connect USB - M5StickCPlus2 powers on
- re-test
Thanks
FelixP.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.
-
@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
-
@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?
-
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 -
@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?
-
Hello @PascalS
at least we know now that the hardware is ok.
Apart from that I am stumped. Sorry.
Thanks
Felix -
@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 Wire1Before:
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 :)
-
@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.