cancel
Showing results for 
Search instead for 
Did you mean: 

LIS2DW12TR acceleration values not returned

YBend.1
Associate III

I am using the Accel 10 click housing the LIS2DW12TR accelerometer and I want ot run it using a MicroPython program.The code is as follows:https://github.com/Yadnik1/Accel-10-i2c/blob/main/Accel10i2c.py .It does not detect the sensor and I am skeptical regarding the init function where I have to write to the registers to enable the accelerometer.

My init function is as follows:

def __init__(self,i2c,addr=device):

    self.addr = addr

    self.i2c = i2c

    b = bytearray(1)

    b[0] = 0

    self.i2c.writeto_mem(0x64,0x20,b)

    b[0] = 16

    self.i2c.writeto_mem(0x04,0x25,b)

The function does the following things:

I2C.writeto_mem

(addrmemaddrbuf*addrsize=8)

Write buf to the slave specified by addr starting from the memory address specified by memaddr. The argument addrsize specifies the address size in bits (on ESP8266 this argument is not recognised and the address size is always 8 bits).

 Can someone please tell me where I may be going wrong.

Datasheet of LIS2DW12TR:https://download.mikroe.com/documents/datasheets/lis2dw12_datasheet.pdf

1 REPLY 1
Winfred LU
ST Employee

Could you confirm if you were setting SAD[0] = 1 ?

Then please check if you could read WHO_AM_I register correctly.

Finally, writing 0 to offset 0x20 means you are powering down the device. Please configure a proper ODR instead.

There seems to be a typo in line 18, where the address shall be 0x64. But this does not effect the sensor's on/off.