

nd(0) // set to zero (wakes up the MPU-6050) TinyWireM.beginTransmission(MPU6050_ADDR) Wire.requestFrom(MPU6050_ADDR,14,true) // request a total of 14 registers Wire.write(0x3B) // starting with register 0x3B (ACCEL_XOUT_H) Wire.write(0) // set to zero (wakes up the MPU6050)
#Tiny wire library serial
Then the values are output on the serial monitor. Since these are 16-bit values, two registers must be read at a time, for a total of fourteen. The three acceleration values, the temperature and the three gyroscope values are then read out one after the other in the main loop. The following sketch uses the wire library for I2C communication. The following circuit was used: Circuit for the control of the MPU6050 MPU6050 Control with Wire Since I want to output the readings of the MPU6050 on the serial monitor, I burned the Optiboot bootloader to the ATtiny85 and uploaded the sketches with a USB-to-TTL Serial Adapter. Here and now, it’s all about seeing TinyWireM and Wire in action. Those interested in the details of this component can read my post on it. I have chosen the 6-axis gyroscope and accelerometer module MPU6050 as a demonstration object. However, to understand the differences between TinyWireM and Wire, let’s now look at an example where we don’t use a component library. In most cases you probably use libraries for I2C devices which do it for you to address the devices on register level using the wire functions. Pinout ATtiny85 / 45 / 25 Using TinyWireM and Wire for the MPU6050 Otherwise, it will be too small for some examples.

However, it should be a model with 8 kByte program memory. You can just as well take another ATtiny which is compatible with ATTin圜ore.
#Tiny wire library download
Alternatively, you can download the library directly from GitHub here.įor this article, I use an ATtiny85. You can get the library via the library manager of the Arduino IDE. You should as well have TinyWireM installed. If that’s not the case, just check out my last post, where I explained it all in detail.

#Tiny wire library how to
I also assume you know how to burn bootloaders and upload sketches with it. I assume that you have installed the ATTin圜ore package from Spence Konde. I will confine myself here to the use of the ATtinys as masters in this post. For example, if you wanted two ATtinys to communicate with each other via I2C, you would need both variants. For the latter, there are several other libraries like TinyWireS. That means the library allows to make the ATtiny the I2C master, but not the slave. And finally, I show with two examples that you can modify many I2C based libraries to make them compatible with TinyWireM without much effort. I also introduce TinyWireM compatible libraries for some I2C based devices. In this article, I use Adafruit’s TinyWireM library as an example to explore how big the savings are compared to Wire. However, since they are leaner, their use on the ATtinys with their limited program memory can still be useful. Special libraries for the I2C implementation, such as TinyWireM, TinyI2C or USIWire are thus no longer needed. This package allows using the USI interface of the ATtinys for I2C use with the Wire library. In the last post I had reported about programming ATtinys with ATTin圜ore.
