I2C on attiny85 works with My OLED but not with I2c_ 1602

trying to get attiny85 I2C to work on 1602 LCD but arduino will not compile ?I have tried several things
still no success ?

I Have the rite libraries so I do not understand Here is my error

Arduino: 1.8.2 (Windows 10), Board: "ATtiny25/45/85, Enabled, CPU, ATtiny85, 8 MHz (internal), B.O.D. Disabled"


   TWBR = ((F_CPU / frequency) - 16) / 2;

   ^

Multiple libraries were found for "LiquidCrystal_I2C.h"
 \avr\libraries\Wire 
Using library LiquidCrystal_I2C in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal_I2C (legacy)
Using library TinyWireM-master at version 1.0.0 in folder: C:\Users\Brandon\Documents\Arduino\libraries\TinyWireM-master 
exit status 1
C:\Program Files (x86)\Arduino\hardware\ATTinyCore-master\avr\libraries\Wire\Wire.cpp:85:3: error: 'TWBR' was not declared in this scope

   TWBR = ((F_CPU / frequency) - 16) / 2;
Error compiling for board ATtiny25/45/85.

can anyone help please ?

good night folks

UPDATE…i got it to compile now nothing shows Im using 10k pullups on SDA & SCL but nothing …well the screen
blinks LOL and thoughts on that

well i was able to get some what looks like Chinese ?still not working as I would like could someone give me some good info on this ?

well here is my code ?
for Chinese

#include <TinyWireM.h>                 
#include <LiquidCrystal_I2C.h>         

LiquidCrystal_I2C lcd(0x27,16,2);  // set address & 16 chars / 2 lines
// pin 5 (SDA) and pin 7 (SCL) 
int LED=PB3;

void setup()
{
  
  pinMode(LED,OUTPUT);

}

void loop()

{
  TinyWireM.begin();                    // initialize I2C lib
  delay(20);
  lcd.init();                           // initialize the lcd 
  lcd.backlight(); 
  lcd.setCursor(0,0);
  lcd.clear();  // Print a message to the LCD.
  lcd.print("Attiny85");
}

That LiquidCrystal_I2C library has hard coded pin mappings between the PCF8574 chip and the LCD.
If the backpack being used uses a different pin mapping, you will get results like you are seeing.
I'd try the backpack/LCD using that same library on an UNO or some other Arduino board and see if works.
This will help isolate the problem. If it doesn't work on an Arduino board, then the issue is likely that the particular backpack that you have does not work with that library.

--- bill

well i got arduino to finally compile and upload to the attiny85 now but my screen just flickers
I triple checked the librarys so now Im still working on this trying to figure out what is going on
i have several LCD's 2004 & 1602 i made sure the addresses are correct also... Im still working on it

You should take Bill's advice and get it working on Uno/Nano/Mega first. Then you will have code/knowledge to make it work on the tiny85.

You may need to use a sketch known as the "i2c LCD guesser". This will help you establish the correct line of code to initialise your display+i2c adaptor. They are not all the same. Try following these instructions.

PaulRB:
You may need to use a sketch known as the "i2c LCD guesser". This will help you establish the correct line of code to initialise your display+i2c adaptor. They are not all the same. Try following these instructions.

That is only useful if using a library that allows configuring the PCF8574 to HD44780 signal pin mapping such as fm's newLiquidCrystal.
That does not appear to be the library that is being used.

--- bill

bperrybap:
That is only useful if using a library that allows configuring the PCF8574 to HD44780 signal pin mapping such as fm's newLiquidCrystal

Dang. @bandmwhitt2013 you may need to swap to another library.

this is true …do you guys know a good library to use for attiny I2C LCD I have several 20x4 and 1602
I have tried two 1602 lcds that i know work so I guess a new Library could be the next step

Which library to use for hd44780 backpacks, you ask? my hd44780 library package, of course… :slight_smile:
hd44780 can be installed using the library manager.
I’ve written about it in many in various forum posts.
You can read more about the library on the github page here:

While it does work with soft i2c libraries, how to make it work really isn’t documented yet so here is a small example:

