Hey! We are trying to use an MPU 9250/6500 and an RTC module with one Arduino. We are using the Analog 4 and 5 ports for I2C connection, but we also want to use their associated libraries (we found online). They both work separately, but when tied together with a pull-up resistor, they don't work at all. We have found no solution online to work so far... Any advice would be appreciated as we need both components for our project.
Thanks,
Engineering students with a dream
#include <MPU6050_tockn.h>
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 RTC;
MPU6050 mpu6050(Wire);
void setup() {
Serial.begin(9600);
Wire.begin();
Serial.print("START==============================================");
// Wire.beginTransmission(0x68);
// Wire.beginTransmission(0x50);
mpu6050.begin();
RTC.begin();
mpu6050.calcGyroOffsets(true);
if (! RTC.isrunning()) {
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date & time this sketch was compiled
RTC.adjust(DateTime(__DATE__, __TIME__));
}
}
void loop() {
mpu6050.update();
// Serial.print("angleX : ");
// Serial.print(mpu6050.getAngleX());
Serial.print("\tangleY : ");
Serial.print(mpu6050.getAngleY());
// Serial.print("\tangleZ : ");
// Serial.println(mpu6050.getAngleZ());
DateTime now = RTC.now();
Serial.print("\t\t\t");
Serial.print(now.year(), DEC);
Serial.print('/');
Serial.print(now.month(), DEC);
Serial.print('/');
Serial.print(now.day(), DEC);
Serial.print(' ');
Serial.print(now.hour(), DEC);
Serial.print(':');
Serial.print(now.minute(), DEC);
Serial.print(':');
Serial.print(now.second(), DEC);
Serial.println();
}