Unable to connect MPU6050 with esp32

I have connected my esp32 with MPU6050
3.3 -> vcc
gnd->gnd
SDA->21
SCL->22
(all other connection are open)

At this connection I was not able to detect this MPU6050 board .


I used to following code to scan

void scan_mpu(WireType& wire = Wire) {
    Serial.println("Searching for i2c devices...");
    device_count = 0;
    for (uint8_t i = 0x68; i < 0x70; ++i) {
        wire.beginTransmission(i);
        if (wire.endTransmission() == 0) {
            addrs[device_count++] = i;
            delay(10);
        }
    }
    Serial.print("Found ");
    Serial.print(device_count, DEC);
    Serial.println(" I2C devices");

    Serial.print("I2C addresses are: ");
    for (uint8_t i = 0; i < device_count; ++i) {
        Serial.print("0x");
        Serial.print(addrs[i], HEX);
        Serial.print(" ");
    }
    Serial.println();
}
void setup() {
    Serial.begin(115200);
    Serial.flush();
    Wire.begin();
    delay(2000);

    scan_mpu();

    if (device_count == 0) {
        Serial.println("No device found on I2C bus. Please check your hardware connection");
        while (1)
            ;
    }
}

But after I connected pull-up resistor of 4.7k via 3.3V to sda and scl.
like the following image.

Now if I run i2c scan. I find a device at 0x68 some times not every time.

I am using Adafruit_MPU6050 library.

But problem remains the same. I am not able to connect this IMU with esp32. The connection breaks any time which causes my machine to disbalance.

previously I have connected mpu9250 with arduino uno (atmega328p) which has shown no problem.

Please tell me where I went wrong.
Thanking your

Please read and use the advise in this link: How to get the best out of this forum - Using Arduino / Project Guidance - Arduino Forum

Post schematics, code....
Connecting "this to that" is not at all clear. How is the powering done?.....
Several questions not being answered in Your post.

@Railroader I have properly framed question . if something is not clear , then please do tell me.
Thank you

Okey, not schematics but a picture.

There's no powering of the setup.
Showing GPIO 22 and GPIO 21 tells me nothing, not playing with ESP's. The physical pins don't tell. In schematics the logic designation of the pin has the information.

What's the message when 0x68 is not found?

Are You using a breadboard? A poor contact of Vcc, GND, SCL or SDA could be the reason.

What's the code You use for running the real application?

Due to the picture I'm uncertain about just anything but nothing looks totally wrong.

GPIO 22 and GPIO 21 are SCL and SDA pins respectively is esp32 wroom.

I have powered esp32 using a usb cable.

Here I have displayed the message that no device has been found.

I have used this code to check I2C connection.

Everything has been properly soldered.

I am building a drone with esp32 and mpu6050 and was tuning it. But suddenly mpu6050 connection breaks most of the time. If connection does not break than code works fine.

Okey.
You identify the address, 0x68 "several times". That's the correct address.
You also run the big project quite well except for intermittent trouble.
Does the rate of trouble increase supposing You start with well charged power supply? I use USB powering from phone power banks.
Do You use soldered connections all the way?

A guess.... Is there some kind of limit how often/quickly the 6050 can respond on the I2C? Is the calling frequency too high?

Yes, at starting I was able to properly use this sensor with minimum trouble. But now every time i2c connection is not detected. I have recently scanned i2c connection. I observed is that the address found is not fixed ( it should have been 0x68) sometimes two times I got 0x6E and other times not connection detected.

yes , I got every thing soldered from an expert.

The MPU-6050 supports I2C communications at up to 400kHz.

My MPU-6050 i2c connection is unstable. I do not think calling frequency is high. I am using standard library for pu 6050 with no changes. It work fine every where.

I am using MPU-6050 chinese sensor. (It might happen that something is wrong with my sensor, but it was working before)

You surely have something disturbing the I2C lines or just a cable broken and intermittent contact. Run the address scan and "rock" the cables, one at the time. I once got a stepper with a broken cable...

That's the frequency of the SCL. Not the rate You can call the 6050. Maybe I'm wrong and the 6050 is spitting out data..

Yes but the lib only connects You to the device. If You call the lib read/write function at a high rate I can imagine problems.

They know how to send up satellites and make nuclear bombs so....
One fear is they sell North Korean made rubbish....

Trial and failure is not my signum. Suggesting buy a genuine 6050 is the last idea on the road.

Let's see if any helper has experienced things like You.

Good! What did You change to achieve this?

Good. Surpriced that such a low value did the trick. I would have suggested 1 - 10 nF. In my opinion adding a second cap like a 10 - 100 microFarad bulk cap could increase the margins.
The Wifi transmitter can be an ugly device using high frequency transmitting that pulls "some" current.

@anchalshivank

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.

It will help you get the best out of the forum in the future.

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