How to use multiple Units wired via GROVE? PbHub?



  • I've been using the HAT for the M5 successfully but there is only one at a time. I just got my first UNIT running connect to the M5 (the Key Unit touch button).

    My question is how am I supposed to run multiple sensor UNIT's using all the daisy chaining of the GROVE wires? I just came upon the PbHUB concept that seems to be needed. Can someone explain the PbHUB?

    My real question is how does the code work when almost all are using the same PIN numbers - and now there will be multiple UNIT's running at the same time. What PINS do they user? Is the PbHUB the way to change those PIN numbers for say 4 push button Keys?

    Please help enlighten me on how one develops code for this plug-n-play variability?

    Thanks.



  • @konacurrents the PbHUB is a I2C connected device with a STM microcontroller on board that operates (or monitors) 6 Grove Port B type sensors, switches, RGB LEDs, and motors for you on each port, relatively seamlessly, but there can be some limitations, such as each port has two wires and one is an input and the other is an output.

    Push 4 keys! The hub is very fast with STM and I2C and they will appear concurrent.



  • The Pbhub is an I2C that assigned I2C address to each pin connected to it.
    In UIFlow you select the Hub and then when you add additional devices like buttons you select the hubs port location in the dropdown list instead of the cores port.



  • Will need to try it out (once I get one). But how would C code know which PIN is for which device? The examples all use a specific pin, so I assume there is a way to specify once they are plugged in?

    My challenge in general is to extend my M5 with plug-n-play sensors - but without modifying the base code. The HAT on M5 works but some devices are too slow if they aren't plugged in (PIR is fast but LUX is slow).

    So it would be great if there was a way to know what sensors are active. Worst case is a configuration message over BLE or MQTT denoting what's plugged in and which pins, etc. I'm doing that with LUX as once it gets a bad reading, it turns that code off. But a MQTT message can ask to recheck and turn it on.

    Finally is PbHUB required to plug in a couple sensor units? (A) if same unit kind, (b) different unit. PIR and KEY for example.

    Thanks





  • Ok, now I'm confused. Can you explain the difference between I2C and Unit I/O? I just want to plug in the the HUB and have multiple Unit's.

    I'm ordering the PbHUB but also want the Ultrasonic Distance, but it comes in 2 modes:

    Ultrasonic Distance Unit I/O (RCWL-9620)
    Ultrasonic Distance Unit I2C (RCWL-9620)

    Or do I get the PaHUB ??



  • I/0 is analog where as I2C is a digital addressed system that send the deice address and the value.

    All I2C devices have their own address and you need to make sure no two devices have the same address. If you use the I/O unit with outer I/O units (PortB/Black Port) then you need the PBHub.



  • Thanks for the detailed replies to my wire questions. Maybe with
    this more concrete example you could let me know what I need.

    I have the following:

    1. M5 Atom Lite (or M5 or Core2)
    2. Key Unit (Button)
    3. PIR Motion Unit
    4. Ultrasonic Distance
      4.a Unit I/O
      4.b I2C

    I can get the Key Unit working using 1 GROVE wire.
    #define KEY_PIN 33

    I assume to connect the other Units I use the Grove-T Connector.

    But how do I talk to the PIR and other Units?

    a: To connect the PIR motion sensor, do I need a HUB?
    b: Adding the Distance Unit: Would the I/O (4a) or I2C (4b) be
    easier to integrate?

    In this example,
    a. is the PbHUB required?
    b. Or is the PaHUB better?

    I'm using straight Arduino C as I have a complex
    capability built already. I just want to add some
    of these Unit sensors.

    Thanks.
    scott



  • The Key unit and the PIR unit and the ultrasonic I/O unit use the same I/O pin and so you need a PBhub for them.
    The PbHub and the I2C Ultrasonic unit have different addresses (should) so can connect to the same I2C port unit a groveT adapter.



  • Thanks, that helps a lot. This is my first use of the Unit devices. I've use the HAT on the M5
    which obviously is only 1 at a time.

    I'll get the PbHUB and the I2C version of the Ultrasonic Distance Unit.

    I'm working on many sensors to help disabled users. These sensors help those in
    wheelchairs where they might not be able to even touch buttons. So providing a multitude
    of options (motion, tilt, distance, LUX, buttons) - even the touch of the Core2 is very sensitive
    which is good.

    Thanks,