Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I2C Not working with MPU6050 on BLE Nano 2 #39

Open
jcbooth2 opened this issue Apr 13, 2018 · 0 comments
Open

I2C Not working with MPU6050 on BLE Nano 2 #39

jcbooth2 opened this issue Apr 13, 2018 · 0 comments

Comments

@jcbooth2
Copy link

Hello,

When I use the following code in Arduino environment, there is no signal at all on either SDA or SCL line. I checked it with an oscilloscope.

From what I have researched, the I2C is not very reliable with BLE Nano 1 or 2. I know that the Nano 1 had a problem with a specific setting in the 'i2c_api.c' file as described by this post. I am wondering if there is a similar fix for the BLE Nano 2, or if someone has had a similar problem?

`#include<Wire.h>
#include<nRF5x_BLE_API.h>

const uint8_t MPU_ADDR = 0x68;
int16_t acc[3], gyro[3], temp;

void setup()
{
Wire.begin(D3, D2, TWI_FREQUENCY_100K);
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x6B); // PWR_MGMT_1 register
Wire.write(0); // set to zero (wakes up the MPU-6050)
Wire.endTransmission(true);

Serial.begin(9600);
}

void loop()
{
Wire.beginTransmission(MPU_ADDR);
Wire.write(0x3B); // starting with register 0x3B (ACCEL_XOUT_H)
Wire.requestFrom(MPU_ADDR,14,true); // request a total of 14 registers
acc[0]= Wire.read()<<8|Wire.read();
acc[1]= Wire.read()<<8|Wire.read();
acc[2]= Wire.read()<<8|Wire.read();
temp = Wire.read()<<8|Wire.read();
gyro[0]= Wire.read()<<8|Wire.read();
gyro[1]= Wire.read()<<8|Wire.read();
gyro[2]= Wire.read()<<8|Wire.read();

Serial.print("AcX = "); Serial.print(acc[0]);
Serial.print(" | AcY = "); Serial.print(acc[1]);
Serial.print(" | AcZ = "); Serial.print(acc[2]);
Serial.print(" | Tmp = "); Serial.print(temp/340.00+36.53); //equation for temperature in degrees C from datasheet
Serial.print(" | GyX = "); Serial.print(gyro[0]);
Serial.print(" | GyY = "); Serial.print(gyro[1]);
Serial.print(" | GyZ = "); Serial.println(gyro[2]);

delay(333);
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant