-
Notifications
You must be signed in to change notification settings - Fork 7
Description
In this document
https://invensense.tdk.com/wp-content/uploads/2024/07/AN-000478_ICM-45605-ICM-45686-User-Guide.pdf
I found the following information:
As far as I understand the description, pass-through mode is only possible if the ICM45686 is connected via I2C.
I had trouble connecting the ICM45686 sensor to the ESP32S3.
I connected it via SPI and successfully read data from the sensor.
The code is below:
/*
*
* Copyright (c) [2020] by InvenSense, Inc.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
* SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
#include "ICM45686.h"
float accel_g[3];
float gyro_dps[3];
// Instantiate an ICM456XX with SPI interface and CS on pin 39
ICM456xx IMU(SPI,39);
void setup() {
int ret;
Serial.begin(115200);
while(!Serial) {}
// Initializing the ICM456XX
ret = IMU.begin();
if (ret != 0) {
Serial.print("ICM456xx initialization failed: ");
Serial.println(ret);
while(1);
}
// Accel ODR = 100 Hz and Full Scale Range = 16G
IMU.startAccel(100,16);
// Gyro ODR = 100 Hz and Full Scale Range = 2000 dps
IMU.startGyro(100,2000);
// Wait IMU to start
delay(100);
}
void loop() {
inv_imu_sensor_data_t imu_data;
// Read registers
IMU.getDataFromRegisters(imu_data);
// https://github.com/tdk-invn-oss/motion.mcu.icm45686.driver/blob/16e45db85ba817ad1ec401c602eccc09e4f4e82f/examples/basic_read_registers/basic_read_registers.c#L123
// accel_g[0] = (float)(d.accel_data[0] * 4 /* gee */) / 32768;
// accel_g[1] = (float)(d.accel_data[1] * 4 /* gee */) / 32768;
// accel_g[2] = (float)(d.accel_data[2] * 4 /* gee */) / 32768;
// gyro_dps[0] = (float)(d.gyro_data[0] * 2000 /* dps */) / 32768;
// gyro_dps[1] = (float)(d.gyro_data[1] * 2000 /* dps */) / 32768;
// gyro_dps[2] = (float)(d.gyro_data[2] * 2000 /* dps */) / 32768;
// Format data for Serial Plotter
Serial.print("AccelX:");
Serial.print(imu_data.accel_data[0]);
Serial.print(",");
Serial.print("AccelY:");
Serial.print(imu_data.accel_data[1]);
Serial.print(",");
Serial.print("AccelZ:");
Serial.print(imu_data.accel_data[2]);
Serial.print(",");
Serial.print("GyroX:");
Serial.print(imu_data.gyro_data[0]);
Serial.print(",");
Serial.print("GyroY:");
Serial.print(imu_data.gyro_data[1]);
Serial.print(",");
Serial.print("GyroZ:");
Serial.print(imu_data.gyro_data[2]);
Serial.print(",");
Serial.print("Temperature in degC:");
// Serial.print(imu_data.temp_data);
Serial.print((float)25 + ((float)imu_data.temp_data / 128));
Serial.println("");
// Run @ ODR 100Hz
delay(10);
}
I had to slightly modify the class code to connect to the SPI bus using non-standard pins.
The serial port contains the following data:
AccelX:-1132,AccelY:-345,AccelZ:1681,GyroX:7,GyroY:26,GyroZ:2,Temperature:376
AccelX:-1135,AccelY:-344,AccelZ:1677,GyroX:5,GyroY:25,GyroZ:2,Temperature:344
Please tell me @tdk-invn-oss, does this library have the ability to read data from a magnetometer or other sensor connected to the I2C MAS_DA and MAS_CLK?
Similar to the ICM20948 sensor
https://github.com/therealwokewok/ICM20948/blob/master/ICM20948.c