Hello guys I am trying to make a datalogger with arduino UNO, MPU9250 (for its 4000Hz capability and 16bit precision) and SD card.
WIRING is:
SPI on UNO MPU9250
MOSI 11 SDI
MISO 12 SDO
CLK 13 SCL
SS 10 NCS
SD card has CS = 4
and SD card module is conected with MOSI,MISO and CLK lines in parallel with MPU9250.
I took the LowLatencyLogger from sdFat library examples and I try to include into it the MPU9250 library
invensense-imu/README.md at main · bolderflight/invensense-imu · GitHub and logg data from sensor to SD card but I have trouble with initialising both devices
If I disconnect the SD module the accelerometer will connect via SPI successfuly (meaning that IMU.begin() will return positive value) but sd card will say:
Can't access SD card. Do not reformat.
No card, wrong chip select pin, or SPI problem?
SD errorCode: 0X20,0X0
When I try to connect one or the other to the second arduino MEGA for external power that device will stop operating (Dont know why)
Now I just want to read from the WHO_AM_I register to check the connection with the MPU9250.
I tried:
- Setting the SPI_MODE to 0 after accesing the accelerometer which works with SPI_MODE3 (doesnt work)
- connecting all to MEGA (I thought maybe UNO isnt able the provide sufficient current)
- interchange the sequence of initialisation.
The main part of the code begins on line 590.
I commented the IMU.begin() function because it didnt work and I have written manualy the SPI communication below so I know that is going on.
In attachements there is the code and MPU9250 library files.
Thank you for any help.
EDIT: if I let the script run, but add a 5 second delay in between the MPU SPI initialisation and SD card initialisation and I unglug the SD card module from power and after the initialisation of MPU plug it back in again and let it initialise everything will initialise successfully ... what???
MPU9250.cpp (34.7 KB)
MPU9250.h (10.3 KB)
LowLatencyLogger.ino (20.5 KB)
LowLatencyLoggerADXL345_my_2.ino (72 Bytes)
UserFunctions.cpp (2.27 KB)
UserTypes.h (437 Bytes)