What address should I use while using SPI communication

38 Views Asked by At

I have a ESP32 DEV board and connects to a 6 axis sensor ICM-42607-P. I am trying to get data from the sensor. Below is my code.

#include <Arduino.h>
#include <ArduinoJson.h>
#include <SPI.h>

const int pinCS = 5; 
const int pinMOSI = 23; 
const int pinMISO = 19;
const int pinSCK = 18;

void setup() {
    Serial.begin(115200);
    SPI.begin();
}

void loop() {
    SPI.beginTransaction(SPISettings(24, MSBFIRST, SPI_MODE0)); 
    digitalWrite(pinCS, LOW); 

    byte accel_x1 = SPI.transfer(0x8b); //address here
    byte accel_x0 = SPI.transfer(0x8c); //address here
    byte accel_x = accel_x1 << 8 | accel_x0;
    Serial.print(accel_x, HEX);

   digitalWrite(pinCS, HIGH);
   SPI.endTransaction();

   delay(500);
}

I included the SPISPI and register addressregister address document snippet. I am not sure if the set up and the converted address are correct since the data I got do not look like useable. The data is still 0 while I move the sensor.

0

There are 0 best solutions below