Arduino Forum

Using Arduino => Sensors => Topic started by: NoahM12 on Jul 15, 2019, 09:16 pm

Title: L3GD20H Sample Code not printing to Serial Monitor
Post by: NoahM12 on Jul 15, 2019, 09:16 pm
I'm attempting to connect a L3GD20H 3-Axis Gyro to an Arduino Micro and run the sample code from the Adafruit_L3GD20_U library, called "sensorapi". Here is the code, unedited:

Code: [Select]
#include <Wire.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_L3GD20_U.h>

/* Assign a unique ID to this sensor at the same time */
Adafruit_L3GD20_Unified gyro = Adafruit_L3GD20_Unified(20);

void displaySensorDetails(void)
  sensor_t sensor;
  Serial.print  ("Sensor:       "); Serial.println(;
  Serial.print  ("Driver Ver:   "); Serial.println(sensor.version);
  Serial.print  ("Unique ID:    "); Serial.println(sensor.sensor_id);
  Serial.print  ("Max Value:    "); Serial.print(sensor.max_value); Serial.println(" rad/s");
  Serial.print  ("Min Value:    "); Serial.print(sensor.min_value); Serial.println(" rad/s");
  Serial.print  ("Resolution:   "); Serial.print(sensor.resolution); Serial.println(" rad/s"); 

void setup(void)
  Serial.println("Gyroscope Test"); Serial.println(" ");
  /* Enable auto-ranging */
  /* Initialise the sensor */
    /* There was a problem detecting the L3GD20 ... check your connections */
    Serial.println("Ooops, no L3GD20 detected ... Check your wiring!");
  /* Display some basic information on this sensor */

void loop(void)
  /* Get a new sensor event */
  sensors_event_t event;
  /* Display the results (speed is measured in rad/s) */
  Serial.print("X: "); Serial.print(event.gyro.x); Serial.print("  ");
  Serial.print("Y: "); Serial.print(event.gyro.y); Serial.print("  ");
  Serial.print("Z: "); Serial.print(event.gyro.z); Serial.print("  ");
  Serial.println("rad/s ");

The code compiles and uploads to the Micro with no errors. However, nothing appears in the Serial Monitor when I open it. What could I be missing here?

I know the first thing to do is check connections, so these are where my wires are going:

     Micro     L3Gd20H
          5 V        -->         V in
         GND       -->         GND
          A4         -->         SDA
          A5         -->         SCL
Title: Re: L3GD20H Sample Code not printing to Serial Monitor
Post by: jremington on Jul 15, 2019, 09:47 pm
If this line in setup() doesn't print anything, then you may have the Baud rate setting on the serial monitor set incorrectly. Make sure the serial monitor setting matches the Serial.begin() setting.

Code: [Select]
  Serial.println("Gyroscope Test"); Serial.println(" ");