The Adafruit ICM20948 is a sophisticated 9-axis motion tracking module that integrates a 3-axis accelerometer, a 3-axis gyroscope, and a 3-axis magnetometer. This compact sensor is ideal for applications in robotics, virtual reality systems, drones, and motion tracking devices. It provides precise measurements for orientation, acceleration, and magnetic fields, making it a versatile component for a wide range of projects.
Pin Number | Pin Name | Description |
---|---|---|
1 | VDD | Power supply (1.71V to 3.6V) |
2 | GND | Ground connection |
3 | SDA/SDI | I2C Data Line / SPI Serial Data Input |
4 | SCL/SCLK | I2C Clock Line / SPI Serial Clock Input |
5 | NCS | SPI Chip Select (Active Low) |
6 | AUXDA | Auxiliary I2C Data (for external sensors) |
7 | AUXCL | Auxiliary I2C Clock (for external sensors) |
8 | FSYNC | Frame Synchronization Digital Input |
9 | INT | Interrupt Digital Output (Active Low) |
To use the Adafruit ICM20948 in a circuit:
#include <Wire.h>
#include <Adafruit_ICM20948.h>
// Create the ICM20948 object
Adafruit_ICM20948 icm;
void setup() {
Serial.begin(115200);
while (!Serial)
delay(10); // Wait for serial console to open
// Try to initialize the ICM20948
if (!icm.begin_I2C()) {
Serial.println("Failed to find ICM20948 chip");
while (1) {
delay(10);
}
}
Serial.println("ICM20948 Found!");
}
void loop() {
// Read and print out the sensor data
if (icm.getEvent(&accel, &gyro, &temp, &mag)) {
Serial.print("Accel X: "); Serial.print(accel.acceleration.x);
Serial.print(", Y: "); Serial.print(accel.acceleration.y);
Serial.print(", Z: "); Serial.print(accel.acceleration.z);
Serial.println(" m/s^2");
Serial.print("Gyro X: "); Serial.print(gyro.gyro.x);
Serial.print(", Y: "); Serial.print(gyro.gyro.y);
Serial.print(", Z: "); Serial.print(gyro.gyro.z);
Serial.println(" rad/s");
Serial.print("Mag X: "); Serial.print(mag.magnetic.x);
Serial.print(", Y: "); Serial.print(mag.magnetic.y);
Serial.print(", Z: "); Serial.print(mag.magnetic.z);
Serial.println(" uT");
Serial.print("Temp: "); Serial.print(temp.temperature);
Serial.println(" C");
}
delay(100);
}
Q: Can I use this sensor with a 5V microcontroller? A: Yes, but ensure that the ICM20948 is powered with a voltage within its operating range (1.71V to 3.6V) and use logic level converters for I2C or SPI lines.
Q: How do I calibrate the magnetometer? A: Calibration typically involves rotating the sensor in various orientations and using the collected data to adjust the readings. Adafruit provides libraries and examples that can assist with this process.
Q: What is the purpose of the FSYNC pin? A: The FSYNC pin is used for frame synchronization. It can be used to synchronize the sampling of sensor data with an external signal.
Q: How do I use the interrupt feature? A: The INT pin can be configured to trigger an interrupt on your microcontroller when certain events occur, such as new data being available. This requires additional setup in your code to configure the interrupt behavior and handle the interrupt signal.