|
|
In readRegister() I think the following line is wrong:
values = SPI.transfer(0x00);
It should be something like:
values[i] = SPI.transfer(0x00);
Thanks ddowlingau for your reply. I have tried changing that line. But it still couldn't work, output readings is 0 0 0. Is it possible that I have damage/burn my accelerometer sensor? Or my power sequence is wrong? Above I have post my connection between 2 devices, and I use USB serial port as my power source.
Actually just noticed you are using Arduino UNO so this has 5V logic. Connecting this directly to 3.3V ADXL is likely to cause issues for the 5V output connecting to the 3.3V input as the ADXL inputs are not 5V tolerant. You should use some form of voltage level switching between the Arduino and ADXL
Arduino has both 3.3v and 5v output pin. I connected both Vs and Vio to 3.3v Arduino. I have research that so long as Vio is lower than Vs or equal to Vs, and technically it should be no problem. When I start using to run the code and it works but after sometimes the output data just went wrong. I'm not sure is it I have burn the sensor?
Arduino has 3V3 power which you have correctly connected to VDD and VDD-IO BUT the logic levels on pin 10, 11, 12 and 13 are 0 - 5V so any output will be driving a voltage into the ADXL345 which is outside the specification. Where you are dragging the CS high this will be pushing 5V into the ADXL345 which is a bad thing. At the very least you should have some current limiting resistors between the Arduino and ADXL345. A better solution is to use a logic level shifter. Something like the following
https://learn.sparkfun.com/tutorials/using-the-logic-level-converter/hookup-examples