Digispark (Or Attiny85) trouble with I2C on VL6180X TOF Sensor

HI! I don't know if it's the right place to post my doubt, or if it's in the "Sensors" subforum. If needed, the admin should move it to there.

I'm trying to use a Digispark (that later will be on a Standalone Attiny85) with a TOF VL6180X sensor, over I2C.

I'm using the DrAzzy's core over the Arduino IDE, that makes it possible to use Wire.h library normally to interface with I2c devices.

From the libraries available for download in the IDE's library manager for this sensor (Polulo, Adafruit's, Sparkfun and SmartEverything), only the SparkFun actually worked for me in the Attiny85.

I happen to have a Digispark PRO, that has an Attiny167, and in the Digispark PRO, no library worked at all.

The other libraries are able to initialize the Digispark sensor, but failed to measure anything.

For testing I tried each libraries' own examples.

I'd like to know if anyone has another working library, or any modified one that that could work fully and normally on the Attiny85 and possibly also on the Attiny167.

I'm running into a bug that happens only on the Digispark (with the vl6180x), and doesn't happen when using the exact code in the Leonardo, for instance.

The VL6180X works, measures, but at random, shuts itself down. I can see the dim-lit red tiny red blinking light disappear. The Digispark doesn't hang, it's still functional, but no measurements are done anymore. The sensor works, but at random stops measuring.

I read in the Polulu forums some people having this exact problems with other MCUs also, and it seemed to be cable length related, as I2c was not meant to be used over long distances. But my digispark and the VL6180X are in the same small breadboard (for now)

I tried powering it from a separate 5V supply (with common grounds), with no difference.

In my case, it never happens in the Pro-Micro (Leonardo), with the exact sketch, exact same breadboard.

For testing, I soldered the sensor in an end of a 1.5m shielded cable, because my sensor will need to be in the end of a cable.

Then I plugged it to the breadboard with the Digispark. Now, even the Sparkfun's library (that used to work, but would hang at random) doesn't even recognize anymore the sensor. So cable length is a problem on the Digispark.

But when I plugged this 1.5m cable into the same breadboard, but replaced the Digispark by the Pro-Micro, even with the 1.5m cable length, it worked normally and flawlessly. It never hangs.

I know I should stick to the Atmega32u4, but the Attiny85 would fit better in the space constraints I have...

Ok, I'll answer myself to leave this doubt solved if anyone runs into some bugs like myself.

The cause was I was using the Digispark core, for both the Digispark and Pro. (85 and 167), and this core is outdated.

When I chose the Dr.Azzy's core for using with the Digispark, everything worked normally. All libraries worked fine, in the Digispark and in the Pro.

Woohoo! So glad to hear it!