The SparkFun 9DoF (Degrees of Freedom) Sensor Stick is an all-in-one sensing module that combines a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer. This compact sensor stick is capable of measuring linear acceleration, angular rotation velocity, and magnetic fields in all three dimensions. It is an ideal choice for applications in robotics, motion tracking, orientation detection, and more.
Pin Number | Name | Description |
---|---|---|
1 | GND | Ground connection |
2 | VCC | Supply voltage (2.2V to 3.6V) |
3 | SDA | I2C data line / SPI data out (Master In Slave Out) |
4 | SCL | I2C clock line / SPI clock |
5 | CS | SPI chip select (active low) |
6 | SDO | SPI data in (Master Out Slave In) |
7 | INT | Interrupt pin (active low) |
To use the SparkFun 9DoF Sensor Stick in a circuit:
#include <Wire.h>
#include <SparkFun_9DoF.h>
SparkFun_9DoF myIMU; // Create an instance of the 9DoF class
void setup() {
Wire.begin(); // Initialize I2C
Serial.begin(115200); // Start serial communication at 115200 baud
if (myIMU.begin() == false) { // Check if the sensor is properly connected
Serial.println("Device not connected. Please check connections.");
while (1);
}
}
void loop() {
myIMU.readSensor(); // Read the sensor values
// Print accelerometer values
Serial.print("Accel X: ");
Serial.print(myIMU.getAccelX_mss(), 4);
Serial.print(" ");
// Print gyroscope values
Serial.print("Gyro X: ");
Serial.print(myIMU.getGyroX_rads(), 4);
Serial.print(" ");
// Print magnetometer values
Serial.print("Mag X: ");
Serial.print(myIMU.getMagX_uT(), 4);
Serial.println();
delay(500); // Delay for readability
}
Q: Can I use multiple Sensor Sticks on the same I2C bus? A: Yes, but you will need to ensure each sensor has a unique I2C address. This can be done by altering the address if the sensor supports it or using an I2C multiplexer.
Q: How do I calibrate the magnetometer? A: Calibration typically involves rotating the sensor in various orientations and using the provided software tools or algorithms to compute the calibration parameters.
Q: What is the purpose of the INT pin? A: The INT pin can be used to trigger an interrupt on the microcontroller when certain conditions are met, such as a threshold being exceeded on any of the sensor axes.