How to use MPU6050 and GY-GPSMV2 with nano?

I'm trying to use a mpu6050 sensor alongside a gpy-gpsmv2 and an arduino nano clone but I can't get the mpu6050 to give any output while the gps module works fine.
I'm using two different codes for each module just for testing before coding both in the same.
Any help is welcomed.

Hardware configuration:

9V battery connected to VIN and GND in the nano.

MPU6050:
VCC --> 5V
GND --> GND
SCL --> A5
SDA --> A4

GY-GPS6MV2:
VCC --> 3.3V
RX --> D3
TX --> D4
GND --> GND

MPU6050 code:

#include "I2Cdev.h"
#include "MPU6050.h"
#include "Wire.h"

MPU6050 sensor;

int ax, ay, az;
int gx, gy, gz;

void setup() {
  Serial.begin(57600);    //Iniciando puerto serial
  Wire.begin();           //Iniciando I2C  
  sensor.initialize();    //Iniciando el sensor

  if (sensor.testConnection()) Serial.println("Sensor iniciado correctamente");
  else Serial.println("Error al iniciar el sensor");
}

void loop() {
  sensor.getAcceleration(&ax, &ay, &az);
  sensor.getRotation(&gx, &gy, &gz);

  Serial.print("a[x y z] g[x y z]:\t");
  Serial.print(ax); Serial.print("\t");
  Serial.print(ay); Serial.print("\t");
  Serial.print(az); Serial.print("\t");
  Serial.print(gx); Serial.print("\t");
  Serial.print(gy); Serial.print("\t");
  Serial.println(gz);

  delay(100);
}

With a new I2C device, start by running the Arduino I2C address scanner program. That will check whether communications are working and report which I2C addresses are found.

Use the correct address in your program.

1 Like

I am not sure which battery you are using but one of the fire alarm type will not last very long, they do not supply much current. Also it would be much easier to follow a drawn schematic then the word version posted.

image
This is the schematic I did for the PCB where I would put all the components. There is an other component which I havent checked yet so you can ignore it.

I tried the I2C scanner but it gets stuck on scanning, so I guess there is a problem with the comunication between the arduino and the mpu.
I guess it has something to do with the gps, because if I try the mpu only, it works.

Looking at your schematic that is what I would expect to happen most of the time. There are no pull up resistors on that board and I2C requires them.

Thanks, I'll try that.

1 Like

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