This is my wiring, all direct connections, no resistors. The simplest wiring possible i think.
VDD ----> 3.3v
GND ----> GND
SDA ----> A4
SCL ----> A5
VIO ----> 3.3v (same VDD supply)
chazm try this exactly this wiring, take out the resistors, and try to disconnect not mentioned pins.
I may be wrong about the sleep bit, so this is a little more complex code which solves that, it should output accelerometer x values.
This is a video of me executing this code.
#include <Wire.h>
#define MPU6050_ACCEL_XOUT_H 0x3B
#define MPU6050_ACCEL_XOUT_L 0x3C
#define MPU6050_ACCEL_YOUT_H 0x3D
#define MPU6050_ACCEL_YOUT_L 0x3E
#define MPU6050_ACCEL_ZOUT_H 0x3F
#define MPU6050_ACCEL_ZOUT_L 0x40
#define MPU6050_GYRO_XOUT_H 0x43
#define MPU6050_GYRO_XOUT_L 0x44
#define MPU6050_GYRO_YOUT_H 0x45
#define MPU6050_GYRO_YOUT_L 0x46
#define MPU6050_GYRO_ZOUT_H 0x47
#define MPU6050_GYRO_ZOUT_L 0x48
#define MPU6050_PWR_MGMT_1 0x6B
#define MPU6050_I2C_ADDRESS 0x68
uint16_t ax, ay, az, gx, gy, gz;
void setup() {
uint8_t c = 0;
Serial.begin(9600);
Wire.begin();
MPU6050_write(MPU6050_PWR_MGMT_1, &c, 1); //Stop device from reseting/sleeping
Serial.println("START");
}
void loop() {
ax = calculate_value(MPU6050_ACCEL_XOUT_H, MPU6050_ACCEL_XOUT_L, 1);
ax = (ax-32500)/8.192;
Serial.println(ax);
}
uint16_t calculate_value(int address_h, int address_l, int size) {
uint8_t hi, lo;
uint16_t value;
hi = MPU6050_read(address_h, size);
lo = MPU6050_read(address_l, size);
value = ((hi)<<8);
value |= lo;
return(value);
}
uint8_t MPU6050_read(int address, int size) {
uint8_t value;
Wire.beginTransmission(MPU6050_I2C_ADDRESS);
Wire.write(address);
Wire.endTransmission(false);
Wire.requestFrom(MPU6050_I2C_ADDRESS, size, true);
while(Wire.available()) {
value = Wire.read();
}
return (value);
}
int MPU6050_write(int address, uint8_t *data, int size) {
Wire.beginTransmission(MPU6050_I2C_ADDRESS);
Wire.write(address); // write the start address
Wire.write(data, size); // write data bytes
Wire.endTransmission(true); // release the I2C-bus
return (0); // return : no error
}