Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Moderators: adafruit_support_bill, adafruit

Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/
Locked
User avatar
hendrixjl
 
Posts: 4
Joined: Sat Nov 10, 2012 2:08 pm

Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Post by hendrixjl »

Can I use the L3GD20 with the raspberry pi. Your statement that you added level shifting for the Arduino makes me worried that I shouldn't hook up it to my Pi? On the other hand, if Vcc is 3.3v does that mean the logic levels will be in the 3.3v range?

adafruit
 
Posts: 12151
Joined: Thu Apr 06, 2006 4:21 pm

Re: Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Post by adafruit »

the level shifting protects the chip from 5V logic, but it will also work great with 3.3v power and logic!

however, at this time we do not have any tutorials for working with the gyro and the pi, and no ETA as to when we'll get to it

User avatar
lamunozh
 
Posts: 2
Joined: Sun Nov 04, 2012 2:18 pm

Re: Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Post by lamunozh »

Hi. I am working with the L3GD20 Triple-Axis Gyro Breakout Board on the BeagleBone and I get that it work (I think so).

The code is in: https://github.com/lamunozh/BeagleBone. (and others Adafruit's Breakout Board)

I think is similar that on Raspberry Pi®. Please check it and talk me if you see mistakes.

Excuse me, for my English.
Adiós (bye).

User avatar
hendrixjl
 
Posts: 4
Joined: Sat Nov 10, 2012 2:08 pm

Re: Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Post by hendrixjl »

I got it working. Here is how I hooked it up (see picture) and the code is how I get the gyro readings.

Code: Select all

import smbus
import time

def twoscomp( x ) :
	"This returns a 16-bit signed number (two's complement)"
	if (0x8000 & x): 
		x = - (0x010000 - x)
	return x

bus = smbus.SMBus(1)
address = 0x6b
print "Time, deltaT, temp, status, x, y, z"
bus.write_i2c_block_data(address, 0x20, [0x0F])
tlast = 0
while True:
	temp,status  = bus.read_i2c_block_data(address, 0xA6, 2)
	if (status & 0x08):
		xlow,xhi,ylow,yhi,zlow,zhi = bus.read_i2c_block_data(address, 0xA8, 6)
		x = (xhi*256 + xlow)
        	y = (yhi*256 + ylow)
		z = (zhi*256 + zlow)
		tim = time.time()
		t = ["%20.6f"%tim, "%20.6f"%(tim - tlast)]
		tlast = tim
       		a = ["%2d" % temp]
        	s = ["%03x" % status ] #[hex(status)]
		b = ["%5d"%i for i in [twoscomp(x), twoscomp(y), twoscomp(z)]]
		print t+a+s+b
Attachments
L3GD20 wiring
L3GD20 wiring
L3GD20_wiring.jpg (88.43 KiB) Viewed 1159 times

User avatar
shigeru
 
Posts: 11
Joined: Fri Nov 09, 2012 6:05 pm

Re: Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

Post by shigeru »

Hello!

I have been working on this breakout board recently and made a little module. I have posted it here, any inputs are appreciated. Please note that it is work in progress.
https://bitbucket.org/shigeru_kawaguchi ... 20_for_rpi

Thanks.

Locked
Forum rules
Talk about Adafruit Raspberry Pi® accessories! Please do not ask for Linux support, this is for Adafruit products only! For Raspberry Pi help please visit: http://www.raspberrypi.org/phpBB3/

Return to “Adafruit Raspberry Pi® accessories”