Wire connection problem for transfer data of adxl345 to Sd card for given code

#include <SD.h> //Load SD card library
#include<SPI.h> //Load SPI Library

#include "Wire.h" // imports the wire library for talking over I2C
int ADXL345 = 0x53; // The ADXL345 sensor I2C address
float X_out, Y_out, Z_out; // Outputs

int chipSelect = 4; //chipSelect pin for the SD card Reader
File AngleData; //Data object you will write your sesnor data to

void setup(){
Serial.begin(9600); //turn on serial monitor
//mySensor.begin(); //initialize pressure sensor mySensor
Wire.begin(); // Initiate the Wire library
// Set ADXL345 in measuring mode
Wire.beginTransmission(ADXL345); // Start communicating with the device
Wire.write(0x2D); // Access/ talk to POWER_CTL Register - 0x2D
// Enable measurement
Wire.write(8); // (8dec -> 0000 1000 binary) Bit D3 High for measuring enable
pinMode(10, OUTPUT); //Must declare 10 an output and reserve it
SD.begin(4); //Initialize the SD card reader

void loop() {
Wire.requestFrom(ADXL345, 6, true); // Read 6 registers total, each axis value is stored in 2 registers
X_out = ( Wire.read()| Wire.read() << 8); // X-axis value
X_out = X_out; //For a range of +-2g, we need to divide the raw values by 256, according to the datasheet
Y_out = ( Wire.read()| Wire.read() << 8); // Y-axis value
Y_out = Y_out;
Z_out = ( Wire.read()| Wire.read() << 8); // Z-axis value
Z_out = Z_out/256;

AngleData = SD.open("PTData.txt", FILE_WRITE);
if (AngleData) {
Serial.print("X= ");
Serial.print(" Y= ");
Serial.print(" Z= ");
delay(50); //Pause between readings.

AngleData.close(); //close the file

@sanket021999, your topic has been moved to a more suitable location on the forum.

Please edit your post, select all code and click the </> button; next save your post.

Please spend some time reading How to get the best out of this forum; the use of e.g. code tags is described in there.

Your topic title does not (and can not) cover everything; please give proper description of what you expect the code to do and what it is actually doing.

Which Arduino are you using?

What is the issue?

We will need a little more context, do you get an error code from the SD card when you try to save it to it? What comes up on the Serial monitor when you run the code, could you give a screen shot of what comes up on the Serial monitor.

Their is no any error shown in code of sd card and also on serial monitor

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.