Wifi uno rev2 & MPU6050

I am using a mpu6050 accelerometer and gyro with uno wifi rev2. There is a problem that the result values do not change. I think the problem is addresses of pin.

VCC-5V, GND-GND, SCL-A4, SDA-A5, INT-digit2

I'll write down the code↓

#include<Wire.h>

const int MPU=0x68;
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;

void setup(){
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B);
Wire.write(0);
Wire.endTransmission(true);
Serial.begin(9600);
}

void loop(){
Wire.beginTransmission(MPU);
Wire.write(0x3B);
Wire.endTransmission(false);
Wire.requestFrom(MPU,14,true);
AcX=Wire.read()<<8|Wire.read();
AcY=Wire.read()<<8|Wire.read();
AcZ=Wire.read()<<8|Wire.read();
Tmp=Wire.read()<<8|Wire.read();
GyX=Wire.read()<<8|Wire.read();
GyY=Wire.read()<<8|Wire.read();
GyZ=Wire.read()<<8|Wire.read();

Serial.print("AcX = "); Serial.print(AcX);
Serial.print(" | AcY = "); Serial.print(AcY);
Serial.print(" | AcZ = "); Serial.print(AcZ);
Serial.print(" | Tmp = "); Serial.print(Tmp/340.00+36.53);
Serial.print(" | GyX = "); Serial.print(GyX);
Serial.print(" | GyY = "); Serial.print(GyY);
Serial.print(" | GyZ = "); Serial.println(GyZ);
delay(1000);
}

Can you tell me what the problem is?
I would appreciate it if you could write the answer kindly :slight_smile:

Hi @hana1206. Here is your problem:

Unlike the classic Arduino Uno, the Uno WiFi Rev2 has dedicated pins for the I2C bus. So you must connect the MPU6050 to the pins marked SCL and SDA on the Uno WiFi Rev2 board.

Although it can be the source of confusion for people expecting the wiring to be the same, this is actually a really nice advancement because it means that on the Uno WiFi Rev2 the A4 and A5 pins are still free for you to use for whatever you like even when you have connected something to the SCL and SDA pins on the board. So you have two additional precious I/O pins to work with!

You mean I have to connect SCL to A5 and SDA to A4? I tried but the result value still does not change :frowning: Although i don't know well, i guess the address is wrong. Are there more problems? And thank you for your advice! :slight_smile: :+1:

No. Please make these connections:

MPU6050 pin Uno WiFi Rev2 pin
SCL SCL
SDA SDA

You can see the Uno WiFi Rev2 pinout here:


The SCL and SDA pins are near the top right of the diagram above

Thank you so much!!! I was doing something serious wrong. You're my hero :slight_smile:

You're welcome. I'm glad if I was able to be of assistance.