The L3GD20 is a low-power three-axis angular rate sensor. It includes a sensing element and an IC interface capable of providing the measured angular rate to the external world through a digital interface (I2C/SPI).
The IC interface is manufactured using a CMOS process that allows a high level of integration to design a dedicated circuit which is trimmed to better match the sensing element characteristics. The L3GD20 has a full scale of ±250/±500/ ±2000 dps and is capable of measuring rates with a user-selectable bandwidth.
Three selectable full scales (250/500/2000 dps)
I2 C/SPI digital output interface
16 bit-rate value data output
8-bit temperature data output
Two digital output lines (interrupt and data ready)
Integrated low- and high-pass filters with user-selectable bandwidth
Wide supply voltage: 2.4 V to 3.6 V
Low voltage-compatible IOs (1.8 V)
Embedded power-down and sleep mode
Embedded temperature sensor
Here is a schematic showing the module I had, the module has an on board 3.3v voltage regulator
Connection
A layout showing how to connect this to your Raspberry Pi
Code
Save this as L3GD20.py
[codesyntax lang=”python”]
import smbus import time bus = smbus.SMBus(1) # L3GD20 address, 0x69 bus.write_byte_data(0x69, 0x20, 0x0F) bus.write_byte_data(0x69, 0x23, 0x30) time.sleep(0.5) # Read X-Axis data data0 = bus.read_byte_data(0x69, 0x28) data1 = bus.read_byte_data(0x69, 0x29) xGyro = data1 * 256 + data0 if xGyro > 32767 : xGyro -= 65536 # Read Y-Axis data data0 = bus.read_byte_data(0x69, 0x2A) data1 = bus.read_byte_data(0x69, 0x2B) yGyro = data1 * 256 + data0 if yGyro > 32767 : yGyro -= 65536 # Read Z-Axis data data0 = bus.read_byte_data(0x69, 0x2C) data1 = bus.read_byte_data(0x69, 0x2D) # Convert the data zGyro = data1 * 256 + data0 if zGyro > 32767 : zGyro -= 65536 # Output data to screen print "Rotation in X-Axis : %d" %xGyro print "Rotation in Y-Axis : %d" %yGyro print "Rotation in Z-Axis : %d" %zGyro
[/codesyntax]
Testing
In a terminal window enter the following – sudo python L3GD20.py
Links
About $4 for one of these sensors
L3GD20 3-axis Gyroscope Sensor replace L3G4200D Angular velocity module