2

I am doing a project which monitors vibrations using an ADXL355 sensor and an Arduino. I have used the MPU-9250 sensor before.

I am not able to find a library or tutorials for calibrating, filtering, and reading accurate data from the sensor. Can anyone who has worked previously with the sensor help me? I am mechanical engineer new to the field of electronics.

If library files are not available, how can I use the datasheet to write the entire code myself? Is there any tutorial available for this?

Sorry if the post seems confusing..

2
  • A quick google search gave me this library from Adafruit. It also has a calibration example. Applying filters has nothing to do with the sensor, but only with the already collected data. If you google something like "kalman filter library arduino github" you also get results for already existing libraries, that implement a kalman filter (often used with accelerometers/gyroscopes). – chrisl Mar 5 '20 at 9:39
  • The above library uses Adxl 345. – Arduiproj Mar 7 '20 at 7:48
2

I had a similar learning path as yours and I also tried to use ADXL345 and ADXL355. The latter was a pain for the issues described in many posts like this.

I couldn't find any good tutorial on this topic and had to learn all by myself.

I also use a different approach because I program ESP32-wrover devices with MicroPython. Nevertheless the logic is the same for translating DataSheets -> code.

  1. You have to decide which serial interface to use

    • I2C if you are constrained to limited wires
    • SPI for high frequency measures
  2. in both cases you write/read to/from registers of the device which are identified by an address, indicated in the datasheet (look for the registers map section). In each address you read/write a byte, that is 8 bits (0 or 1), that are packed into an hexadecimal format (e.g. you can set power mode to 'measure' writing 0x01 in register with address 0x2d)

  3. with both you normally have a library that implement 3 main methods:

    1. init() for initializing the interface with the parameters you find in the datasheet:
      • SPI: polarity, phase, max_clock_frequency, first bit MSB or LSB
      • I2C: max_clock_frequency
    2. read(register_address, nbytes) -> bytearray
    3. write(register_address, bytearray)
  4. before reading accelerations you must set range (e.g. ±2g), output data rate (e.g. 1000Hz), power mode (e.g. measure mode)

  5. then you read acceleration data from corresponding registers. Consider that you can read multiple registers in one transaction reading multiple bytes starting from an address (e.g. you can read x,y,z measure in one transaction by starting from the first byte of x data and then reading 9 bytes = 3 axes * 3 bytes)

  6. Then you have to convert from bytes to g units: in this accelerometer the value of one axis consist of 20 bits that are split in 3 bytes. You have to join the 3 bytes, shift away the trailing 4 bits, then apply two's components (that is for allowing negative numbers, look at this guide), then multiply by the scale factor indicated in the datasheet.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.