20#define I2C_FREQ 400000UL
28void printLinea() { Serial.println(F(
"------------------------------------------------------------")); }
30void printDobleLinea() { Serial.println(F(
"============================================================")); }
45 "PowerDown",
"SingleMeasure",
"Continuo1",
"Continuo2",
"Continuo3",
"Continuo4"
56 Serial.println(F(
"ERROR: initMag() failed"));
59 for(
int i = 2; i <
N_OPM; i++){
62 Serial.println(F(
"Magnetometer ready"));
69 for(
int r = 0; r < 500 ; r++){
71 Serial.printf(
"[%d]",r);
75 Serial.print(mx, 2); Serial.print(F(
"; "));
76 Serial.print(my, 2); Serial.print(F(
"; "));
77 Serial.println(mz, 2);
79 Serial.println(F(
"Mag read failed"));
82 Serial.println(F(
"-----------------------------"));
95 Serial.println(F(
"ICM-20948 (I2C) — Magnetometer Example"));
100 Serial.println(F(
"ERROR: beginI2C() failed."));
101 while (1) delay(200);
104 Serial.println(F(
"ICM-20948 ready (I2C)."));
109 Serial.println(F(
"ERROR: WHO_AM_I mismatch"));
110 while (1) delay(200);
113 Serial.print(F(
"WHO_AM_I = 0x"));
114 Serial.println(who, HEX);
120 Serial.println(F(
"setSensors failed."));
123 Serial.println(F(
" Sensor listo.\n"));
124 Serial.println(F(
" Sensor PLANO y QUIETO sobre la mesa."));
125 Serial.println(F(
" Iniciando en 5 segundos..."));
126 for (
int i = 5; i > 0; i--) {
127 Serial.printf(
" %d...\n", i);
@ MODE_SINGLE_MEASUREMENT
bool setMagOpMode(ICM20948_Op_Mode opMode)
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 printDobleLinea()
Print a double separator line to Serial.
void setup()
Initialize I2C, verify the IMU, enable sensors, and start the sweep.
#define SDA_PIN
I2C SDA pin used by the example board.
const uint8_t N_OPM
Number of printable magnetometer operation modes.
void printLinea()
Print a separator line to Serial.
#define ICM_ADDR
ICM-20948 I2C address selected by the AD0 pin.
const char * etiquetasOpModeCfg[]
Text labels matching the operating modes printed in the sweep.
DevLab_ICM20948 imu
Global ICM-20948 driver instance.
const ICM20948_Op_Mode opMode[]
Magnetometer operating modes tested by the sweep.
void applySettings()
Initialize the magnetometer and collect samples for each mode.
void loop()
Empty loop; this sketch runs the magnetometer sweep once in setup().