First time posting.
I have been using arduino for a few years but now it seems that I am stuck for good.
For this project I use a Nano and the LIS3DH (SPI wiring).
I get the acceleromteter values (x,y,z) by serial print. Baudrate used 2.000.000.
I also transmit the data to another nano using nrf 24, where I also get the values printed to another pc by serial print. That works too.
LIS3DH is capable of 5kHz datarate if low power is enabled.
My problem is that I do get only 250sps besides having set the datarate of LIS3DH to 5kHz.
I want to measure 1kHz frequency which requires at least 2kHz.
I guess that serial print is the probably the problem since it is not fast enough.
What I have tried:
Writing to LIS3DH registers. Not sure if successfully.
Switched to STM32, ESP32, ESP8266 without any success. All I get is 250sps instead of 5000sps.
Read the LIS3DH datasheet again and again.
Erased any delays and useless code.
Searched and tried everything found on the internet.
I would be happy by only gettinng 2000sps.
Also I have tried storing the measurements to an array and send them afterwards but "memory is not enough" as IDE states while compiling. (Fails to compile).
The code used below is from the library examples with some changes:
I would really appreciate any help or suggestions if someone has experienced the same.
The library apparently allows you to set impossible configurations, and very likely, is not correctly coded.
To understand what is actually happening, you either need to understand what the library code is doing, or read out the control registers.
The first step in maximizing the overall data transfer rate is to verify that you can simply read out sensible data at the maximum rate. Drop the radio and serial printing, and focus on that effort.
Ok I will focus on that.
A few days ago I tried reading and writing to registers (which I am not familiar with....) and then I quited.
I studied a few other codes and tried to relate them to their library and datasheet in order to figure out how to read and understand what I have to do.
Anyway, thank you so much!
I hope I will figure it out since it's been almost a month trying whatever i can.
That library is a bit of a mess. It clearly does allow you to independently set conflicting device configurations.
The only straightforward operation to retrieve the acceleration data is as floats, which wastes time and doubles the number of data bytes you need to transmit.
The individual data for each axis are 16 bit integers, and nothing is gained by converting them to four byte floats.
I'll repeat: the very first thing you need to do is to verify that it is even possible to read data from the device at 5 kHz, as three 16 bit integers, without sending those data anywhere.
I'm absolutely sure that it is, but possibly not with that device library.