Arduino TKJHAT
Arduino library for Pico HAT extension board
Loading...
Searching...
No Matches
ICM42670 Class Reference

A class for the TDK InvenSense ICM-42670 6-axis accelerometer + gyroscope. More...

#include <ICM42670.h>

Public Member Functions

bool begin ()
 Initialize the IMU.
bool enableAccelGyroLnMode (void)
 Enable low-noise mode for both accelerometer and gyroscope.
 ICM42670 ()
 Construct a new ICM42670 object Default constructor uses the default Wire I2C bus. You can also provide a custom TwoWire instance if needed.
bool readSensorData (float &ax, float &ay, float &az, float &gx, float &gy, float &gz, float &t)
 Enable low-noise mode for both accelerometer and gyroscope.
bool reset ()
 Perform a soft reset of the IMU.
bool startAccel (uint16_t odr_hz, uint16_t fsr_g)
 Start the accelerometer.
bool startGyro (uint16_t odr_hz, uint16_t fsr_dps)
 Start the gyroscope.
bool startWithDefaultValues (void)
 Start IMU with SDK default settings and enable LN mode.

Detailed Description

A class for the TDK InvenSense ICM-42670 6-axis accelerometer + gyroscope.

Datasheet can be found at: https://invensense.tdk.com/wp-content/uploads/2021/07/DS-000451-ICM-42670-P-v1.0.pdf Functions are based on TKJHAT C SDK with minimal modifications to fit Arduino style and the class structure.

The IMU is connected on I2C at ICM42670_I2C_ADDRESS (0x69).

Recommended defaults

Modes

  • This SDK supports Low-Noise (LN) mode (higher precision, higher power).
  • Other modes (LP/ULP/hybrid) are not implemented in this SDK.
Precondition
The I2C interface must be initialized (use init_i2c_default() or init_hat_sdk()). {@

Member Function Documentation

◆ begin()

bool ICM42670::begin ( )

Initialize the IMU.

Performs a soft reset and verifies device identity (WHO_AM_I).

Returns
true on success, false on error.

◆ enableAccelGyroLnMode()

bool ICM42670::enableAccelGyroLnMode ( void )

Enable low-noise mode for both accelerometer and gyroscope.

Returns
true on success, false on error.

◆ readSensorData()

bool ICM42670::readSensorData ( float & ax,
float & ay,
float & az,
float & gx,
float & gy,
float & gz,
float & t )

Enable low-noise mode for both accelerometer and gyroscope.

Returns
true on success, false on error.

◆ reset()

bool ICM42670::reset ( )

Perform a soft reset of the IMU.

This function sends the appropriate command to reset the device and waits for it to become ready again.

Returns
true on success, false on error.

◆ startAccel()

bool ICM42670::startAccel ( uint16_t odr_hz,
uint16_t fsr_g )

Start the accelerometer.

Configures the accelerometer with the requested ODR and FSR.

Parameters
odr_hzDesired output data rate in Hz (e.g., ICM42670_ACCEL_ODR_DEFAULT).
fsr_gFull-scale range in g (2, 4, 8, 16; e.g., ICM42670_ACCEL_FSR_DEFAULT).
Returns
true on success, false on error.

◆ startGyro()

bool ICM42670::startGyro ( uint16_t odr_hz,
uint16_t fsr_dps )

Start the gyroscope.

Configures the gyroscope with the requested ODR and FSR.

Parameters
odr_hzDesired output data rate in Hz (e.g., ICM42670_GYRO_ODR_DEFAULT).
fsr_dpsFull-scale range in degrees per second (250, 500, 1000, 2000; e.g., ICM42670_GYRO_FSR_DEFAULT).
Returns
true on success, false on error.

◆ startWithDefaultValues()

bool ICM42670::startWithDefaultValues ( void )

Start IMU with SDK default settings and enable LN mode.

Calls:

Precondition
Call ICM42670::begin() successfully before this function.
Returns
true on success, false on error.

The documentation for this class was generated from the following file: