How to use MPU6050 6 axis accel/gyro (or any I2Cdev) with Attiny

This took me days to figure out, but the solution was very simple to implement.

Attached is a zip of what is named the “Wire” library, but is actually the TinyWireM library with a few changes:
-Every instance of TinyWireM replaced with Wire
-“send” method changed to “write” method
-“recieve” method changed to “read” method

  • added “#define BUFFER_LENGTH 16”

The arduino IDE looks in user libraries before its libraries, so simply drop my “Wire” library into your libraries folder, and classes that depend on Wire should compile and function.

In examples there is my code to read one gyroscope axis and print it to whatever serial monitor you have hooked up to pin 3. Also, I have only tested this on Attiny85 at 8Mhz using IDE 1.6 on a macbook pro- reply if it does not work for you or if you have a fix.

Limitations of this ‘easy fix’-

-the standard ‘Wire’ library also has I2C slave capabilities - but TinyWireM is only master (but you should be able to use TinyWireS alongside this library)

-you need to removed my Wire library or rename it and restart arduino IDE to use the standard wire library, I don’t think that Atmega or an arduino can use TinyWire.

Be looking out for an Attiny balancing robot instructable (13.6 KB)

Thank you for posting this! Have you got it running right?