This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

LPC1768 + adxl345 accelerometer

Dear friend,

I need to communicate with adxl345 accelerometer using LPC1768's 4 wire spi interface.
does anybody have a library for this purpose? (I need to enable activity and inactivity interrupts)

If not has anyone ever worked with this module? How am I supposed to write a value to a special register of the module?

yours sincerely

Parents
  • I worked with that device with i2c interface. You need to select register you wish to read/write and send parameter that is expected.

    e.g.

    #define ADXL345_ADDR 0x1D
    #define DEVICE_ID 0x00
    uint8_t deviceId = i2c_read(ADXL345_ADDR, DEVICE_ID);
    

    Command like device id, just need to read 1 byte from register with address 0x00.

    To read X value from sensor, you need to read two registers.

    #define OUT_X_L 0x32
    #define OUT_X_H 0x33
    
    uint16_t xVal = i2c_read(ADXL345_ADDR, OUT_X_L) | (i2c_read(ADXL345_ADDR, OUT_X_H)<<8))
    

Reply
  • I worked with that device with i2c interface. You need to select register you wish to read/write and send parameter that is expected.

    e.g.

    #define ADXL345_ADDR 0x1D
    #define DEVICE_ID 0x00
    uint8_t deviceId = i2c_read(ADXL345_ADDR, DEVICE_ID);
    

    Command like device id, just need to read 1 byte from register with address 0x00.

    To read X value from sensor, you need to read two registers.

    #define OUT_X_L 0x32
    #define OUT_X_H 0x33
    
    uint16_t xVal = i2c_read(ADXL345_ADDR, OUT_X_L) | (i2c_read(ADXL345_ADDR, OUT_X_H)<<8))
    

Children