I want to connect an ADXL374 sensor to an Arduino via SPI. But there are connection problems. The sensor works via I2C and I also tried with another ADXL374 and that also does not work. There is a problem with the item "Failed to find ADXL375 chip" in the code below.
I also use a LSM6DSOX in SetUp which works fine via SPI.
Here is the code I am using:
Code: Select all
#include <Adafruit_Sensor.h>
#include <Adafruit_LSM6DSOX.h>
#include <Adafruit_ADXL375.h>
#include <SPI.h>
#define LSM_CS 0 //cs
#define LSM_SCK 32 //SCL
#define LSM_MISO 33 //DO
#define LSM_MOSI 26 //SDA
Adafruit_LSM6DSOX lsm1;
Adafruit_ADXL375 adxl = Adafruit_ADXL375(LSM_SCK, LSM_MISO, LSM_MOSI, LSM_CS);
void setup() {
delay(1000);
Serial.begin(115200);//115200
while (!Serial)
delay(10);
Serial.println("Start!");
if(!adxl.begin()) {
/* There was a problem detecting the ADXL375 ... check your connections */
Serial.println("Failed to find ADXL375 chip");
while(1);
}
if (!lsm1.begin_SPI(LSM_CS, LSM_SCK, LSM_MISO, LSM_MOSI)) {
Serial.println("Failed to find LSM6DSOX chip");
while (1) {
delay(10); }
}
}
void loop() {
sensors_event_t accel, gyro, temp;
lsm1.getEvent(&accel, &gyro, &temp);
sensors_event_t accel1;
adxl.getEvent(&accel1);
}
Thanks a lot