Xbee and WM+

Thanks. This is the code I use to read the gyro values:

/* Activate Wii Motion +
______________________________________________________________________*/

void enableWii()
{
   Wire.beginTransmission(0x53);    //WM+ starts out deactivated at address 0x53
   Wire.send(0xfe);                 //send 0x04 to address 0xFE to activate WM+
   Wire.send(0x04);
   Wire.endTransmission();          //WM+ jumps to address 0x52 and is now active
}

/* Calibrate Wii
______________________________________________________________________*/

void calibrateWii()
{
  for (int i=0; i < 10; i++)
  {
    sendZeroWii();
    
    Wire.requestFrom(0x52,6);
    
    for (int i=0;i<6;i++)
    {
      data[i] = Wire.receive();
    }
    
    yaw0   += (((data[3]>>2)<<8)+data[0]) / 10;        //average 10 readings for each zero
    pitch0 += (((data[4]>>2)<<8)+data[1]) / 10;
    roll0  += (((data[5]>>2)<<8)+data[2]) / 10;
  }
}

/* Get data from Wii
______________________________________________________________________*/

void receiveData()
{
  sendZeroWii();                   //send zero before each request (same as nunchuck)
  Wire.requestFrom(0x52,6);        //request the six bytes from the WM+
  
  for(int i=0; i<6; i++)
  {
    data[i] = Wire.receive();
  }
  
  yaw   = ((data[3]>>2)<<8) + data[0] - yaw0;        //see http://wiibrew.org/wiki/Wiimote/Extension_Controllers#Wii_Motion_Plus
  pitch = ((data[4]>>2)<<8) + data[1] - pitch0;    //for info on what each byte represents
  roll  = ((data[5]>>2)<<8) + data[2] - roll0;      
}

/* Send 0 to communicate with wii
______________________________________________________________________*/

void sendZeroWii()
{
  Wire.beginTransmission(0x52);    //now at address 0x52
  Wire.send(0x00);                 //send zero to signal we want info
  Wire.endTransmission();
}

After that I just Serial.print the values.

I guess it must have something to do with the power consumption. Because if I keep the USB plugged in but transfer the data over XBee, I get the right values.

So it must be when I disconnect the USB and use a 12v power adapter that the problem appears?