cancel
Showing results for 
Search instead for 
Did you mean: 

Application example for step counter using LIS2DS12

AB.4
Associate II

Hello ST community,

I would like to know if there are examples available for configuring LIS2DS12 for pedometer applications. I see that the Github examples (https://github.com/STMicroelectronics/STMems_Standard_C_drivers/tree/master/lis2ds12_STdC/example) does not have one for pedometer use.

Regards,

Anusha

4 REPLIES 4
niccolò
ST Employee

Hi Anusha @AB.4​ ,

I'm sorry, but there are no examples for this particular sensor regarding the pedometer, as ready to compile code.

Nevertheless, if you search section 5.5.1 of the datasheet, there are all the info that you need to program the pedometer of the LIS2DS12.

I would suggest to start from the lis2ds12_read_data_polling.c example on the page you linked (that should be the easiest example on the list) and add the register programming that is needed for the pedometer.

Do you think this help?

AB.4
Associate II

Hi Niccolo,

Thanks for your response. Yes, this helps a little. I will check it out.

Regards,

Anusha

Eleon BORLINI
ST Employee

Hi @AB.4​ , besides @niccolo.ruffini​ indications, you can find some more details in AN4748 application note, p. 29. You can use a brief pseudo-code for the embedded pedometer initialization that summarize the datasheet indications:

1. Write 20h in CTRL1 // Turn on the accelerometer with ODR = 25 Hz, FS = ±2 g
2. Write 01h in FUNC_CTRL // Enable pedometer algorithm
3. Write 04h in CTRL5 // Step detector interrupt driven to INT2 pin

The interrupt signal is generated when a step is recognized and the step count is available by reading the STEP_COUNTER_H / STEP_COUNTER_L registers.

For sake of completeness, you could implement the pedometer without using the embedded feature, but only the X, Y and Z accelerometer output data. It is of course more complicated, and you can refer to a platform- and device- independent C implementation here on Github.

Regards

AB.4
Associate II

Hi Eleon,

Thanks for your helpful suggestions. I will check them out.

Regards,

Anusha