Tropics
Posts: 6
Joined: Fri May 12, 2017 9:15 am

GY-521 I2C not detected on Pi

Fri May 12, 2017 9:25 am

Hello,
I've been trying to get my GY-521 accelerometer connected with my pi for few good hours now without success :(
The accelerometer has 8 pins (VCC,GND,SCL,SDA, XDA, XCL, ADO, INT).
I connected them as follows:
VCC -> pi 5v (pin 2)
GND -> pi gnd (pin 6)
SCL -> pi scl (pin 5)
SDA -> pi sda (pin 3)
ADO -> pi 3.3v (pin 1)

i enabled I2C on pi, and i made sure its working by running the following:

Code: Select all

pi@raspberrypi:~ $ ls -l /dev/i2c*
crw-rw---- 1 root i2c 89, 1 May 12 09:17 /dev/i2c-1
And yet whenever i run

Code: Select all

i2cdetect -y 1
i get a blank table..

At first i thought that it might be the accelerometer fault so i tried to connect another I2C device (BME280 temperature sensor) but that one wasnt detected as well.. i tried the same setup on 2 other pis as well (pi 3, pi zero, pi zero w) all with the same result.. i2c seems to be enabled but no device is recognized..

Is there anything that im missing?
Thanks!

User avatar
joan
Posts: 12818
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GY-521 I2C not detected on Pi

Fri May 12, 2017 9:57 am

Could you add a photo of your connections? Everything you say seems correct.

Tropics
Posts: 6
Joined: Fri May 12, 2017 9:15 am

Re: GY-521 I2C not detected on Pi

Fri May 12, 2017 3:03 pm

joan wrote:Could you add a photo of your connections? Everything you say seems correct.
Hey Joan,
Attached are photos of the connection:
http://imgur.com/a/KAlMu

The module im using is this:
https://www.aliexpress.com/item/MPU-605 ... 0.0.3Y9TDk

I read somewhere about strapping address line high or low but i have no idea what that means... might that be an issue?

Thanks!

Moe
Posts: 196
Joined: Sun Jan 25, 2015 2:44 pm

Re: GY-521 I2C not detected on Pi

Wed May 17, 2017 10:04 pm

You're trying to talk to a 5V device with 3.3V GPIO pins. I2C normally wants to be pulled up to the supply voltage. You might want to try a level converter (search I2C logic level converter on Ebay - they are very cheap).
Submarine communication systems engineer and amateur robot enthusiast.

User avatar
DougieLawson
Posts: 30444
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: GY-521 I2C not detected on Pi

Thu May 18, 2017 4:29 am

Moe wrote:You're trying to talk to a 5V device with 3.3V GPIO pins. I2C normally wants to be pulled up to the supply voltage. You might want to try a level converter (search I2C logic level converter on Ebay - they are very cheap).
That's not a problem the two I²C pins on the RPi have 1.8K resistors to make them OK at 5V.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4601
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: GY-521 I2C not detected on Pi

Thu May 18, 2017 10:04 am

DougieLawson wrote:That's not a problem the two I²C pins on the RPi have 1.8K resistors to make them OK at 5V.
??! :shock:
The GPIOs 2&3 have 1k8 pullups to 3.3V on the Pi. That offers no protection to the SoC for you applying 5V to it.
The only GPIOs that are 5V tolerant are the I2C lines use for reading the EDID off your monitor. 5V to any of the others is likely to result in damage.

Referencing http://playground.arduino.cc/Main/MPU-6050 and linked schematic at http://playground.arduino.cc/uploads/Ma ... V1-SCH.jpg it appears the GY-521 has a built in 3V3 regulator, so is actually running at 3V3. If true then there should be no need for level translators. Quickest way to check would be a multimeter on SDA or SCL of the board whilst NOT connected to the Pi to see what level the I2C pullups are connected to.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

User avatar
DougieLawson
Posts: 30444
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website

Re: GY-521 I2C not detected on Pi

