gy-521

Hello,

I am just starting to work with arduino. I have a Mega2560 and a GY-521 board and some problems.
So after some research first I ran an I2C scanner and found the MPU on the 0x68 adress.
My gy-521 is connected this way:

VCC ---- 5V
GND ---- GND
SCL --- SCL
SDA ---- SDA

I don't know if I should connect the INT pin to "2" pin on arduino. I have tried this code with INT both connected and disconnected, it gives the same result.

I used the code from arduino playground. This one.. And I am getting the same 2 reading over and over again, with 2 errors on the beginning.
I don't know the code well enough to identify these errors, could you give me a hand?

These are the readings. After the first two readings, it just continues repeating those two readings.
Any idea what "who_am_i: a4, error = 2....pwr_mgmt_1 : a4, error = 2" is and what I am doing wrong? Thank you!

who_am_i: a4, error = 2
pwr_mgmt_1 : a4, error = 2


MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 512, 2, 1023
temperature: 36.506 degrees Celsius
gyro x,y,z : 5376, 0, 4593, 

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 2, 512, -253
temperature: 36.506 degrees Celsius
gyro x,y,z : 21, 0, -3823

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 512, 2, 1023
temperature: 36.506 degrees Celsius
gyro x,y,z : 5376, 0, 4593, 

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 2, 512, -253
temperature: 36.506 degrees Celsius
gyro x,y,z : 21, 0, -3823

Or something like this on another try.

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 2, 0, 2079
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 16384, 0, 

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 512, 0, 7944
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 64, 0, 

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 2, 0, 2079
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 16384, 0, 

MPU-6050
Read accel, temp and gyro, error = 2
accel x,y,z: 512, 0, 7944
temperature: 36.506 degrees Celsius
gyro x,y,z : 0, 64, 0,

I think that is the error from Wire.endTransmission.
http://arduino.cc/en/Reference/WireEndTransmission
Error 2 means that the Slave did not respond with an acknowledge.

In other words: The I2C bus is not working.

How long are your wires (try less than 50cm).
Do you use flat ribbon cable for the I2C bus (you should not do that).

What happens if you let the i2c_scanner run for a while. Is it stable ?

You can test your I2C bus with the Multi Speed i2c scanner :

Hi, thanks for looking into it.

My wires are <10 cm. I’m using wires out of an ethernet cable, the only thing I got atm.

Running i2c_scanner for some time and it seems stable. Running the MultiSpeecI2CScanner it isn’t so stable. Finds it some of the time, then it stops finding it and only finds it again when I restart it or something.

Something is not okay. Perhaps a breadboard with bad contacts. Can you check with a magnifier the GY-521 sensor board. Is everything soldered well ? Do you have a multimeter to measure the voltages ? For example the voltage of the 3.3V voltage regulator on the sensor board.

I will try to find a magnifier for the soldering on the board. I have a multimeter.

Should I measure the voltage on the KB33 regulator on the board? On which pins exactly?

Perhaps the board has a 3.3V pin ? Or else measure the voltage regulator. One pin should be 5V, one 3.3V and one 0V. There must be a capacitor at the 3.3V, so you can also measure the voltages of the capacitors.

When you click the “REPLY” button, there is an option below the text input field to attach a photo. You could make a photo of Arduino + sensor board + wires.

Hi sry for answering late, had stuff at university.

I couldn’t really measure the voltage, it’s all so tiny to me and I cant navigate well enough, especially since I welded the IMU so it fits on the protoboard in an upward position. I tried both VCC - 5V and 3.3V and both are giving the same result.

I connected everything again today and i2c scanner found a device at x01 (used to be x68). I ran the i2c multispeed scanner and it found 63 !?! devices. No idea.

Everything is connected as I wrote in the first post. Here are the pictures if they can help you. I will try to connect everything once more and scan for I2C and try to measure the voltage. Thanks for helping.

VCC ---- 5V
GND ---- GND
SCL — SCL
SDA ---- SDA

download.jpg

Thanks for the photos.
You need a I2C level shifter.

The Arduino Mega 2560 has a 5V I2C bus, because there are 10k pullup resistors on the Mega board. This is only for the Mega board.
I should have thought of that sooner :-[

The MPU-6050 sensor is a 3.3V sensor. If you connect it like this, the 5V (via the 10k pullup on the Mega board) flows into the MPU-6050 via the SDA and SCL. The MPU-6050 might already be damaged.

Buy a I2C level shifter. I use these : http://www.ebay.com/sch/i.html?_sop=15&_nkw=i2c+level+module&LH_BIN=1
You might also need a new MPU-6050 module.

Just redid everything. The i2c scanner founds it at x68 again.

I ran the i2c multispeed and it works on 3.3V (sometimes it doesnt find it tho) and on 5V it stop in the middle of the first scan and freezes.

How come the gy-532 needs 3.3V, I read on multiple occasions that it has a voltage regulator (the KB33 on the IMU) and can work on both 3.3V and 5V?

EDIT: If I understood corectly, even though I can connect the IMU to the 3.3V, the 5V still goes to the SDA and SCL, and that is the problem?

Yes.

The voltage regulator on the GY-521 makes 3.3V for the power of the MPU-6050. It is therefor even better to use 5V for the VCC than 3.3V. When 3.3V is used, it must go through the voltage regulator and that makes 3.2V for the MPU-6050, but 3.3V is preferred.

The current from the Mega board 5V via the 10k into the SDA and SCL travel into the MPU-6050 chip, probably lifting the voltages inside the poor chip.

Ok. Thank you very much for your help!! I really appreciate it!

I will check if the MPU is still working on an UNO these days or I need to get a new one, and I will order the i2c level shifter so I can use it on my mega.

Hi, I got the i2c leveler from ebay.

Not getting any response so I want to check if I connected it right.

IMU VCC - 5V
IMU GND - GND
IMU SDA - TX1 (low side of leveler) --- TXO (high side) - SDA on arduino.
IMU SCL - TX0 (low side, channel 2) -- TXO (high side) - SCL on arduino.

leveler HV - 5V
leveler LV - 3.3V
leveler GND's - GND


My leveler looks like this.

(TXO-RX1) - HV - GND (RX1-TX0) -// this is top side, brackets are seperate channels.
(TX1-RX0) - LV - GND (RX0 - TX1) // bottom side

Those on Ebay are clones of the Sparkfun level shifter.

Here is how to use it : http://letsmakerobots.com/blog/unixguru/running-both-5v-and-33v-devices-i2c

I'm not sure how you describe the SCL signal. The opposite pins should be used.

It can shift 4 signals, and it is the same for all 4. You can select any of those 4.
The labels are confusing, that is why Sparkfun uses new labels now : Bi-Directional Logic Level Converter Hookup Guide - learn.sparkfun.com