Using KX134 Accelerometer over I2C Arduino Nano

I am currently using an Arduino Nano and I am trying to get a Kx134 accelerometer to output x,y,z acceleration data. I am very new to using the I2C Wire library, and I would really appreciate if someone could help me out. I have attached my code below, but it only outputs 0 (not sure what that means), as well as the Technical manual and the starters guide to the sensor. The code below is setup to read the x accel data but it does not work. I believe the issue is with the initial values I send to the accelerometer before it begins reading but i am not sure. All values and registers I got from the "getting started with kx134" pdf.

#include <Wire.h>

#define KX134addr 0x1E


void setup() {

  Wire.begin();
  Serial.begin(115200);

  Wire.beginTransmission(KX134addr);
  Wire.write(0x1B);  //puts accelerometer in standby
  Wire.write(0x00);
  Wire.endTransmission();


  Wire.beginTransmission(KX134addr);
  Wire.write(0x21);  //50 hz output data
  Wire.write(0x06);
  Wire.endTransmission();

  Wire.beginTransmission(KX134addr);
  Wire.write(0x1B);  //activates accelerometer
  Wire.write(0xC0);
  Wire.endTransmission();


}

void loop() {

  Wire.beginTransmission(KX134addr);
  Wire.write(03); //reads MSB of x accel
  Wire.endTransmission();
 
  

  delay(100); // Wait for data to be available
  Wire.requestFrom(KX134addr,2);
  uint8_t buf = Wire.read();
  int acc = buf <<4;


  Serial.print("\n");
  Serial.print(buf);
  Serial.print(acc);
  Serial.print("\n");

  delay(1000);

}

Technical Manual: https://kionixfs.azureedge.net/en/document/KX134-1211-Technical-Reference-Manual-Rev-5.0.pdf

Getting started with kx134: https://kionixfs.azureedge.net/en/document/AN101-Getting-Started.pdf

Any help is appreciated
Thank you

Haven't you tried the SparkFun library?

I could not find that address in the linked documents. What did I miss?

Have you run i2c_scanner to verify the device address?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.