#include <TinyWireM.h> // SDA=PINB0, SCL=PINB2
#define Wire TinyWireM
#include <hd44780.h>
#include <hd44780ioClass/hd44780_I2Cexp.h>
hd44780_I2Cexp lcd; // declare the lcd object and let it auto-configure everything.

int istatus;
void setup()
{

  istatus = lcd.begin(16,2);
  if(istatus)
  {
 // LCD initalization failed.
 // handle it anyway you want
 if(istatus < 0)
 istatus = -istatus;
 lcd.fatalError(istatus); // blinks error if LED_BUILTIN is defined
  }
  lcd.print("Hello, World!");
}

void loop() { }

One BIG gotchya is that there is bug in the TinyWireM library (That I just spent an hour tracking down), that you must fix in order for this to work.
I have created an issue to tell Adafruit about it and how to fix it.
Here is the link to the issue:
https://github.com/adafruit/TinyWireM/issues/7

If you make that correction, the above example should work.
I tested it on an attiny85 clocked @8mhz.

I haven’t optimized it at all yet for small environments, so in the future their may be some options that allow reducing the codesize footprint.

— bill

that is great ..could you tell me what library's I need to get and post a hello world sketch I have been trying everything... im getting nowhere at the speed of light

i tried that sketch and I get this

Arduino: 1.8.2 (Windows 10), Board: "ATtiny25/45/85, ATtiny85, Internal 8 MHz"

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Brandon\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Brandon\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Brandon\Documents\Arduino\libraries -fqbn=attiny:avr:ATtinyX5:cpu=attiny85,clock=internal8 -ide-version=10802 -build-path C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468 -warnings=default -build-cache C:\Users\Brandon\AppData\Local\Temp\arduino_cache_855319 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Brandon\Documents\Arduino\I2C_ATtiny85_LCD\I2C_ATtiny85_LCD.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -hardware C:\Users\Brandon\AppData\Local\Arduino15\packages -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -tools C:\Users\Brandon\AppData\Local\Arduino15\packages -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Brandon\Documents\Arduino\libraries -fqbn=attiny:avr:ATtinyX5:cpu=attiny85,clock=internal8 -ide-version=10802 -build-path C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468 -warnings=default -build-cache C:\Users\Brandon\AppData\Local\Temp\arduino_cache_855319 -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.arduinoOTA.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Brandon\Documents\Arduino\I2C_ATtiny85_LCD\I2C_ATtiny85_LCD.ino
Using board 'ATtinyX5' from platform in folder: C:\Users\Brandon\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2
Using core 'arduino' from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Warning: Board atmega-breadboard-master:avr:attiny84 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY84
Warning: Board atmega-breadboard-master:avr:attiny45 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY45
Warning: Board atmega-breadboard-master:avr:attiny85 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY85
Warning: Board atmega-breadboard-master:avr:attiny44 doesn't define a 'build.board' preference. Auto-set to: AVR_ATTINY44
Detecting libraries used...
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10802 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Brandon\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8" "C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468\sketch\I2C_ATtiny85_LCD.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10802 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Brandon\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8" "-IC:\Program Files (x86)\Arduino\libraries\TinyWireM" "C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468\sketch\I2C_ATtiny85_LCD.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10802 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Brandon\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8" "-IC:\Program Files (x86)\Arduino\libraries\TinyWireM" "-IC:\Users\Brandon\Documents\Arduino\libraries\hd44780" "C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468\sketch\I2C_ATtiny85_LCD.ino.cpp" -o "nul"
"C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++" -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics  -flto -w -x c++ -E -CC -mmcu=attiny85 -DF_CPU=8000000L -DARDUINO=10802 -DARDUINO_attiny -DARDUINO_ARCH_AVR   "-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino" "-IC:\Users\Brandon\AppData\Local\Arduino15\packages\attiny\hardware\avr\1.0.2\variants\tiny8" "-IC:\Program Files (x86)\Arduino\libraries\TinyWireM" "-IC:\Users\Brandon\Documents\Arduino\libraries\hd44780" "C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468\sketch\I2C_ATtiny85_LCD.ino.cpp" -o "C:\Users\Brandon\AppData\Local\Temp\arduino_build_467468\preproc\ctags_target_for_gcc_minus_e.cpp"
C:\Users\Brandon\Documents\Arduino\I2C_ATtiny85_LCD\I2C_ATtiny85_LCD.ino:4:43: fatal error: hd44780ioClass/hd44780_I2Cexp.h: No such file or directory

 #include <hd44780ioClass/hd44780_I2Cexp.h>

                                           ^

