Myth about ADXL345 breakout
This is my experience about buying AD's ADXL345 accelerometer breakout board.
There are so many breakout boards of ADXL345 sold in the market (or shopping store). Some are very cheap and some are very expensive. Price ranges from NT$ 65 to NT$799. Which one should you buy? What's the difference between the cheap one and expensive one?
I choose to take adventure and buy the cheaper breakout, one for NT$ 65 and one for NT$ 85. And the result, the NT$ 65 one can't work! But the NT$ 85 one work perfectly.
As the picture shows, this ADXL345 breakout board work! The acceleration reading values can be read out. At first I use ST's Nucleo-F401RE development board to connect this NT$ 85 ADXL345 breakout board via SPI interface. And in the MBED online compile web site, I import the ADXL345_HelloWorld sample program to read out acceleration readings.
The first time I run that program, nothing can be readout. Strange! Check the schematic (show below), I found SDO (pin 12) was connect to ground.
85元便宜ADXL345板子電路圖 |
So this is the problem come from. Don't hesitate, use your torch to remove resistor R4. And try again. This time the readings was correct. But in the internet, I found some blog say that NT$ 85 breakout can't work with SPI. He say this kind of cheap breakout just work with I2C. I was confused! Because the same breakout is working fine via SPI in front of me.
Recently I have opportunity to experiment this cheap ADXL345 breakout with Arduino Uno board. Because Arduino Uno board is 5 voltage system, and ARM Cortex is 3.3 voltage system. It worth to give it a try. But first, I check Sparkfun's web site about their ADXL345 breakout board. They have demonstrate how to connect Arduino Uno board with their breakout via both SPI and I2C.
Sparkfun's ADXL345 breakout |
So, what's the difference between Sparkfun's breakout and the cheap one?
The NT$ 85 cheap breakout |
Just using our eye, we see that the number of components in the cheap breakout are much more that the Sparkfun's breakout.
SparkFun ADXL345板子的電路圖 |
Yes, there are just 3 capacitors in addition to the ADXL345 chip at the Sparkfun's breakout. Nothing special. No reason it can work with SPI, but the cheap one can't.
Let's make experiment to see result.
I2C界面接法 wiring via I2C |
Wiring via I2C work fine. The wiring char and sample code is here: https://github.com/poushen/adxl345_i2c
SPI界面接法 wiring via SPI |
1. Connect Arduino Uno board's SPI pins directly with the cheap breakout's SPI pins don't work. Check Sparkfun's web site, I find they use voltage level translator.
2. Using TI's TXB0104 to do the work of voltage level translator, the readings is not correct. Check the TXB0104's document, see it's sensitive to pull-up resistor. And the cheap breakout do have 10K pull-up resistor at SDA, SCL, CS pins.
3. Using bidirectional logic level converter (BD-LLC), it work perfectly! The wiring char and sample code is here: https://github.com/poushen/adxl345_spi
BD-LLC document is here: https://learn.sparkfun.com/tutorials/bi-directional-logic-level-converter-hookup-guide
In conclusion, the cheap ADXL345 breakout can connect via SPI.
The cheap breakout was designed for I2C wiring, so it give us pull-up and pull-down resistor out of box. But it work with SPI too. Just remove R4 pull-down resistor and using BD-LLC, we can make it work with SPI. Oops, you want to use TI's TXB0104. Ok, I think it would be also work. But you must remove more resistor. See https://learn.sparkfun.com/tutorials/txb0104-level-shifter-hookup-guide
Adafruit的板子 |
Now let's look at Adafruit's ADXL345 breakout board. In addition to voltage regulator and pull-up pull-down resistor, it also have voltage level shifter build in. With some other circuit design, it let you easier to connect with Arduino Uno via SPI or I2C. Adafruit indeed is more intimate. So, which breakout board will you choose? Cheap one or expensive one?
Whatever you choose (or buy), don't forget that Spartfun and Adafruit had ADXL345 sample code and library for you (it's free too). Of course, you can write the code by yourself. Just like those I put in GitHub. Also, don't forget Analog Devices ADXL345 official web site. There are so many documents. http://www.analog.com/en/products/mems/accelerometers/adxl345.html
留言