Go Down

Topic: Using GY-521 Accelerometer + Gyro (Read 19 times) previous topic - next topic

doughboy

did you configure both A4 and A5 as input first?
It does not matter what the pullup on your board is. what matters is the cpu internal pullup is to 5v and your sensor board pullup is to 3.3v and you don't want to mix them. A4 and A5 are special pins that are open collector specifically designed so if you disable the internal pull up, only the external pullup wll be used. its all in the atmega328 datasheet if you want to read about it.

Krodal

You did the right thing : Just 4 connections (+5V to VCC, GND to GND, A4 to SDA, A5 to SCL).
After that the i2c_scanner should see the device.

Do you have another i2c device ?
Perhaps you should try that first, to see if the Arduino is working.
Use the i2c_scanner to test it.

If the i2c_scanner can't find anything, some connection is bad, or your sensor board has a problem.
Test everything very careful, and check the sensor board with a magnifying glass or take a picture with a camera with macro.
Check every solder point. Measure the 3.3V on the sensor board.


gevo12321

Thanks for your help guys. Just wanted to leave a record of how I fixed the problem for future reference.

I did not want to change any of the source code in case I needed the same code without the changes in the future so I ended up getting a logic level converter(they are very cheap).

I got the Sparkfun logic level converter and there is one little detail that should be kept in mind when using it. Since i2c lines need 2 way communication, make sure to use the bidirectional Tx lines on the logic level converter and not the Rx lines.

Anyway, in the end I did not change any of the code and my setup was as follows:

Arduino +5V to VCC on GY-521 and to Hv on the Logic Level Converter
Arduino +3.3V to Lv on the Logic Level Converter
Arduino GND to GND on Gy-521 and both GNDs on the Logic Level Converter
Arduino analog input pin A4 to ch1 Tx on Hv side and ch1 Tx on the Lv side to SDA on GY-521
Arduino analog input pin A5 to ch2 Tx on Hv side and ch2 Tx on the Lv side to SCL on GY-521

thanks again for your help

jjspierx

I am having problems getting the i2C scanner to recognize my GY-521.  I am trying to connect it without using a logic level converter if possible.

I tried setting the A4 and A5 pins as inputs, setting them low to disable the internal pull-ups using the following code:

pinMode(A4, INPUT);
pinMode(A5, INPUT);
 
digitalWrite(A4,LOW);
digitalWrite(A5,LOW);

However, when I upload this code, the serial monitor doesn't even update, and TX light on the Arduino Uno does not blink.  This happens with either the pinMode or digitalWrite functions commented out as well.  However, with both of them commented out, the I2C scanner works, but does not see any I2C devices

I also tried adding 4.7k resistors as pullup resistors between SDA and SCL and pins A4 and A5.  When I do this the scanner does not find any I2C devices. The GY-521 is on (blue led is lit up) but nothing I do seems to make the I2C scanner find a I2C device.

Any other ideas?

Thank you in advance.



jjspierx

I just got the scanner to recognize the GY-521.  I didn't realize the Uno R3 has SDA and SCL pins (next to AREF).  Once I hooked up to the dedicated SDA and SCL pins, the device is now recognized.  Hopefully this helps somebody else using an Uno R3.

Go Up