Seeking help:20x4 I2C LCD +Attiny85+TinyWireM: Library issue.

I’m attempting to use a 20x4 LCD on an attiny85, however, it seems the library that works with the device on the mega2560 won’t work on the attiny85 because it uses wire.

i have very little experience with editing the libraries for devices, so i really have no idea where to start with this one.

The LCD module is a 20x4 blue backlight with white characters
It has an I2C backpack attached with a PCF8574T
In the mega2560, the device address is 0x27

The device does function correctly in the mega2560 with the same sketch, however, due to library using wire, i can’t use TinyWireM instead.

I’ve spent the last 3 - 4 weeks googling whenever i had freetime, and i can’t find a working library for the device that uses tinywire.

If anyone has experience with doing this, or knows how to edit the working library to use TinyWireM, i would be most appreciative, as i really have no idea where to start when it comes to editing the hardware libraries.

Attached is a zip that contains the sketch i’m trying to use, and the working LCD library that came with the device.

Thank you in advance.

i2cAttiny85.zip (9.51 KB)

The real problem is in the tiny core. The core is broken since it doesn’t provide a working Wire library.
You should be able to do a few hacks to get something to work with the TinyWire library.
It would be trivial to fix the core, and I don’t know why they don’t fix it.

You will have replace every include for Wire.h with:

#if defined(__AVR_ATtiny84__) || (__AVR_ATtiny2313__) || defined (__AVR_ATtiny85__)
#include "TinyWireM.h" // include this if ATtiny84 or ATtiny85 or ATtiny2313

#define Wire TinyWireM
#else
   #include <Wire.h>
#endif

Put this in your sketch, and in the library lcd .cpp and .h files in place of the include for Wire.h
That should kludge it up enough to get it to work.
And after this “fix” it should work with Wire for non tiny cores, and with TinyWireM with the tiny core.

— bill

Well… I did get a few errors after your suggested edit,
Read somewhere that replacing Wire.write with Wire.send, and Wire.read with Wire.receive in the LCD library files would clear that up, and it did, then i ran into a new error

‘TWBR’ was not declared in this scope
TWBR = ((F_CPU / frequency) - 16) / 2;

So i removed your edit from the sketch itself (left it intact in the LCD library cpp and h files)

After doing that, i didn’t see any errors when checking, or uploading the sketch, however, the LCD still just shows two blank lines, and two filled lines in alternating pattern.

In all honesty, it’s not really critical that this issue gets resolved for myself. However, it would be nice to get it solved, just in case someone else runs into it, and either doesn’t have, or can’t afford to throw a full arduino type board at it.