compilation terminated.

Multiple libraries were found for "TinyWireM.h"
 Used: C:\Program Files (x86)\Arduino\libraries\TinyWireM
 Not used: C:\Users\Brandon\Documents\Arduino\libraries\TinyWireM-master
Multiple libraries were found for "hd44780.h"
 Used: C:\Users\Brandon\Documents\Arduino\libraries\hd44780
 Not used: C:\Program Files (x86)\Arduino\libraries\hd44780-master
Using library TinyWireM in folder: C:\Program Files (x86)\Arduino\libraries\TinyWireM (legacy)
Using library hd44780 at version 0.5.0-a in folder: C:\Users\Brandon\Documents\Arduino\libraries\hd44780 
exit status 1
Error compiling for board ATtiny25/45/85.
Error downloading https://github.com/mistertwo/ozled-oled-display-096-i2c-driver-library.git
Invalid library found in C:\Program Files (x86)\Arduino\libraries\ATtiny85-LCD-library-master: C:\Program Files (x86)\Arduino\libraries\ATtiny85-LCD-library-master
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\arduino_601062: C:\Users\Brandon\Documents\Arduino\libraries\arduino_601062
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\arduino_777039: C:\Users\Brandon\Documents\Arduino\libraries\arduino_777039
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\arduino_831481: C:\Users\Brandon\Documents\Arduino\libraries\arduino_831481
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\LiquidCrystal_I2C: C:\Users\Brandon\Documents\Arduino\libraries\LiquidCrystal_I2C
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\Nokia_5110_Driver: C:\Users\Brandon\Documents\Arduino\libraries\Nokia_5110_Driver
Invalid library found in C:\Users\Brandon\Documents\Arduino\libraries\TinyWireM: C:\Users\Brandon\Documents\Arduino\libraries\TinyWireM

Please be patent with me i have mental issues from bad motorcycle wreck (Im here but not Here) ..Thank you for your help BTW

OK so I need only one new Library hd44780_I2Cexp.h Rite ?

A couple of issues.
You need to properly install the latest versions of the TinyWireM library and the hd44780 library.
It looks like TinyWireM was installed more than once and at least one install was done manually and was not installed properly. (so you have it installed twice)
And it looks like you installed a VERY old version of hd44780.
Both can be installed using the IDE library manager.
My recommendation would be to remove both libraries and re-install them.
Unfortunately, because the Arduino team has not implemented a way to remove libraries from the IDE GUI, you will need to do it manually.
Which means removing both directories for the two TinyWireM installations and the directory for hd44780 installation. You can see the directories that need to be removed in the compile output.

And then reinstall each one (TinyWireM and hd44780) using the IDE library manager so you get the latest versions installed properly. Installation is super easy using the IDE library manager.
Use the library manager which will pull the latest version from the github repository.
Just search for the library and then click the button to install it. It is just that easy.
Do not use a zip file and try to import it using the zip file import. The directory name created will be wrong because of the goofy naming that github does on its zip files and the IDE zip import does not correct it.

You can read the hd44780 github page referenced earlier and it has installation instructions.
You can also read about library installation and how to use the library manager on the Arduino site here:
https://www.arduino.cc/en/guide/libraries

After they are correctly installed, in the future you can simply update them using the IDE library manager rather than have to remove them and re-install them.

--- bill

I just noticed it looks like hd44780 was also installed more than once.
So make sure to remove both hd44780 directories before you re-install it using the IDE library manager.

--- bill

Oh and don't forget that you must go do the modification to the TinyWireM library to fix the bug as pointed out in response #11

Thank you bperrybap i will study what you have said and will work on it till I get it ....i have worked on this
exclusively for the past three days i have a bunch of Megas that can easily do what i want but I am trying
for small size ...