using lis3dh in STM32F4 discovery board

Hi, I am using RIOT-OS in STM32F4discovery. The hello world program runs very well. Unfortunately I can compile the lis3dh example (located in /RIOT/tests/driver_lis3dh) but the program didn’t run on the board correctly. Because I read 255 from the LIS3DH_REG_WHO_AM_I Register. Did you have any idea how to let the lis3dh example run correctly in STM32F4discovery properly.

Many thanks,


Similar to the hello world program, I copied the /RIOT/tests/driver_lis3dh in a new directory. I added at the beginning of the main program:

#include <stdio.h> #include “board.h” #include “xtimer.h” #include “periph/spi.h” #include “periph/gpio.h” #include “lis3dh.h” #include “vtimer.h”

#define LIS3DH_CS GPIO_PIN(PORT_E, 3) #define LIS3DH_SPI SPI_0 #define LIS3DH_INT1 GPIO_PIN(PORT_E, 0) #define LIS3DH_INT2 GPIO_PIN(PORT_E, 1)

I used the following Makefile:

APPLICATION = driver_lis3dh #include …/Makefile.tests_common RIOTBASE ?= $(CURDIR)/…/RIOT QUIET ?= 1 FEATURES_REQUIRED = periph_spi periph_gpio

USEMODULE += lis3dh USEMODULE += xtimer USEMODULE += vtimer

include $(RIOTBASE)/Makefile.include

Hi Alicja,

and welcome to RIOT! If I see it correctly, the a accelerometer that’s mounted on the stm32f4 discovery board is LIS3DSH whereas we only have support for the LIS3DH accelerometer currently. I assume they are not too different, but it might be the reason why the app does not work out of the box. Also: did you make sure that the sensor is really connected to SPI_0 in RIOT?

Best, Peter


the driver might actually work with both devices (though I am not 100% sure). But if I remember correctly, the LIS sensor is connected via SPI on the discovery board while the driver is using I2C only, Have you checked this?

Cheers, Hauke