Hey there!
I just started with Arduino, so probably the solution for my problem is quite simple, but unfortunatelly I cannot find it -.-
I'm using Arduino Pro Mini (5V, 16MHz) with Atmega 328 board and try to read raw data from MPU-6050. I use USBasp programmator. I connected the MPU SCL to Arduino's PIN 5 (SLC), and SDA to Arduino's PIN 4 (SDA). XDA, XCL and INT I left not connected, the same with AD0 (in programme I use address 0x68). Of course VCC and GND are connected as well
Since I'm not an expert (yet ^^) I started with some ready made projects I've found on playground.arduino.cc (this one to be exact http://playground.arduino.cc/Main/MPU-6050#short). I edited a programme a bit, since I don't wanna put the data to Serial Monitor, but 16x2 LCD Display (JHD 162A).
#include <Wire.h>
const int MPU=0x68; // I2C address of the MPU-6050
int16_t AcX,AcY,AcZ,Tmp,GyX,GyY,GyZ;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 7, 6, 3, 2); // (RS, E, D4, D5, D6, D7)
void setup()
{
Wire.begin();
Wire.beginTransmission(MPU);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);
}
void loop()
{
Wire.beginTransmission(MPU);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.endTransmission(false);
Wire.requestFrom(MPU,14,true); // request a total of 14 registers
AcX=Wire.read()<<8|Wire.read(); // 0x3B (ACCEL_XOUT_H) & 0x3C (ACCEL_XOUT_L)
AcY=Wire.read()<<8|Wire.read(); // 0x3D (ACCEL_YOUT_H) & 0x3E (ACCEL_YOUT_L)
AcZ=Wire.read()<<8|Wire.read(); // 0x3F (ACCEL_ZOUT_H) & 0x40 (ACCEL_ZOUT_L)
GyX=Wire.read()<<8|Wire.read(); // 0x43 (GYRO_XOUT_H) & 0x44 (GYRO_XOUT_L)
GyY=Wire.read()<<8|Wire.read(); // 0x45 (GYRO_YOUT_H) & 0x46 (GYRO_YOUT_L)
GyZ=Wire.read()<<8|Wire.read(); // 0x47 (GYRO_ZOUT_H) & 0x48 (GYRO_ZOUT_L)
lcd.begin(16, 2);
lcd.setCursor(1,1);
lcd.print(AcX);
lcd.setCursor(1,0);
lcd.print(GyX);
delay(500);
}
The display is just putting "-1" value to both AcX and GyX, moving the board around doesn't change a thing.
I also checked the other code from same website (Arduino Playground - MPU-6050). I just added
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 7, 6, 3, 2); // (RS, E, D4, D5, D6, D7)
at the beggining, and
lcd.begin(16, 2);
lcd.setCursor(1,1);
lcd.print(accel_t_gyro.value.y_accel);
in line 760 to just check the data reading. There was a little progression, the LCD is showing some changing values, however they seem to just randomly change, rotating the board doesnt make any difference as well). The values sometimes change between f.ex. 512 and 212 every second, then after some time change to over 30000, then drop drastically.
The communication with LCD is fine, I can put there other data as well, and they behave normally. F.ex. homemade touch sensor used with ADC works perfectly fine.
Does anyone have any idea what could be the problem?