Offline
Newbie
Karma: 0
Posts: 8
|
 |
« on: September 23, 2012, 11:03:36 pm » |
HI, I a completely new to Arduino and this is my first time posting on this forum. I have the Arduino Uno R3 and I bought the GY-521: http://arduino.cc/playground/Main/MPU-6050So after doing some research, i found a post that showed how to connect gy-521 to the Arduino: Arduino +5V to VCC Arduino GND to GND Arduino analog input pin A4 to SDA Arduino analog input pin A5 to SCL I guess this is the standard way to connect to a i2c device? anyway, I ran the i2c scanner found here: http://arduino.cc/playground/Main/I2cScannerbut for some reason, it doesn't find the device. I was hoping someone could tell me what I am doing wrong. Thanks!
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay area
Offline
Full Member
Karma: 0
Posts: 165
|
 |
« Reply #1 on: September 24, 2012, 12:33:56 pm » |
you must disable the internal pullups to A4 and A5 if you are not using a logic level converter.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #2 on: September 24, 2012, 08:06:25 pm » |
how would I disable the internal pullups? (sorry, very new to this)
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay area
Offline
Full Member
Karma: 0
Posts: 165
|
 |
« Reply #3 on: September 24, 2012, 09:53:22 pm » |
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #4 on: September 24, 2012, 10:13:03 pm » |
ok so I tried: (I also tried setting the values to HIGH) digitalWrite(A4,LOW); digitalWrite(A5,LOW); it didn't work. I am guessing because :
"This sensor board has a voltage regulator. So it can be used with 3.3V and with 5V. It has pull-up resistors of 2k2 on the I2C-bus. The value of 2k2 is rather low. If it is combined with other sensor board which have also pull-up resistors, the total pull-up impedance might be too low."
Anything else I can try?
|
|
|
|
|
Logged
|
|
|
|
|
SF Bay area
Offline
Full Member
Karma: 0
Posts: 165
|
 |
« Reply #5 on: September 24, 2012, 10:24:10 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 9
Posts: 1003
|
 |
« Reply #6 on: October 01, 2012, 02:57:33 am » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 8
|
 |
« Reply #7 on: October 24, 2012, 10:05:26 pm » |
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
|
|
|
|
|
Logged
|
|
|
|
|
Indiana
Offline
Jr. Member
Karma: 0
Posts: 56
|
 |
« Reply #8 on: December 27, 2012, 02:29:57 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Indiana
Offline
Jr. Member
Karma: 0
Posts: 56
|
 |
« Reply #9 on: December 27, 2012, 03:30:27 pm » |
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.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 23
|
 |
« Reply #10 on: January 24, 2013, 08:02:38 pm » |
Hi, i have an arduino pro mini, and a breackout board GY-521, the board is perfectly recognized from the arduino and i can read the values. But i haven't undestand if are needed the pull up resistor on SDA and SCL. I don't want broke the board.
Thanks a lot!
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Edison Member
Karma: 9
Posts: 1003
|
 |
« Reply #11 on: January 24, 2013, 10:09:12 pm » |
If I look at a photo of the GY-521, I can see two pull-up resistors of 2k2 (the black smd components with the text "222"). So you don't need to add them yourself.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #12 on: March 27, 2013, 11:14:58 pm » |
I am following this same approach below. But I get error "no I2C device found" Any thoughts? 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
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 0
Posts: 4
|
 |
« Reply #13 on: March 28, 2013, 12:41:14 pm » |
ah, got it. directly connecting UNO R3 SCL, SDA to to GY-521. Wasn't getting power earlier.
|
|
|
|
|
Logged
|
|
|
|
|
|