43#define I2C_FREQ 400000UL
59 Serial.println(F(
"ICM-20948 (I2C) — Magnetometer Example"));
63 Serial.println(F(
"ERROR: beginI2C() failed."));
67 Serial.println(F(
"ICM-20948 ready (I2C)."));
72 Serial.println(F(
"ERROR: WHO_AM_I mismatch"));
76 Serial.print(F(
"WHO_AM_I = 0x"));
77 Serial.println(who, HEX);
83 Serial.println(F(
"setSensors failed."));
88 Serial.println(F(
"ERROR: initMag() failed"));
92 Serial.println(F(
"Magnetometer ready"));
106 Serial.print(F(
"MAG [uT]: "));
107 Serial.print(mx, 2); Serial.print(F(
", "));
108 Serial.print(my, 2); Serial.print(F(
", "));
109 Serial.println(mz, 2);
111 Serial.println(F(
"Mag read failed"));
114 Serial.println(F(
"-----------------------------"));
bool readWhoAmI(uint8_t &whoAmI)
bool beginI2C(uint8_t address=0x69, TwoWire &i2cPort=Wire, uint32_t i2cSpeed=400000)
bool readMag(float &x, float &y, float &z)
bool setSensors(bool accel_on, bool gyro_on, bool temp_on)
#define SCL_PIN
I2C SCL pin used by the example board.
void setup()
Configure I2C, verify the IMU, and initialize the magnetometer.
#define SDA_PIN
I2C SDA pin used by the example board.
#define ICM_ADDR
ICM-20948 I2C address selected by the AD0 pin.
DevLab_ICM20948 imu
Global ICM-20948 driver instance.
void loop()
Read and print magnetometer data in microtesla.