I've been trying to connect my ADXL346Z accelerometer to my Arduino Leonardo for days, but it just doesn't want to work. Does anyone have experience with it?
I also tried to apply the example code for the ADXL345 (as both are similar), but it returns only 0,0,0. I found the code here: ADXL345 Hookup Guide - SparkFun Learn
I wired the ADXL346Z as described for the ADXL345.
If anyone knows anything or could help me I'd be very delighted.
A Leonardo is different.
The example is for the Arduino Uno (the most common Arduino board).
Do you want SPI interface or a I2C bus ?
Do you have a sensor board with the ADXL346Z ? Or just the chip ? Which sensor board ?
The Leonardo has the I2C bus on differrent pins, and doesn't have the SPI bus on the normal pins at all. The ICSP header (6 pins) contains the signals for the SPI bus.
The ADXL346 is for 2.7V.
If you have already connected it to an Arduino, it might be broken.
How will you connect a 2.7V sensor to a 5V Arduino board ?
I was thinking about I²C. I only got the ADXL346Z chip, without a sensor. I read the datasheet and it says 2.7V max for the accelerometer, so I made a voltage divider on my breadboard which supplies 2.5V (it wasn't connected to 3.3V).
I'll have another look into the I²C bus and Leonardo. Thanks.
That chip is designed for battery operated 2.7V devices.
Please use a 'normal' accelerometer that is compatible with the Arduino.
I have my doubts about the voltage divider. It might work, since the chip uses very little power.
Most I2C level shifters can do 2.7V.
When you use 2.5V and have pullup resistors of 10k on the 2.5V side, the current is 2 * 2.5 / 10k = 0.5mA
The voltage divider of 2.5V should also be able to supply that 0.5mA.
So instead of using a different (or as you say, "normal") sensor, I kept working with the ADXL346.
I have now eliminated all issues and the sensor works just fine. I am using the 5V pin of the Arduino to power my circuit and ADXL; a zener diode keeps the stability and decreases the voltage to 2.6V, which is perfect for the sensor. The signals SDO, INT1 and INT2 coming from the ADXL get decreased back to 5V by using transistors, while the signals going to the ADXL (CS, SDI and SCL) get decreased using simple voltage dividers.
The code is close to ADXL345 codes, but I preferred to make my own one.
Oh and I am no longer using Arduino Leonardo, I switched to the Uno.