parts
- Three-axis rate gyro on breakout board:gyro datasheet,breakout board "datasheet"
- Arduino Uno:pinout
goal: I want to periodically read a single axes' angular rate. As rvbarreto pointed out, Adafruit built an Arduinolibrary for this sensor, so I'm playing around with its example file.
I have a 5600 Ohm pull-up connected to the SDA and SCL pins each on the Arduino. The internal pull-ups of the Arduino are too weak according tothis thread.
code: (Adafruit library's sensorapi example)
#include <Wire.h>#include <Adafruit_Sensor.h>#include <Adafruit_FXAS21002C.h>/* Assign a unique ID to this sensor at the same time */Adafruit_FXAS21002C gyro = Adafruit_FXAS21002C(0x0021002C);//Adafruit_FXAS21002C gyro = Adafruit_FXAS21002C(0x21);void displaySensorDetails(void){ sensor_t sensor; gyro.getSensor(&sensor); Serial.println("------------------------------------"); Serial.print ("Sensor: "); Serial.println(sensor.name); Serial.print ("Driver Ver: "); Serial.println(sensor.version); Serial.print ("Unique ID: 0x"); Serial.println(sensor.sensor_id, HEX); 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"); Serial.println("------------------------------------"); Serial.println(""); delay(500);}void setup(void){ Serial.begin(9600); /* Wait for the Serial Monitor */ while (!Serial) { delay(1); } Serial.println("Gyroscope Test"); Serial.println(""); /* Initialise the sensor */ if(!gyro.begin()) { /* There was a problem detecting the FXAS21002C ... check your connections */ Serial.println("Ooops, no FXAS21002C detected ... Check your wiring!"); while(1); } /* Display some basic information on this sensor */ displaySensorDetails();} void loop(void){ /* Get a new sensor event */ sensors_event_t event; gyro.getEvent(&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 "); delay(500);}NOTE: I noticed that Adafruit's Github hadremoved a line of code (line 67) in their library's main .cpp file. I edited my library code to reflect that change.
problem: I keep getting the "Ooops, no FXAS21002C detected ... Check your wiring!" error message.
questions:
- Am I connecting my pull-up resistors correctly?
- Should I not power VDD and VDD_IO on the same rail? Can they even be powered by the Uno?
- I'm assuming that the gyro is on a breakout board of some sort? Linking the manual/schematic might be helpful.uint128_t– uint128_t2017-04-17 03:58:20 +00:00CommentedApr 17, 2017 at 3:58
- 3Your I2C resistors are at least 10 times to large, and your code seemingly has nothing to do with this sensor, or at least not with it's "gyro-ness". If you are new to this, you'd probably do best to pick a part for which others have already devised wiring and Arduino code, otherwise you'll need to make your own deep dive into I2C basics and data sheet fundamentals.Chris Stratton– Chris Stratton2017-04-17 04:49:49 +00:00CommentedApr 17, 2017 at 4:49
- The arduino Wire library activates the 10k internal pull-up resistors of the TWI and SCK pins.jms– jms2017-04-17 09:36:40 +00:00CommentedApr 17, 2017 at 9:36
- 1There is a library for this sensor made by Adafruit available at Arduino IDE. If you have an up-to-date version of Arduino IDE, go to
Sketch > Include Library > Manage Libraryand then type "FXAS21002C" and you will see it. Just install it and you will have the library and examples to test, explore and get this working.rvbarreto– rvbarreto2017-04-17 19:03:03 +00:00CommentedApr 17, 2017 at 19:03 - The 0x20is the 7-bit address. Or 0x21 if you opt to configure it for that address. The full slave address byte is either 0x40 or 0x41 depending on if it's write or read. You should look at table 9 on page 12.Majenko– Majenko2017-04-17 19:31:02 +00:00CommentedApr 17, 2017 at 19:31