Sun May 21, 2017 2:16 pm

6by9 wrote:
DougieLawson wrote:That's not a problem the two I²C pins on the RPi have 1.8K resistors to make them OK at 5V.
??! :shock:
The GPIOs 2&3 have 1k8 pullups to 3.3V on the Pi. That offers no protection to the SoC for you applying 5V to it.
The only GPIOs that are 5V tolerant are the I2C lines use for reading the EDID off your monitor. 5V to any of the others is likely to result in damage.
So why do my MCP23017s running with Vcc @ 5V work OK? I thought the pull-ups were there for protection since I²C is a 5V bus.
Microprocessor, Raspberry Pi & Arduino Hacker
Mainframe database troubleshooter
MQTT Evangelist
Twitter: @DougieLawson

Since 2012: 1B*5, 2B*2, B+, A+, Zero*2, 3B*3

Please post ALL technical questions on the forum. Do not send private messages.

User avatar
joan
Posts: 12818
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: GY-521 I2C not detected on Pi

Sun May 21, 2017 2:25 pm

I2C does not specify a voltage. High/low are defined as 70%/30% of the pulls high.

I2C on the Pi uses 3V3.

I expect the currents involved are miniscule and the excess voltage milliamps are shunted away by the GPIO protection diodes. I've often fed 5V into my Pi, both by mistake and on purpose. When I do it on purpose I tend to use a 100k series resistor.

bensimmo
Posts: 1917
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: GY-521 I2C not detected on Pi

Sun May 21, 2017 5:03 pm

These worked being connected directly to the Pi, nothing else is needed (I've used them).
You only need VCC/GND and the two I2C connected to use them normally.

VCC can go to 3V3 that how I use them.

If I could remember what else I did I would help but notes are at work and I have a feeling I wrote over my address card with all the files :oops:

Are you using sudo before I2C detect?

Edit I remember using this site a lot http://blog.bitify.co.uk/2013/11/interf ... -6050.html
I remember a few things being a bit different to get it to work, I don't remember if I had to alter blacklists etc I know there was certainly code changes and using smbus2 (or 3 I forget) because I had to alter a lot for python3 in code.

This was setup on a pi2, transferred to an A+ to sit logging in a rocket

bensimmo
Posts: 1917
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: GY-521 I2C not detected on Pi

Tue May 23, 2017 8:20 am

Just wondering if you fixed this ?

For me
VCC to 3V3
GND to GND
SCL to SCL
SDA to SDA

Connect and boot
LED on GY-521 turn on and is red

Turn I2C on in RaspberryPi Configuration/Raspi-config.
Reboot

sudo apt-get install i2c-tools
i2cdetect -y 1

Shows device at 68

Tropics
Posts: 6
Joined: Fri May 12, 2017 9:15 am

Re: GY-521 I2C not detected on Pi

Tue May 23, 2017 8:28 am

bensimmo wrote:Just wondering if you fixed this ?

For me
VCC to 3V3
GND to GND
SCL to SCL
SDA to SDA

Connect and boot
LED on GY-521 turn on and is red

Turn I2C on in RaspberryPi Configuration/Raspi-config.
Reboot

sudo apt-get install i2c-tools
i2cdetect -y 1

Shows device at 68
Hey bensimmo,
First my led was never red, but always green and no matter what i tried i couldnt get it recognized.
I ordered a new board which should arrive today/tomorrow and im hoping it would work this time around...
Will post an update as soon as the new board arrives.

bensimmo
Posts: 1917
Joined: Sun Dec 28, 2014 3:02 pm
Location: East Yorkshire

Re: GY-521 I2C not detected on Pi

Tue May 23, 2017 11:03 am

For the record i've just had all the link I gave working well.
Even the webserver and the OGL little bit works on the Pi now (it's been many year and Chrome does it's job).


To convert to Python3 if you use it (just for the first part to read the values nicely)
() Around the prints
And install python3-smbus not python-smbus
Not checked the maths yet but reasonable numbers are there, if just a few more d.p.'s

(Using a Pi2 here for testing).
Last edited by bensimmo on Thu May 25, 2017 7:57 pm, edited 1 time in total.

Tropics
Posts: 6
Joined: Fri May 12, 2017 9:15 am

Re: GY-521 I2C not detected on Pi

Thu May 25, 2017 6:20 pm

Just wanted to update that i got the new board and it works out of the box :)
Connected it as bensimmo suggested in one of the previous posts, ran

