Hi everyone,
I use LIS2DW12 with I2C interface. I can scan the address was 0x18. But the output always consistency when I move the sensor, see the code as below.
#include <LIS2DW12.h>
#include "Wire.h"
#include "SPI.h"
//Create one instances of the driver class
LIS2DW12 Sensor( I2C_MODE, 0x18, SPISettings(0, MSBFIRST, SPI_MODE0) );
void setup() {
// put your setup code here, to run once:
// put your main code here, to run repeatedly:
Serial.begin(9600);
delay(1000); //relax...
Serial.println("Processor came out of reset.\n");
//Call .begin() to configure the IMUs
if( Sensor.begin() != 0 )
{
Serial.println("Problem starting the sensor at 0x18.");
}
else
{
Serial.println("Sensor at 0x18 started.");
}
}
void loop() {
Serial.print(" X1 = ");
Serial.println(Sensor.readFloatAccelX(), 2);
Serial.print(" Y1 = ");
Serial.println(Sensor.readFloatAccelY(), 2);
Serial.print(" Z1 = ");
Serial.println(Sensor.readFloatAccelZ(), 2);
delay(2000);
}
Manufacturer's page of the LIS2DW12: https://www.st.com/en/mems-and-sensors/lis2dw12.html with datasheet.
If the SA0 pin is not connected (or connected to 3.3V), then it is internally pulled up and the I2C address is 0x19.
If the SA0 pin is connected to GND, then the I2C address is 0x18.
It is possible that a I2C Scanner can detect a I2C device, and when data is transferred then things go wrong. However, it is not likely. Can you try again with the Sparkfun library ?
The Sparkfun library calls isConnected() from the accel.begin().
That function checks the I2C address for 0x19 and reads the WHO_AM_I register.
I don't understand what is going on. The library did work at some moment.
Does Sparkfun buy a sensor with a different value, or am I looking at the wrong datasheet. I don't know
Could you read register 0x0F and check if you have 0x33 or 0x44 ?