How to Put the GY521 IC2 device on Wire1 on a DUE

I am saving the the First wire port for some other devices. They don't play nice, so Im trying to move the IMU on the second SCL SDA port on an Arduino DUE>
It it possible right?

Here is what I tried, and I got "Could not connect"

Thanks
Mitch

#include "GY521.h"

GY521 sensor(0x68);

uint32_t counter = 0;


void setup()
{
  Serial.begin(115200);
  Serial.println();
  Serial.println(__FILE__);
  Serial.print("GY521_LIB_VERSION: ");
  Serial.println(GY521_LIB_VERSION);

  Wire1.begin();

  delay(100);
  while (sensor.wakeup() == false)
  {
    Serial.print(millis());
    Serial.println("\tCould not connect to GY521");
    delay(1000);
  }
  sensor.setAccelSensitivity(2);  //  8g
  sensor.setGyroSensitivity(1);   //  500 degrees/s

  sensor.setThrottle();
  Serial.println("start...");

  //  set calibration values from calibration sketch.
  sensor.axe = 0.574;
  sensor.aye = -0.002;
  sensor.aze = -1.043;
  sensor.gxe = 10.702;
  sensor.gye = -6.436;
  sensor.gze = -0.676;
}

I tested the device on wire zero and it works...
No hardware problem

GY521 sensor(0x68, &Wire1);

IIRC, Wire1 on the Due doesn't come with pullup resistors so you may have to add your own.

That worked, thanks a lot.
Did not have to put pull-ups . If I do , what is the Kohm recommendation ?

Since you're so good with DUE.
Is there a way to increase the PWM freq. on pins 2 to 7?
I am controlling motors and they make the annoying sound.

Thanks
mitch

Sorry, never worked with a Due, never even seen one. I just looked up the constructor in the GY521 library for the correct syntax. And as for knowing that Wire1 might need pullups (I like 4.7K myself, but the Due uses 1.5K on Wire for some reason) that was just something I've picked up reading the forum.

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