MPU6050/Servo tutorial not working.

Hello. I read arduino124789's post about the link/tutorial he tried to control a servo with a MPU6050 which didn't work. I tried to do it also..but it wouldn't work for me either. So...my question is...why isn't it working??

Here is the link...it contains the diagram and the code: Controlling of Servo Motor with Arduino and MPU6050

I would appreciate if you could answer my question.

(Why was arduino124789's question taken down?)

Insert serial prints to see what values are returned by the refresh function.

I did....

I put this code in: Serial.println(X);

He returns nothing...the Serial Moniter is empty...Is that the right code to put in?

Did you remember to put a Serial.begin(9600) in setup?

When you make changes to your code please post the latest so that we can keep up.

I didn't...Smh

All it returns is '87' for x...nomatter how i move the MPU6050

And it returns 90 for y

Its not reading the movement of the gyro properly. And ideas why?

First i would establish that the MPU is talking to the Arduino. Run the I2C scanner to confirm the I2C address and communication.

 // I2C scanner by Nick Gammon.  Thanks Nick.

#include <Wire.h>

void setup() {
  Serial.begin (115200); //*****  make sure serial monitor baud matches *****

  // Leonardo: wait for serial port to connect
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 1; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

This is what comes up:

I2C scanner. Scanning ...
0 device(s).
⸮x⸮⸮

Does this mean that it is not communicating...If so...how can i fix it?

Can you post photos of your project wiring?

Here is the link to a frizzing diagram of it:

Has the sensor board got pullups on SDA and SCL?

I do not care about a fritzing of what it should look like. I need to see how you have your device(s) wired.

If the I2C scanner does not see the MPU, there is a wiring problem or the MPU is bad. There is no point messing with software if the processor cannot see the MPU.

Can you post a data sheet for the, exact, MPU6050 module that you have or point us to information about it?

Im sorry..what what do you mean by a data sheet for the MPU

The project page makes the idiotic suggestion to power the servo from the Arduino 5V supply.

Don’t do that, it could actually destroy the Arduino. Use a 4xAA battery pack to power the servo, and connect the grounds.

Post a link to the exact MPU-6050 module that you have, and post a clear, easy to interpret photo of your wiring or much better, a hand drawn wiring diagram. Image posting guide

Ok..but the problem is we cant get the MPU to communicate to my pc and Serial Moniter.. Is it okay to have it be powered by 3.3 v?

This is exact one I bought: MPU-6050 (GY-521) 3-Axis Accelerometer and Gyro for Arduino

A data sheet has the description, specifications, pinouts, and other information on the part. You should have data sheets for all the major parts in the project.

It should work at 3.3V, but I would power it with 5V.

Is it okay to have it be powered by 3.3 v?

Probably not. That module has a voltage regulator and is intended to be powered from 5V. People have had problems with those, as the regulator drops too much voltage when 3.3V is applied to "Vcc".

It will work to bypass the regulator and connect 3.3V to the regulator output pin.

1 Like

My project has the same exact wiring as the diagram I showed you. I've checked it more than 3 times and my friend also did...thats not the problem...should I switch out the MPU?

Does powering the MPU with 5V make a difference when you run the scanner?

I made some progress. The servo I was using was bad...I swapped it with a good one

When I plug it into my pc..the servo moves once..then it stops....

Also, how many lights are supposed to light up on a MPU once it is fully powered? Mine only has one light lighting up.