I think my wire.h library does not work properly. Please HELP!!

Hi everybody! I am a beginner with Arduino. But with this project I am working on right now I have the same problem over and over.

Setup: I got a GY-521 Accelerometer connected to my Arduino.


The internet tells me that I only have to use the SCL and SDA wires, so I did. The sensor is green and everything but when I upload the code, every time I check out the Serial Monitor to see the data I get question marks. Like this

At first It seems to work but then the data turns into question marks. I really don't know how I can fiks this, the only thing I can think of is that maybe my wire.h library is not installed properly or anything.

I've used many different tutorials for example:

[url=https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/[]https://howtomechatronics.com/tutorials/arduino/how-i2c-communication-works-and-how-to-use-it-with-arduino/[[/url] http://www.mschoeffler.de/2017/10/05/tutorial-how-to-use-the-gy-521-module-mpu-6050-breakout-board-with-the-arduino-uno/

When I got this fiksed and got the code well. I want to make a device what works together with an micro SD card reader.

|500x215 Anyone extra tips for that?

This is the code I was using right now:

//--- Accelerometer Register Addresses
#define Power_Register 0x2D
#define X_Axis_Register_DATAX0 0x32 // Hexadecima address for the DATAX0 internal register.
#define X_Axis_Register_DATAX1 0x33 // Hexadecima address for the DATAX1 internal register.
#define Y_Axis_Register_DATAY0 0x34 
#define Y_Axis_Register_DATAY1 0x35
#define Z_Axis_Register_DATAZ0 0x36
#define Z_Axis_Register_DATAZ1 0x37
int ADXAddress = 0x53;  //Device address in which is also included the 8th bit for selecting the mode, read in this case.
int X0,X1,X_out;
int Y0,Y1,Y_out;
int Z1,Z0,Z_out;
float Xa,Ya,Za;
void setup() {
 Wire.begin(); // Initiate the Wire library    
 Wire.write(Power_Register); // Power_CTL Register
 // Enable measurement
 Wire.write(8); // Bit D3 High for measuring enable (0000 1000)
void loop() {
 // X-axis
 Wire.beginTransmission(ADXAddress); // Begin transmission to the Sensor 
 //Ask the particular registers for data
 Wire.endTransmission(); // Ends the transmission and transmits the data from the two registers
 Wire.requestFrom(ADXAddress,2); // Request the transmitted two bytes from the two registers
 if(Wire.available()<=2) {  // 
   X0 = Wire.read(); // Reads the data from the register
   X1 = Wire.read();
   /* Converting the raw data of the X-Axis into X-Axis Acceleration
    - The output data is Two's complement 
    - X0 as the least significant byte
    - X1 as the most significant byte */ 
   X_out =X0+X1;
   Xa=X_out/256.0; // Xa = output value from -1 to +1, Gravity acceleration acting on the X-Axis
 // Y-Axis
 if(Wire.available()<=2) { 
   Y0 = Wire.read();
   Y1 = Wire.read();
   Y_out =Y0+Y1;
 // Z-Axis
 if(Wire.available()<=2) { 
   Z0 = Wire.read();
   Z1 = Wire.read();
   Z_out =Z0+Z1;
 // Prints the data on the Serial Monitor
 Serial.print("Xa= ");
 Serial.print("   Ya= ");
 Serial.print("   Za= ");

Please post the code that you are using.

OP’s image

The internet tells me that I only have to use the SCL and SDA wires

Which is true with only one device selected, but you cannot leave the chip select pin floating.

Need to post you code inside code tags to get rid of the smiling faces ;)