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/

Raspberry Pi and L3GD20 Triple-Axis Gyro Breakout Board

by HendrixJL on Thu Nov 29, 2012 10:56 am

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?
HendrixJL
 
Posts: 4
Joined: Sat Nov 10, 2012 2:08 pm

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

by adafruit on Thu Nov 29, 2012 12:01 pm

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
adafruit
 
Posts: 11779
Joined: Thu Apr 06, 2006 4:21 pm
Location: nyc

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

by lamunozh on Sun Dec 09, 2012 10:10 pm

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).
lamunozh
 
Posts: 2
Joined: Sun Nov 04, 2012 2:18 pm

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

by HendrixJL on Sun Dec 30, 2012 3:48 pm

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 | TOGGLE FULL SIZE
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.jpg
L3GD20 wiring
L3GD20_wiring.jpg (88.43 KiB) Viewed 641 times
HendrixJL
 
Posts: 4
Joined: Sat Nov 10, 2012 2:08 pm

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

by shigeru on Mon Feb 11, 2013 3:52 pm

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.
shigeru
 
Posts: 11
Joined: Fri Nov 09, 2012 6:05 pm