StickC Plus + PaHUB + 3 Ultrasonic I2C units
-
@robot_alf "need to connect sensors to 1,2,3 ports of pahub, not to 0,1,2"
There are 2 hard problems in computer science: cache invalidation, naming things, and off-by-1 errors :D
-
@robot_alf That's encouraging.
I take that label0 is Ultrasonic_0
, label1 is Ultrasonic_1
, label2 is Ultrasonic_2
What happens if you complete the three unit ultrasonic set (by adding (Add/+) two more Ultrasonic units)?
Have you tried increasing the Wait? -
For reference/comparison. From drag and drop controls in UIFlow, I added the PaHUB first then 3x Ultrasonics (sub images pasted in and config as shown bottom right). The loop I know to work from my StickC and Ultrasonic unit. Drag in 3x labels and connect the dots.
-
Hmmm... I did the same several times and always not worked. Which PaHub are you used? I2C Hub 1 to 6 Expansion Unit (PCA9548APW) https://shop.m5stack.com/products/i2c-hub-1-to-6-expansion-unit-pca9548apw or [EOL] I2C Hub 1 to 6 Expansion Unit (TCA9548A) https://shop.m5stack.com/products/pahub-unit?variant=16804803412058 ?
-
Hi @robot_alf, I bit the bullet and bought some more hardware. So, now there are two of us in the same position.
1x StickC (freshly flashed from M5Burner v1.12.4)
1x M5Stack I2C Hub 1 to 6 Expansion Unit (PCA9548APW) SKU: U040-B
2x M5Stack Ultrasonic Distance Unit I2C (RCWL-9620) SKU: U098-B1Strating from a new UIFlow, click Run, and (drumroll please)... "X Ultrasonic unit maybe not connect", FFS.
The good news, I have a ENV III here, so I connected it and got the same error. Take out the Ultrasonic and it works fine (PaHub Added/+ or not). Excellent, so back to the blocks in UIFlow. I can see that the Ultrasonic unit from the ? link is SKU: U098, both of mine are SKU: U098-B1 – the "Sonic" rather than "Ultrasonic", no unit for that in UIFlow. Comparing the notes for U098 vs U098-B1, I came across this line: "This allows for easy I2C integration and multi-sensor operation using a single BUS, to save I/O resources.", interesting.
Hmm, [now rummaging around for all sorts of hardware] Groove2Duponts, check, breadboard, check, off we go...
Switched to Core2 and transferred all the rest of the hardware, inc. PaHub, same UIFlow setup, and guess what... it works as expected. Two independent readings/labels. NB Keep sensors a little bit apart to avoid cross talk.
I tried additionally with power from I2C port of Core2 and no change “X Ultrasonic unit maybe not connect”. Very annoying.
-
@gavin67890 yes it works perfect for Core2. I have the problem only on StickC Plus.
Okay, I tried to switch my project from PaHub to PbHub. I have such a hub too. I compared the photo of Ultrasonic I2C and IO versions (thanks a lot to M5 for this) and saw that it can be easily re-soldered I2C to IO. I made an IO out of one I2C sensor and it works fine, but not through PbHub. Actually now I'm at a dead end now ) It looks that I can't make a small mobile machine with two servos360 and three ultrasonic sensors on the StickC Plus (M5 engineers could you please add a function "get distance from ultrasonic" for PbHub?
-
@robot_alf, I can see the 0Ohm? resistors, interesting. Glad to hear at least the conversion worked.
Yeah, it's a bit disappointing because it's a common use case, multiples of the same ultrasonic sensors.
One thought, could you use the hat GPIO pins at the top of the StickC for the now IO ultrasonic sensor?
-
@gavin67890 Yes, you need to change two jumpers (0Ohm) in the IO position and also remove one resistor on the top of the board, which is labeled "IIC".
It was easier for me to short-circuit the contacts than to solder small transistors. So, you just need to unsolder three resistors and then make two short circuits.I think that need just to add a simple function to the PbBoard for ultrasonic sensors like this - https://github.com/ErickSimoes/Ultrasonic/blob/master/src/Ultrasonic.cpp
Because I can't to it through blocks or python, it's microseconds between send a receive an impulse. -
I tried the example in the following documentation, but I think it is out of date because the blocks are not available as shown in UIFlow https://docs.m5stack.com/en/uiflow/advanced/i2c (@m5stack can this be refreshed please).
Basically, I wanted to try and setup an I2C ultrasonic module from vanilla blocks, without Add/+ing the module and in accordance with this Arduino code https://github.com/m5stack/M5-ProductExampleCodes/blob/master/Unit/ULTRA/Arduino/ULTRA/ULTRA.ino and this https://www.sgbotic.com/products/datasheets/sensors/sr04_i2c.py for guidance/inspiration.
If I could be confident in the sensor, then maybe move back to the hub, then back to multiple sensors following the Arduino and converting back to vanilla blocks, something like this https://dronebotworkshop.com/multiple-i2c-bus/
I also tried the "Scan I2C device" block, which doesn't find address of Ultrasonic (0x57) at freq 400000 - fine for ENV III [0x44, 0x70] and PaHub [0x70] – ENV III on its own definitely scans as two addresses. freq reduced to 100000 it finds the ultrasonic address.
If I try and use the "Available I2C address in list" block I get I2C bus error (19) message (StickC and Core2), any help appreciated on why.
I'd really like to figure this out as I2C ultrasonic sensor arrays would be extremely useful for driving vehicles.
-
I'd like to get to this, which should be possible using PaHUB and the sensors (easier to assemble with M5Stack with sensors in cases, up to 6 at a 30deg angle to each other).
https://www.hackster.io/user04650005/ultrasound-sensor-array-with-the-hc-sr04-f7108f -
Interesting from UIFlow2.0, is there a similar global? control for bus speed in UIFlow v1.12.4?
-
Anyone got any more thoughts? My intension is to raise it as a bug (I think we've exhausted our best ideas).
-
Continuing my tale-of-woe about the PaHub:
I have now tried using G0 and G26 (StickC) to connect as custom I2C to PaHUB with the ENV III attached, which works on Port A.
Via the PaHUB using the top hat pins (the pins an I2C hat uses). I get "Pahub unit maybe not connect", fine on Port A.