Arduino Due and a L3GD20 sensor example

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 sensing element is manufactured using a dedicated micro-machining process developed by STMicroelectronics to produce inertial sensors and actuators on silicon wafers.

Features

  • 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
  • Embedded FIFO
  • High shock survivability

Here is a schematic showing the module I had.

l3gd20
l3gd20

Connection

Arduino Due  Connection GY-50 L3GD20 connection
3v3 Vcc
Gnd Gnd
SDA – pin 20 SDA
SCL – pin 21 SCL

 

And here is a layout

arduino due and L3GD20
arduino due and L3GD20

 

Code

I managed to find the following library that seemed to work well – https://github.com/pololu/l3g-arduino

This is the test example

 

[codesyntax lang=”cpp”]

#include <Wire.h>
#include <L3G.h>

L3G gyro;

void setup() {
Serial.begin(9600);
Wire.begin();

if (!gyro.init())
{
Serial.println("Failed to autodetect gyro type!");
while (1);
}

gyro.enableDefault();
}

void loop() {
gyro.read();

Serial.print("G ");
Serial.print("X: ");
Serial.print((int)gyro.g.x);
Serial.print(" Y: ");
Serial.print((int)gyro.g.y);
Serial.print(" Z: ");
Serial.println((int)gyro.g.z);

delay(100);
}

[/codesyntax]

 

Output

Open the serial monitor

G X: 119 Y: -82 Z: -33
G X: 5362 Y: -6681 Z: -2621
G X: 28523 Y: -230 Z: 22629
G X: 19185 Y: -3062 Z: 11825
G X: 25101 Y: -1529 Z: 13998
G X: 10682 Y: 4295 Z: -875
G X: -11374 Y: 21671 Z: -15175
G X: -14491 Y: 17675 Z: -21982
G X: -4422 Y: 1674 Z: -16058
G X: 14170 Y: -13096 Z: -25366
G X: 6914 Y: -12142 Z: -22337
G X: 17697 Y: -13041 Z: -14010
G X: 1702 Y: -13527 Z: 32686
G X: -11608 Y: -13166 Z: 14383
G X: -26598 Y: 15724 Z: -6731
G X: -5818 Y: 21711 Z: 23291
G X: -7242 Y: -22368 Z: 5766
G X: 13469 Y: -13508 Z: 1793
G X: 20855 Y: 7268 Z: -9825
G X: -753 Y: 2673 Z: -355
G X: -753 Y: 2673 Z: -355

 

Links

You can pick up one these sensors for about $4

L3GD20 3-axis Gyroscope Sensor replace L3G4200D Angular velocity module

Share
This div height required for enabling the sticky sidebar
Ad Clicks : Ad Views : Ad Clicks : Ad Views :