Go Down

Topic: Saving Accelerometer data to SD card via SPI interface (Read 116 times) previous topic - next topic

henry321yu

May 13, 2019, 11:11 am Last Edit: May 14, 2019, 02:33 am by henry321yu
Hi hi,henry here
I'm working a project need to save many data to SD card,like accelerometer,encoder...
Now i'm only using accelermeter(adxl355) with ardiuno Nano.

And the results are so strange..

i connect
vcc(sd) -> 5V
vcc(accelermeter) -> 3.3V
mosi(sd、accelermeter) -> d11(mosi)
miso(sd、accelermeter) -> d12(miso)
sclk(sd、accelermeter) -> d13(sclk)
gnd(sd、accelermeter) -> gnd

I can read and write accelermeter and sd card individually with the same circuit. I can not execute both actions when they are wiring to the nano.
When I'm wiring both together, I can write data to sd card,but can't read accelerometer.It wrote 0,0,0 in sd crard.
But when I cut off vcc(sd) 5v,i can read accelerometer but can't write data to sd card...
code attached~


wiring both:



cut off vcc(sd) 5v:



data:



circuit:


adxl355


HELP :o  :o  :o  :o  :o  :smiley-eek-blue:  :smiley-eek-blue:

henry321yu

https://arduino.stackexchange.com/questions/43732/adxl345-becomes-0g-when-plugin-microsd-adapter-using-spi

..so its a glitch that alway have??
Nowonder most of people use i2c interface to do this.
But I have not seen many people discussing this issue.

hope someone can answer me :(

MorganS

Those accelerometers in the ADXL345 family respond to I2C commands when the SPI interface is de-selected. So if you are talking to other devices on the SPI bus, the accelerometer can misinterpret that as I2C.

There is no way to turn off the I2C in the chip. You have to use multiple SPI buses or a buffer chip that can disconnect the ADXL when it is not selected.

What adapter do you have for the SD card? The SD specification uses 3.3V but the Nano is 5V. Some cards will work at 5V for a short time before failing.

The ADXL is also 3.3V.
"The problem is in the code you didn't post."

Go Up