2022-11-16 07:31 AM
2022-11-16 10:47 AM
One. More. Time.
There is an address pin on the MPU-6050. Ground the "AD0" pin on one board and tie it to VCC on the other board. Look at the data sheet to see what the two addresses are. Connect those two boards to one I2C bus. Then repeat that on the 3rd and 4th boards and connect them to a second I2C port.
Or - get an I2C MUX (for example, https://www.adafruit.com/product/2717), connect that mux to the I2C port, then connect the 4 sensors to the 4 ports on the mux. You may need to add pull-up resistors on the mux ports - check the data sheet/schematic to see.
Or - as @Community member mentioned, each I2C port is usually available on more than one set of pins on the STM32. By re-configuring the GPIO pins and their "alternate function" mapping, you can have a single I2C port on multiple pairs of pins (but only one pair at a time).
2022-11-16 08:03 AM
It looks like the mpu-6050 has only one address select line. Which means at most 2 of these can be placed on a single I2C bus.
Unless you can add external I2C bus buffers/isolators, or an I2C Mux. Then you can turn the isolators on/off to each mpu-6050, or switch the mux to each unit one at a time.
The F401 has several I2C ports. Is there some restriction limiting you to only using one?
2022-11-16 08:09 AM
i managed use 1 mpu6050 but i need use 4 mpu6050 with stm32. But f401 has 3 i2c channel.
2022-11-16 09:12 AM
Check how many pins any specific I2Cx SCL signal can be mapped.
Then multiplex between them.
2022-11-16 09:35 AM
how to multiplex between them. can ı read 4 mpu6050 angle from one i2c channel ? is it possible??
2022-11-16 10:47 AM
One. More. Time.
There is an address pin on the MPU-6050. Ground the "AD0" pin on one board and tie it to VCC on the other board. Look at the data sheet to see what the two addresses are. Connect those two boards to one I2C bus. Then repeat that on the 3rd and 4th boards and connect them to a second I2C port.
Or - get an I2C MUX (for example, https://www.adafruit.com/product/2717), connect that mux to the I2C port, then connect the 4 sensors to the 4 ports on the mux. You may need to add pull-up resistors on the mux ports - check the data sheet/schematic to see.
Or - as @Community member mentioned, each I2C port is usually available on more than one set of pins on the STM32. By re-configuring the GPIO pins and their "alternate function" mapping, you can have a single I2C port on multiple pairs of pins (but only one pair at a time).
2022-11-16 11:00 AM
One I2C peripheral, not sure, I'm not going to do the due-diligence on this for you.
I do believe there's more than one pin that each I2Cx peripheral can map to the SCL
You'd configure them as GPIO or AF, with a pulled-high OD, and you'd cycle which is internally connected to the SCL of the peripheral.
I think you only need to switch the SCL (clock) pin, the unconnected slave(s) won't see an active bus, and won't respond.
2022-11-16 02:43 PM
I understand what you mean. I will change the address by applying different voltage(0-1) to the ad0 pin of the mpu 6050 and I will communicate from 2 sensors over a single i2c pin.
If I use the multiplexer in the link you shared, how will I know which mpu6050 has which address?
Moreover,Thank you very much for your reply. it will work for me.
2022-11-16 02:45 PM
Thx for answer
2022-11-16 03:28 PM
If you use the MUX, then all four MPU-6050 units can have the same address. You send a command to the MUX (at its own I2C address) to tell it which port you want to talk to. For example, if you connect the sensors to mux ports 0 to 3: