Hi everyone,
I've just start my work with Arduino and I'm trying to build measurement system with three or more accelerometers (MPU 6050).
I wrote simple code (Szkic_3-axis) based at Korneliusz Jarzębski code -http://www.jarzebski.pl/arduino/czujniki-i-sensory/3-osiowy-zyroskop-i-akcelerometr-mpu6050.html- but when I'm trying to do the same with Jeff Rowberg Script (SZKICOWNIK) -https://github.com/jrowberg/i2cdevlib/tree/master/Arduino/MPU6050- I have problem which I cannot understand because this code works with one accelerometers properly, but now I can't see any data...
Thats my problems with compilation:
In file included from C:\Users\Daniel\Documents\Arduino\SZKICOWNIK\SZKICOWNIK.ino:49:0:
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h: In member function 'uint8_t MPU6050::dmpGetGravity(int16_t*, const uint8_t*)':
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050/MPU6050_6Axis_MotionApps20.h:689:65: warning: integer overflow in expression [-Woverflow]
- (int32_t)qI[2] * qI[2] + (int32_t)qI[3] * qI[3]) / (2 * 16384);
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050/MPU6050.h:436:7: warning: type 'struct MPU6050' violates one definition rule [-Wodr]
class MPU6050 {
^
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050\MPU6050.h:436:7: note: a different type is defined in another translation unit
class MPU6050 {
^
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050/MPU6050.h:1026:18: note: the first difference of corresponding definitions is field 'dmpPacketBuffer'
uint8_t *dmpPacketBuffer;
^
C:\Users\Daniel\Documents\Arduino\libraries\MPU6050\MPU6050.h:436:7: note: a type with different number of fields is defined in another translation unit
class MPU6050 {
^
I suppose that my problem is with DMP. Firstly I had connect every INT to 2 pin but now I was try connect every INT to another pin (2,3 and 4).
I've try to separate every value to another sensor:
#define INTERRUPT_PIN 2 // use pin 2 on Arduino Uno & most boards
#define INTERRUPT2_PIN 3
#define INTERRUPT3_PIN 4
#define GLOWKA 5 // use pin 5
#define TROJKAT 6 // use pin 6
#define DAMPER 7 // use pin 7
#define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
bool blinkState = false;
int Alfons = 1; // Counter
// MPU control/status vars
bool dmpReady = false; // set true if DMP init was successful
bool dmp2Ready = false;
bool dmp3Ready = false;
uint8_t mpuIntStatus; // holds actual interrupt status byte from MPU
uint8_t mpu2IntStatus;
uint8_t mpu3IntStatus;
uint8_t devStatus; // return status after each device operation (0 = success, !0 = error)
uint8_t dev2Status;
uint8_t dev3Status;
uint16_t packetSize; // expected DMP packet size (default is 42 bytes)
uint16_t packet2Size;
uint16_t packet3Size;
uint16_t fifoCount; // count of all bytes currently in FIFO
uint16_t fifo2Count;
uint16_t fifo3Count;
uint8_t fifoBuffer[64]; // FIFO storage buffer
uint8_t fifo2Buffer[64];
uint8_t fifo3Buffer[64];
But I've no idea what to do with "_BV(MPU6050_INTERRUPT_DMP_INT_BIT)":
if ((mpu2IntStatus & _BV(MPU6050_INTERRUPT_FIFO_OFLOW_BIT)) || fifo2Count >= 1024) {
// reset so we can continue cleanly
mpu2.resetFIFO();
fifo2Count = mpu2.getFIFOCount();
Serial.println(F("FIFO_2 overflow!\t"));
Serial.println("Fifo2Count\t");
Serial.println(fifo2Count);
Serial.println("mpu2IntStatus\t");
Serial.println(mpu2IntStatus);
Serial.println("MPU6050_INTERRUPT_FIFO_OFLOW_BIT\t");
Serial.println(MPU6050_INTERRUPT_FIFO_OFLOW_BIT);
// otherwise, check for DMP data ready interrupt (this should happen frequently)
} else if (mpu2IntStatus & _BV(MPU6050_INTERRUPT_DMP_INT_BIT)) {
// wait for correct available data length, should be a VERY short wait
while (fifo2Count < packet2Size) fifo2Count = mpu2.getFIFOCount();
// read a packet from FIFO
mpu2.getFIFOBytes(fifo2Buffer, packet2Size);
// track FIFO count here in case there is > 1 packet available
// (this lets us immediately read more without waiting for an interrupt)
fifo2Count -= packet2Size;
Now I have no idea why it doesn't work or maybe I made something wrong?
SZKICOWNIK.ino (34 KB)
Szkic_3-axis.ino (3.55 KB)