Multiple GY-521 sensors on Arduino


hi there,

i have tried gy-521 sensor on arduino using guide (http://playground.arduino.cc/main/mpu-6050). worked well. can guide me on how can add gy-512 module please? planning use total of 4 of them connected arduino uno. how define additional sensor modules in program?

it possible connect 2 of these sensors arduino, not four. on first, connect ad0 pin gnd, on second, connect ad0 pin 3,3v pin. first have i2c address 0x68, second have address 0x69.

i don't know sure, think should add things:
code: [select]
#define mpu6050_i2c_address_unit2 0x69 // address of second mpu


the rest of code used in different way. everywhere says "mpu6050_i2c_address", can choose mpu want use.

code: [select]
int mpu6050_read(int start, uint8_t *buffer, int size)
{
  int i, n, error;

  wire.begintransmission(mpu6050_i2c_address);
  n = wire.write(start);
  if (n != 1)
    return (-10);

  n = wire.endtransmission(false);    // hold i2c-bus
  if (n != 0)
    return (n);

  // third parameter true: relase i2c-bus after data read.
  wire.requestfrom(mpu6050_i2c_address, size, true);
  = 0;
  while(wire.available() && i<size)
  {
    buffer[i++]=wire.read();
  }
  if ( != size)
    return (-11);

  return (0);  // return : no error
}

this code 'do something' first mpu, when use mpu6050_i2c_address, , 'do something' second mpu when mpu6050_i2c_address changed mpu6050_i2c_address_unit2. same goes mpu_write()


Arduino Forum > Using Arduino > Sensors > Multiple GY-521 sensors on Arduino


arduino

Comments

Popular posts from this blog

Convierte tu Raspberry en un NAS. Firmware fvdw-sl 15.3 - Raspberry Pi Forums

How to format a Get Request

avrdude: verification error, first mismatch at byte 0x0000 0x0c != 0x62