L3GD20 gyro unable to get sample arduino code working

I’m fairly new at this stuff so I’m hoping it’s just something simple that I am not aware of.

I have the L3GD20 3-Axis gyro and am trying to get the example code for the Arduino Uno to work.

Whenever I run the example arduino code I’m just getting the message “Failed to autodetect gyro type!” The code compiles properly. Is there something I could do to verify the 3-axis gyro is not broken.

The example code I’m using is from this link.

github.com/pololu/L3G

Below are pictures of my wiring setup.




Sample code unchanged

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

Hello,

Thanks for posting pictures of your setup. You will need to solder the header pins to the L3GD20 board to make good electrical connections; simply resting the board on the header pins won’t ensure reliable contact.

- Kevin

I have the same problem, just wondering if you have fixed it?

Hello.

I am sorry you are having problems reading your gyro. Are you getting the same “Failed to autodetect gyro type!” error? Could you tell me more about your setup? What are you using to read the gyro? Are you using the sample code? Could you post photos of your setup?

- Jeremy

Hi,

I have the same problem too.

Photos of my setup are attached in this post.




This is Seeeduino V3.0 (Atmega 328P), which is completely based on Arduino Duemilanove.

As per instructions on the github page, github.com/pololu/l3g-arduino:

I connected a 5V power supply to the gyro.
Seeeduino powered by USB
SCL → A5
SDA → A4

Using the standard Arduino IDE to upload the sample code sketch.

Is there any resolution to this problem?

Best regards,
Chun Kwang

Hello, Chun.

I am sorry you are having problems using your L3GD20 gyroscope. Could you tell me more about your setup? How are the wires connected to the header pins on the L3GD20? Do you have a common ground between your Arduino and the L3GD20 module? Could you try powering it directly from the Arduino’s 5V pin?

- Jeremy