Home » ESP32 and a L3GD20 sensor example

ESP32 and a L3GD20 sensor example

by shedboy71

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.

lsm303 module

lsm303 module

 

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

Parts Required

Here are the parts I used

 

Name Link
ESP32
LTR390
Connecting cables

Connection

LOLIN32  Connection GY-50 L3GD20 connection
3v3 Vcc
Gnd Gnd
SDA – pin 21 SDA
SCL – pin 22 SCL

 

And here is a layout

lolin32 and L3GD20

lolin32 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

#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);
}

 

You may also like

Leave a Comment

Adblock Detected

Please support us by disabling your AdBlocker extension from your browsers for our website.