1

Allow me to start by saying I'm an absolute beginner when it comes to raspberry pi . I've recently purchased a raspberry pi b+ 3 model ,two mpu 6050 sensors (which I had to solder) and connected each to the pi.I have followed this guide https://tutorials-raspberrypi.com/measuring-rotation-and-acceleration-raspberry-pi/ and even managed to make the moving object in the video. I can detect each sensor separately using i2cdetect -y 1

0 1 2 3 4 5 6 7 8 9 a b c d e f

00: -- -- -- -- -- -- -- -- -- -- -- -- --

10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

60: -- -- -- -- -- -- -- -- 68 -- -- -- -- -- -- --

70: -- -- -- -- -- -- -- --

but when I attempt to connect two of them and just get them to register on the i2cdetect separately I still get the same message as seen above which to my understanding means I cannot read the second sensor.

After searching for some time I cannot grasp how I can connect those two and have them show multiple devices on the i2cdetect .

What I want to build as a final project is having at least 6 (up to 11) mpu 6050 sensors connected on a raspberry as well as some other components (up to 5 small haptic feedback motors ). Please bear in mind I am an absolute beginner and any help is very much appreciated.

Here's the connection of the two sensors I have so far in the physical world:

Raspberry and two connected MPU 6050 sensors

2
  • read this invensense.com/wp-content/uploads/2015/02/… .......... it states that AD0 is used to assign the last bit of the address ........ tie the AD0 on one module low and on the other module high (maybe all you have to do is tie one low)
    – jsotola
    Jul 12, 2018 at 21:44
  • Abandoned post by unregistered user.
    – Milliways
    Feb 15, 2023 at 6:53

2 Answers 2

1

Each I2C sensor comes with its own unique address and the code talks to only one sensor at a time. If you connect two similar sensors, they would show up on the same address and it would not be possible to talk to both the sensors. MPU9050 comes with an address select pin, so you can connect the ADD pin on one sensor to GND and ADD pin on another to 3.3V and they would show up in two address. You'll have to modify the code so that it can talk to the second sensor on the new address.

It would be impossible to connect 11 MPU6050 to the Pi since it has only 1 I2C bus and hence can only talk to two MPU6050 sensors since the sensor can only have 2 addresses. You can try using an I2C mux, but that would be very complicated. Maybe you can look at other sensors which come with more address select lines or you can look at multiple sensors or different kind each with their own address select

4
  • 1
    I2C multiplexors are easy to use, what experience caused you to think they are very complicated?
    – joan
    Jul 12, 2018 at 22:08
  • The Linux kernel handles I²C multiplexers automatically. Their outputs show up as separate buses.
    – Janka
    Jul 12, 2018 at 23:35
  • @joan By complicated, I meant in this application, since the guy wants to connect 11 sensors and only 2 of them can be connected on an I2C bus, so the number of MUX's required, their connections and the software to go along with it can be quite intimidating for someone new
    – karan
    Jul 13, 2018 at 4:53
  • @karan Fair enough (to someone unfamiliar to a topic perhaps everything appears intimidating).
    – joan
    Jul 13, 2018 at 7:46
0

Every device connected to an I2C bus needs a unique address.

Some devices allow you to vary the address by providing additional address pins. You set these pins high or low to set the devices to a unique address. If the MPU6050 has this feature then you need to set unique addresses for each device.

If it doesn't you have two choices.

  1. use an I2C multiplexor such as the TCA9548A which lets you connect up to 8 devices.
  2. use additional software I2C buses. This will be wasteful as you will need two GPIO per MPU6050 to be added.
2
  • I figured as much. I did change the address of one of the sensors by connecting the AD0 to the VCC of the pi and lo and behold it did give me an extra address that of 69.
    – Mike
    Jul 13, 2018 at 7:46
  • Hi @joan This is probably too late, but I'm kind of looking at a similar setup. Could you please briefly describe the second choice? (using additional software?) I will be using the Raspi only to interface 5-6 IMUs, and thus I can afford to use the GPIO pins. (I came across this instructables.com/Raspberry-PI-Multiple-I2c-Devices), is this what you were describing? If so, what additional software is required? Thanks! Oct 19, 2020 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.