user15677: I want to integrate Pololu's vl53l0x Time of Flight distance sensor into a project of mine. They created a library to interface with the vl53l0x over I2C, which works great on my Uno. The only problem is that Wire.h doesn't work on the ATtiny85.
TinyWireM is a replacement library for Wire that I think would be compatible. My question is this: how can I go about replacing all the calls to the Wire library with calls to the TinyWireM library? Is it as simple as replacing all instances of Wire with TinyWireM? Is there anything else I need to do to make the library ATtiny85 compatible?
Thanks!

user31802: In fact, there would be nothing to do now I guess, as TinyWireM is now included tiny boards packages.
If you just include Wire as usual, it should work as on an UNO.
Except for setting a different clock, if I remember well, it is fixed to 400kHz.

user45521: I can't guarantee it will work, but it is probably possible to just modify the library. You can find the source code for that ToF sensor library here:
https://github.com/pololu/vl53l0x-arduino/blob/master/VL53L0X.cpp
The first step is to find the reference to Wire.h (line 7 in that file) and change it to TinyWireM.h. After that, you would need to find the functions that call the Wire library and replace them with the appropriate TinyWireM functions instead. Those begin at line 284 (Wire.beginTransmission(address);). You can find the source code for TinyWireM here (which should tell you all of the functions in the library):
https://github.com/adafruit/TinyWireM/blob/master/TinyWireM.cpp
So Wire.beginTransmission(address); would become TinyWireM.beginTransmission(address); and Wire.write(reg); would become TinyWireM.send(reg);
I'm not sure if that's all of the solution, but I think that's a good start.

15677: <p>I want to integrate Pololu's <a href="https://www.pololu.com/product/2490" rel="nofollow noreferrer">vl53l0x Time of Flight distance</a> sensor into a project of mine. They created a <a href="https://github.com/pololu/vl53l0x-arduino" rel="nofollow noreferrer">library</a> to interface with the vl53l0x over I2C, which works great on my Uno. The only problem is that Wire.h doesn't work on the ATtiny85.</p>

<p><a href="https://github.com/adafruit/TinyWireM" rel="nofollow noreferrer">TinyWireM</a> is a replacement library for Wire that I think would be compatible. My question is this: how can I go about replacing all the calls to the Wire library with calls to the TinyWireM library? Is it as simple as replacing all instances of Wire with TinyWireM? Is there anything else I need to do to make the library ATtiny85 compatible?</p>

<p>Thanks!</p>
 31802: <p>In fact, there would be nothing to do now I guess, as TinyWireM is now included tiny boards packages.</p>

<p>If you just include Wire as usual, it should work as on an UNO.
Except for setting a different clock, if I remember well, it is fixed to 400kHz.</p>
 45521: <p>I can't guarantee it will work, but it is probably possible to just modify the library. You can find the source code for that ToF sensor library here:</p>

<p><a href="https://github.com/pololu/vl53l0x-arduino/blob/master/VL53L0X.cpp" rel="nofollow noreferrer">https://github.com/pololu/vl53l0x-arduino/blob/master/VL53L0X.cpp</a></p>

<p>The first step is to find the reference to <em>Wire.h</em> (line 7 in that file) and change it to <em>TinyWireM.h</em>. After that, you would need to find the functions that call the <em>Wire</em> library and replace them with the appropriate <em>TinyWireM</em> functions instead. Those begin at line 284 (<code>Wire.beginTransmission(address);</code>). You can find the source code for TinyWireM here (which should tell you all of the functions in the library):</p>

<p><a href="https://github.com/adafruit/TinyWireM/blob/master/TinyWireM.cpp" rel="nofollow noreferrer">https://github.com/adafruit/TinyWireM/blob/master/TinyWireM.cpp</a></p>

<p>So <code>Wire.beginTransmission(address);</code> would become <code>TinyWireM.beginTransmission(address);</code> and <code>Wire.write(reg);</code> would become <code>TinyWireM.send(reg);</code></p>

<p>I'm not sure if that's all of the solution, but I think that's a good start.</p>
