Changing the Data Sampling Rate from the IMU

Everyone good time of day!
I do not know if this question has already been asked (the forum search did not give anything), so do not swear, please, if it really is (especially since sending me to a post with a topic with a solution will be much easier) :smiley:
So. When I ordered the official version of the Nano 33 BLE, I was “bribed” by the fact that I could read the data of accelerometers and gyroscopes with a rather high frequency (up to 952 Hz, if I am not mistaken). However, what was my disappointment when I found out that the library “Arduino LSM9DS3 library” is hopelessly setting boundaries at 104/20 Hz (accelerometers/magnetometer). It is not possible to change this “out of the box” parameter - there are no such methods in the library. I also note that despite fixing at 104 Hz, the real frequency is 119 Hz (for some reason). In addition, the acceleration boundaries are set at + 4g/-4g, and this cannot be changed either.
The first thing (since I am from Russia) I turned to the Russian-speaking community (, and they answered me that the library was most likely not completed. I quote the expert’s answer: “I looked into this library - I immediately came across that for example, the frequency of polling a gyroscope is set by a register entry at 0x17, and according to the datasheet at this address there is nothing in the chip (Reserved).” The library may not match the current chip revision… this can explain the case with default speed - in the library by default 104 Hz, and in the datasheet there is no such speed at all, the nearest value is 119 Hz - exactly as you intended in the iron. In short, it’s not so simple, you have to take a chip like you, sit down and seriously understand. "
I note that this is a sad story, like for me. In general, I ask for the help of the community in solving this “problem.” I would like to understand how I can “squeeze everything” from the nano 33 BLE hardware, especially since the manufacturer himself announced such capabilities.
Thank you in advance for any help!
P.S. I apologize for possibly incorrect translation from Russian made with the help of a translator :slight_smile:

The Arduino libraries are not made to squeeze everything out from the hardware. Engineering is a working on compromises because the world is not ideal and you can not always get what you want. The library is open source and easy to understand even for beginners. It shows you what you need to do to configure a device and use it. The library can be modified with very little C/C++ knowledge. I think that is more useful to most Arduino users.

Additionally, there are multiple libraries for the LSM9DS3 available e.g. from Adafruit. See if you like them more.

Try modifying the library to your needs and if you have any questions let me know. I will try to help.

Thank you very much for your response!

The fact is that, as I wrote above, I tried to change the library, but I saw absolutely no effect from the changes and turned to the Russian-language forum for help. People who, unlike me, understand well what needs to be done say that changing the library will be problematic, since it does not correspond to the reality or documentation of Arduino itself. Under these circumstances, I believe it will be extremely difficult for me to understand what the matter is.

You mean a library like this?

I understand this, but in this particular case, a fictitious restriction on the frequency of sensor interrogation is not a compromise. The manufacturer, apparently, just wanted to “create a headache” in an even place. By compromise, I understand, for example, the balance between the maximum measured acceleration and the accuracy of the measurements themselves.
Please tell me, will it make it difficult for you to check the statement of our local specialist regarding the presence of links to “empty addresses” in the library? After all, if such a problem does exist, then I think it is advisable to contact Arduino engineers directly (in some way).

Yes, and as you can see the library has about 3 times the amount of source lines and is a lot more complex. Maybe it provides you what you need.

I had a look at the datasheets. Your friend likely missed the fact that there are two register maps. One for the accelerometer and gyroscope and one for the magnetic sensor. There are two tables in chapter 6 of the datasheet (DocID025715 Rev 3).

The address 0x17 for the accelerometer and gyroscope contains the STATUS_REG register. The same address for the magnetometer is reserved.

Maybe that is the reason your changes did not change the behavior. Have a look at the LSM9DS1.cpp file.

The writeRegister function requires two addresses and a value. There are two defines at the beginning of the file for the two slave addresses. Use the first one to write to the gyroscope.

#define LSM9DS1_ADDRESS            0x6b
// magnetometer
#define LSM9DS1_ADDRESS_M          0x1e
int LSM9DS1Class::writeRegister(uint8_t slaveAddress, uint8_t address, uint8_t value)

Thank you for your help! Now I understand what to do :slight_smile:

Well, it’s time to close this topic definitively.
While I was looking for information about filtering raw data, I found a branch of the discussion on the GitHub, which discussed the standard library for IMU on Arduino nano 33 BLE (& Sense). It said that the axes of various sensors are not correlated - somewhere X is Y, and somewhere the left coordinate system is used instead of the right. It was also said there that the standard library is very limited and even works incorrectly in places.
In the end, one of the members of the conversation presented a modified library - “version 2.0 of the LSM9DS1 library” - in which the functionality was significantly expanded, and VERY convenient autocalibration was also added.
The solution to my original question is thus the following reference:
Note: I don’t remember exactly where the discussion of IMU axis problems on nano 33 BLE (link lost) is, however I can just show how exactly to reassign variables: [a_x, a_y, a_z, omega_x, omega_y, omega_z, m_x, m_y, m_z] = [a_y, a_x, a_z, omega_y, omega_x, omega_z, m_y, -m_x, m_z]

I found a link:

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.