Code: Select all

i2cdetect -y 1
and it comes up at 68 as it should :)

BMardle
Posts: 92
Joined: Wed Feb 13, 2013 4:00 pm
Location: Isle of Wight

Re: GY-521 I2C not detected on Pi

Wed Oct 04, 2017 6:45 pm

DougieLawson wrote:
Sun May 21, 2017 2:16 pm
So why do my MCP23017s running with Vcc @ 5V work OK?
That's a good question, since the MCP23017 data sheet says SCL and SDA in, high, has to be at least 0.8*Vdd!
I use a couple of them at 5V in a memory-programmer connected to my Pi 1B.

(I'm planning to get my Pi Zero talking to a PIC soon. I know some PICs (e.g. PIC16F872, if asked nicely) will accept 1.4V as a high when they're fed from 5V. Not sure about my PIC16F677.)
Bruce Mardle. "You know I yearn for a simpler time of barn dances and buggy rides before life was cheapened by heartless machines."

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4601
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: GY-521 I2C not detected on Pi

Thu Oct 05, 2017 9:26 am

BMardle wrote:
Wed Oct 04, 2017 6:45 pm
DougieLawson wrote:
Sun May 21, 2017 2:16 pm
So why do my MCP23017s running with Vcc @ 5V work OK?
That's a good question, since the MCP23017 data sheet says SCL and SDA in, high, has to be at least 0.8*Vdd!
I use a couple of them at 5V in a memory-programmer connected to my Pi 1B.

(I'm planning to get my Pi Zero talking to a PIC soon. I know some PICs (e.g. PIC16F872, if asked nicely) will accept 1.4V as a high when they're fed from 5V. Not sure about my PIC16F677.)
It's a combination of luck and tolerances.

The spec sheet states the worst case that can be 100% guaranteed to read as a high/1 or low/0.
It's a binary system though - the input has to be treated as either a 0 or a 1, there is no intermediate value. So whilst SDA and SCL must be below 0.2*Vdd (1V if Vdd is 5V) to guarantee a low, and above 0.8*Vdd (4V if vdd is 5V) to guarantee a high, a voltage between 0.2 and 0.8*Vdd will be interpreted as something. The exact interpretation will depend on tolerances of the input transistors inside your particular chip and how they are used.
Try it on a Schmitt trigger, and you're likely to miss transitions. On most other chips you'll probably get away with it, but may need to slow the data rate down due to capacitors taking longer to charge/discharge to required levels.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

BMardle
Posts: 92
Joined: Wed Feb 13, 2013 4:00 pm
Location: Isle of Wight

Re: GY-521 I2C not detected on Pi

Sat Oct 07, 2017 3:04 pm

6by9 wrote:
Thu Oct 05, 2017 9:26 am
It's a combination of luck and tolerances.
The Slice of PI/O has a jumper that selects 3.3V or 5V for its MCP23017's Vdd, and the I2C lines are connected straight to the Pi's.
Oh, well. There must be a lot of luck about :D
My PIC is now running off 3.3V (despite being connected to a 5V LCD, which seems happy with the PIC's low highs).
Every time I send a byte or 2 from my Pi Zero, the PIC gets the first byte twice! I know, off-topic here...
Bruce Mardle. "You know I yearn for a simpler time of barn dances and buggy rides before life was cheapened by heartless machines."

Return to “Interfacing (DSI, CSI, I2C, etc.)”

Who is online

Users browsing this forum: No registered users and 13 guests