Accessing the i2c of raspberry pi connector mangoh red

Hi!
I’m new to legato and mangoh red and could use some advise.
I want to connect an external accelerometer to the i2c pins of the raspberry pi connector of a mangoh red (wp7607) .

  1. Is there any example of how to get sensor data from the raspberry connector (i2c) to a similar file as the one used by the on-board sensors in the redSensorToCloud app (sys/bus/i2c/devices/4-xxxx)?

  2. Where/How can I access the i2c bus of the raspberry connector i2c-lines?

The accelerometer I want to use:
the sensor module: https://www.seeedstudio.io/s/Grove-3-Axis-Digital-Accelerometer-%C2%B116g-Ultra-low-Power-(BMA400)-p-3201.html

BMA400: https://www.elfa.se/Web/Downloads/_t/ds/101020582_BMA400_eng_tds.pdf

Thanks in advance!

Hi mastr

I think mangoh Red already support accelerometer on board?

For reading I2C bus on raspberry Pi connector.
You can refer to example with Grove LedMatrix Driver.

Thanks
Thong

Thanks for the answer!

Yes I have used the accelerometer on the mangoh red board with the redSensorToCloud app. But I want to explore the possibility of connecting an external accelerometer as well.

From the example GroveLedMatrixMangOH
In the ledmatrix.adef:
//replace these devices based on your module
[rw] dev/i2c-0 dev/i2c-ledmatrix

  1. Is the device i2c-0 the i2c bus of your component?
  2. How do I know where I can find the i2c bus of my accelerometer?

When I do i2cdetect -l

and i2cdetect -y -r 4

Thanks in advance!

Hi @mastr,

  1. Is the device i2c-0 the i2c bus of your component?
    –>yes, for your module , I think that i2c-4 is corresponding.
  2. How do I know where I can find the i2c bus of my accelerometer?
    –>Unfortunately, I also can’t find out i2c bus of my device by using i2cdetect -y -r 4 (for wp76xx) and i2cdetect -y -r 0 (for wp8548) but you can follow code what I referred to you above and using logread -f command to track whether you can send data to I2C device or not.

Thanks
Thong

Hi @mastr,
I realized that I was confused about the question number 1, as you mentioned, It seems that your module has been enabled all virtual buses by kernel driver of i2c-hub (pca954x), so you can see /dev/i2c-5, /dev/i2c-6, /dev/i2c-7, /dev/i2c-8
follow schematic of mangoh red https://mangoh.io/uploaded-documents/Reference/mangOH%20Red/Hardware/Schematics/MangoRed_DV6_final.pdf you can see the raspberry pi header, the I2C lines are labeled SDA_EXP, SCL_EXP and connect to SD3, SC3 (channel 3) of TCA9546A hardware, the hardware has 4 channel 0-3 correspond to virtual buses 5-8, so if you want to access the i2c of raspberry connector, please use /dev/i2c-8.

Note : if you follow my source, please remove lines from 822 to 856 in ledmatrixUtils.c file, because your module has been enabled i2c-hub.

Thanks,
Thong

Thank you @Thong

Perfect, I managed to find the i2c bus on /dev/i2c-8.

Thank you very much :smiley: