Hello
I am trying to use an Arduino Uno to read from a GY-521 gyroscope, but having some problems. I followed this tutorial exactly, but all the axis were reporting -1 every time. I also tried the official tutorial, but the output numbers would never change. When I used the I2C scanner, it reported no devices connected. I am certain I have installed all the necessary libraries and wired everything correctly.
This forum post describes a problem very similar to mine, but the person was using a different Arduino and wired it incorrectly. I have tried multiple sketches, libraries, tutorials, Arduinos, gyroscopes, and everything I can think of, but nothing is working.
I am at a loss for what to do, any help would be greatly appreciated.
Attached to this post is a picture of my breadboard, as well as the output from the example sketch found here.
Output.txt (2.13 KB)
When I used the I2C scanner, it reported no devices connected.
So that is the place to start looking, unless you get something showing up at the right address nothing else will work and it is a waste of time trying.
Common problems with getting I2C to work are getting the clock and data lines mixed up, not setting the address on the device correctly or not having pull up resistors on both signals. The internal pull-ups on the Arduino are weak and if the board has none then things often fail. Use two 4K7 resistors.
Your photograph it too high contrast and not positioned well enough to actually see what connects to what.
I attached two 4.7k resistors to my circuit according to the schematic on the tutorial, but still no luck. I also tried adding a 22k resistor to the ground, but still nothing.
After scrolling through some Amazon reviews, I came across a person who was saying that the GY-521 worked perfectly with their ESP-32 board. I wired up my own ESP-32 board and it reported that there was indeed an I2C device connected. This implies the problem is on the Arduino's side. However, when I tried the ESP-32 board with the GY-521 example sketch, the output was 0's for each axis with -11 as the error code. This is different from the Arduino, but still useless. I also tried changing the address in the sketch to the one that the I2C scanner reported, but no luck. When I attach the pull-up resistors to the ESP-32 board and run the I2C sketch, the output spits out ~40 "connected devices". It is all very strange.
Here is a better picture of my breadboard (with the pull-up resistors).
The MPU-6050 is a 3.3V device -- never expose the device inputs to 5V.
To use any 3.3V I2C device with a 5V Uno, you need to connect the pullup resistors to 3.3V or (better) use 5V to 3.3V level shifters for the I2C lines. You chose a poor tutorial to follow.