arduino-libraries / Arduino_HTS221

HTS221 Library for Arduino
GNU Lesser General Public License v2.1
15 stars 17 forks source link

What is the sensor frequency/data rate/sampling rate? #13

Open hkayann opened 2 years ago

hkayann commented 2 years ago

The spreadsheet of the sensor states the following:

Selectable ODR from 1 Hz to 12.5 Hz

However, I could not see any code regarding this.

Is there any default value? What is current sensor frequency?

LRagji commented 2 years ago

Looking at the code i see this operates in One Shot Mode as described in the (datasheet)[https://www.st.com/resource/en/datasheet/hts221.pdf] Page 23 ONE_SHOT Page Line i2cWrite(HTS221_CTRL1_REG, 0x84); in begin function sets ODR1 & ODR2 to ONE_SHOT mode

patti-favaron commented 1 year ago

The data sheet also indicates (page 21, register AV_CONF - 0x10) how to change the number of individual readings contributing to a single data gathered from the HTS221. Changing this number affects the response time somewhat (more individual readings = less speed). I made no precise measurements, but this could have some impact on your application.

Also: it is true the HTS221 can work in stream mode (the opposite of single-shot), but as far as I've seen using the chip, in stream mode you are responsible to ensure the reads made from the MCU are made at a rate equal or slower than the chip's. Overall, adopting the single-shot mode potentially allows to reach the maximum data rate compatible with the averaging depth selected in AV_CONF.

It is true the implementation of single-shot data reads in Arduino_HTS221 library is blocking, but a non-blocking version could be easily implemented in my feeling. Nevertheless, the simplicity of a blocking approach is, to me and my applications, a value.