I ordered the kX132 and kx134 breakout boards from sparkfun and have been successful in reading data from the kx132 but have not been able to read data from the kx134 breakoutboard.
Links to the kx132 and kx132 acceleromters respectively
https://www.sparkfun.com/products/17871
https://www.sparkfun.com/products/17589
I am using the Arduino IDE and commented/uncommented the proper lines to change to the example1_basic_readings for the kx134. Specifiacally lines 39-40, and 79-80. I am running this on a Teensy 4.1. This is in the I2C protocol.
I keep getting the following printed in the Serial monitor when I try to upload the code:
Could not communicate with the the KX13X. Freezing.
I know that my pinout is correct because I have been able to successfully get data from the KX132 with both the ADR port connected to 3.3v as well as ADR connected to ground after changing the trace on a kx132 board.
I am not able to view the kx134 with an i2c scanner, though I am able to view the kx132.
I am using the most updated library 2.0.4
From what I understand the KX132 and KX134 are identical in how you hook them up, the only alteration is the two different spots that you need to change in the code and obviously the g ranges that you can measure between them varies.
Any help on how to get this working would be much appreciated. I have tried everything I can think of and can’t get it working any help would be much appreciated. Thank you!
Below is the code that I am using unsuccessfully with the kx134
////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*
example1-BasicReadings
This example shows the basic settings and functions for retrieving accelerometer
data. Other possible Range settings, depending on your accelerometer KX132 or KX134, are
the following:
SFE_KX132_RANGE2G
SFE_KX132_RANGE4G
SFE_KX132_RANGE8G
SFE_KX132_RANGE16G
SFE_KX134_RANGE8G
SFE_KX134_RANGE16G
SFE_KX134_RANGE32G
SFE_KX134_RANGE64G
Written by Elias Santistevan @ SparkFun Electronics, October 2022
Products:
SparkFun Triple Axis Accelerometer Breakout - KX132:
https://www.sparkfun.com/products/17871
SparkFun Triple Axis Accelerometer Breakout - KX134:
https://www.sparkfun.com/products/17589
Repository:
https://github.com/sparkfun/SparkFun_KX … no_Library
SparkFun code, firmware, and software is released under the MIT
License (http://opensource.org/licenses/MIT).
*/
#include <Wire.h>
#include <SparkFun_KX13X.h> // Click here to get the library: http://librarymanager/All#SparkFun_KX13X
//SparkFun_KX132 kxAccel;
SparkFun_KX134 kxAccel; // For the KX134, uncomment this and comment line above
outputData myData; // Struct for the accelerometer’s data
void setup()
{
Wire.begin();
Serial.begin(115200);
Serial.println(“Welcome.”);
// Wait for the Serial monitor to be opened.
while (!Serial)
delay(50);
if (!kxAccel.begin())
{
Serial.println(“Could not communicate with the the KX13X. Freezing.”);
while (1)
;
}
Serial.println(“Ready.”);
if (kxAccel.softwareReset())
Serial.println(“Reset.”);
// Give some time for the accelerometer to reset.
// It needs two, but give it five for good measure.
delay(5);
// Many settings for KX13X can only be
// applied when the accelerometer is powered down.
// However there are many that can be changed “on-the-fly”
// check datasheet for more info, or the comments in the
// “…regs.h” file which specify which can be changed when.
kxAccel.enableAccel(false);
//kxAccel.setRange(SFE_KX132_RANGE16G); // 16g Range
kxAccel.setRange(SFE_KX134_RANGE16G); // 16g for the KX134
kxAccel.enableDataEngine(); // Enables the bit that indicates data is ready.
// kxAccel.setOutputDataRate(); // Default is 50Hz
kxAccel.enableAccel();
}
void loop()
{
// Check if data is ready.
if (kxAccel.dataReady())
{
kxAccel.getAccelData(&myData);
Serial.print("X: ");
Serial.print(myData.xData, 4);
Serial.print(" Y: ");
Serial.print(myData.yData, 4);
Serial.print(" Z: ");
Serial.print(myData.zData, 4);
Serial.println();
}
delay(20); // Delay should be 1/ODR (Output Data Rate), default is 1/50ODR
}