Home Code Arduino and L3GD20 sensor

Arduino and L3GD20 sensor

by shedboy71

The L3GD20 is a low-power three-axis angular rate sensor. This is the module I bought for reference

L3GD20

Key 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, the module has an on board 3.3v voltage regulator

l3gd20.600

 

Connection

Arduino Connection GY-50 L3GD20 connection
5v Vcc
Gnd Gnd
SDA – Arduino Uno A4 SDA
SCL – Arduino Uno A5 SCL

 

Code

I used the following library – 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]

 

 

Links

About $4 for one of these sensors

L3GD20 3-axis Gyroscope Sensor replace L3G4200D Angular velocity module

Share

You may also like

Leave a Comment