37#define I2C_FREQ 400000UL
53 Serial.println(F(
"ICM-20948 — I2C Basic"));
57 Serial.println(F(
"ERROR: beginI2C() failed"));
64 Serial.println(F(
"ERROR: WHO_AM_I mismatch"));
68 Serial.print(F(
"WHO_AM_I = 0x"));
69 Serial.println(who, HEX);
73 Serial.println(F(
"ERROR: setSensors failed"));
78 Serial.println(F(
"Mag init failed"));
80 Serial.println(F(
"Mag initialized"));
83 Serial.println(F(
"Ready.\n"));
99 Serial.print(F(
"ACC [g]: "));
100 Serial.print(ax, 3); Serial.print(
", ");
101 Serial.print(ay, 3); Serial.print(
", ");
102 Serial.println(az, 3);
104 Serial.println(F(
"ACC read failed"));
109 Serial.print(F(
"GYR [dps]: "));
110 Serial.print(gx, 2); Serial.print(
", ");
111 Serial.print(gy, 2); Serial.print(
", ");
112 Serial.println(gz, 2);
114 Serial.println(F(
"GYR read failed"));
119 Serial.print(F(
"MAG [uT]: "));
120 Serial.print(mx, 2); Serial.print(
", ");
121 Serial.print(my, 2); Serial.print(
", ");
122 Serial.println(mz, 2);
124 Serial.println(F(
"MAG read failed"));
129 Serial.print(F(
"TMP [C]: "));
130 Serial.println(tC, 2);
132 Serial.println(F(
"TMP read failed"));
135 Serial.println(F(
"-----------------------------"));
bool readGyro(float &x, float &y, float &z)
bool readAccel(float &x, float &y, float &z)
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 readTemperature(float &temperature)
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 Serial, I2C, sensor identity check, and enabled sensors.
#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 accelerometer, gyroscope, magnetometer, and temperature data.