[nRF52] Accelerometer module for LIS3DH using FIFO mode

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
User avatar
FoldedToad
Posts: 8
Joined: Sat Feb 23, 2019 11:50 pm

[nRF52] Accelerometer module for LIS3DH using FIFO mode

Post by FoldedToad » Wed Mar 13, 2019 10:59 pm

I am working of driver for the STMicro LIS3DH 3-axis accelerometer. The micropython source code is at https://github.com/foldedtoad/more_py_p ... ter/lis3dh.
The README.md file should give general operational overview.

Out-of-the-box, this code configures for a 25Hz sample rate with a 25 sample deep FIFO buffer, e.g. 1Hz interrupts to retrieve 25 samples (where one sample is 16-bit data for each X-axis, Y-axis, Z-axis, or as I sometimes call it a "vector").
This code should work for several Nordic dev boards: PCA10040, PCA10056, etc.
I haven't to tried it on other, non-Nordic nRF52 boards yet.
It also should work for other accelerometer devices in the STMicro LIS3xx & LIS2xx series: LIS2DH for example.

Anyway, this is still some what a work-in-progress, but I thought others might be interested.
The code shows a simple code pattern for machine.I2C and how to hook interrupts via the machine.Pin.irq().

Useful comments would be, well, useful. :)

Post Reply