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:

by HendrixJL on Thu Nov 29, 2012 9: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?
Posts: 4
Joined: Sat Nov 10, 2012 1:08 pm

by adafruit on Thu Nov 29, 2012 11:01 am

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

by lamunozh on Sun Dec 09, 2012 9: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: (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).
Posts: 2
Joined: Sun Nov 04, 2012 1:18 pm

by HendrixJL on Sun Dec 30, 2012 2: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
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
L3GD20 wiring
L3GD20_wiring.jpg (88.43 KiB) Viewed 497 times
Posts: 4
Joined: Sat Nov 10, 2012 1:08 pm

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


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. ... 20_for_rpi

Posts: 10
Joined: Fri Nov 09, 2012 5:05 pm