Hi everyone.
I am struggeling to let a Digispark Pro (ATtiny167) communicate with the GY-521 / MPU-6050 board
I must say, that I've never ever used I2C before. So I cannot know, where to start searching for the problem and which boards work well together and how I can tell right away which don't.
What am I doing?
I try to summarize the essential code, that in the end should produce some numbers.
#include <Wire.h>
pinMode(0, INPUT); // SDA
pinMode(2, INPUT); // SCL
Wire.begin();
// Setup MPU-6050
Wire.beginTransmission(0x68); // default address, when AD0 is not pulled high.
Wire.write(0x6B); // Register to disable sleep.
Wire.write(0b00000000);
Wire.endTransmission(); // returns 0
Wire.beginTransmission(0x68);
Wire.write(0x1B); // Register for gyro setup
Wire.write(0x00000000);
Wire.endTransmission(); // returns 0
Wire.beginTransmission(0x68);
Wire.write(0x1C); // Register for accel setup
Wire.write(0b00000000);
Wire.endTransmission(); // returns 0
Wire.beginTransmission(0x68);
Wire.write(0x3B); // Starting register of 6 bytes accelerometer values (3x high/low).
Wire.endTransmission(); // returns 0
Wire.requestFrom(0x68, 6); // returns 0
// each of the following 6 read() calls returns 0 here, where I would expect some reasonable byte values.
XH = Wire.read();
XL = Wire.read();
// ...
If all of the endTransmission() calls return 0, I think, the I2C is working fine, isn't it?
I only have a very simple DIY oscilloscope, which may not be able to handle 400kHz, but at least I can see, that SCL and SDA are pulled high by the board, which according to the I2C specs is correct. Further I catch some signals on wire, that look like communication is going on, without analyzing in detail - I would assume I don't need to debug a popular protocol like I2C. (Side note: When I was using a Digispark first, I got the return code 3 for the 3 setup calls, while I could observe SCL and SDA being pulled low. Maybe my Digispark is broken, that's why I switched to the Pro.) That's why I would assume, with the Pro the I2C works here.
About the wiring:
Pro 5V -> GY VCC, providing 4.8V
Pro PIN 0 -> GY SDA
Pro PIN 2 -> GY SCL
and of course a shared GND.
Power supply is via USB only for now.
Why am I getting 0 out of all registers? Btw. - the only way for me to see, what's going on is to use DigiKeyboard's println().
Any experiences? Any advice? Opinions?