20x4 LCD with attiny85?

Hello, I have tried and search for different Libraries to work on the attiny84 using the 20x4 lcd. So far none of them worked. So i gave up on it. Does anyone of where I can find a working library and sketch that I get to work please? 10 different ones I have tired and failed.

Joseph

Which "20x4 lcd" ?

On the back it says 2020/3/15 AR other place shows 2004A no other writing I can see. It has a back pack for i2C on it.

Joseph

Maybe you could post pictures?

99% of The ‘2004’ LCDs have the same interface and control electronics as every other.

The HD44780 chipset is everywhere…
I’m sure there is a model number somewhere on your display, and the I2C backpack will make it even easier for you to wire up.

It sounds you’re lacking that little bit of ‘get started’ knowledge to make things happen.

Wiring is not the problem. It works if I was using a uno board. However I'm using a attiny85 the backpack of the display interface is I2C. the problem I'm having is being on attiny the library and sketches I find online Doesn't work. It is not the wiring that is the problem.

Joseph

Are you supplying the display with 5V?

I have successfully used the hd44780 library by Bill Perry (@bperrybap) to run a 20x4 I2C backpack (with PCF8574 I2C expander) enabled LCD.

In addition I use the ATTinyCore core by Spence Konde to program the Tiny85. That core has a version of the Wire library that works with the hd44780 library. The default pins for I2C are pin 0 = SDA and pin 2 = SCL.*

For an I2C LCD display to work, the I2C address and the I2C backpack to LCD pin mapping must be correct. If the library default settings for either or both are not correct the LCD will not work. You can try to figure out the right pin mapping and use an I2C scanner to find the address, but if you install and use the hd44780 library that is done automatically by the library.

To install the hd44780 library. The hd44780 library is the best available for I2C LCDs. The library is available in the Library Manager. Go to Library Manager (in the IDE menus, Sketch, Include Libraries, Manage Libraries) and in the Topics dropdown choose Display and in the Filter your search box enter hd44780. Select and install the hd44780 library by Bill Perry.

The class that you want to use is the hd44780_I2Cexp class. There are examples to show how to use the library. The nice thing about the hd44780 library is that it will autodetect the I2C address and the I2C backpack to LCD pin mapping.

In the examples, there is a diagnostic sketch that will help us to help you if you still have trouble with the display. Run the diagnostic sketch and post the results.

Edited because the pin (1) was wrong as pointed out by @killzone_kid

1 Like

Try something here, otherwise there’s more your not saying…
L I N K

Hello groundFungus, Thank you I will try it out and give a update shortly.

Joseph

Here is a simple "Hello World" sketch that has been tested successfully with a 20x4 LCD using the ATTinyCore core and the hd44780 library. I2C pin connections as above (pin 0, physical pin 5 = SDA, pin 2*, physical pin 7 = SCL).

// hd44780 library see https://github.com/duinoWitchery/hd44780
// thehd44780 library is available through the IDE library manager
#include <Wire.h>
#include <hd44780.h>                       // main hd44780 header
#include <hd44780ioClass/hd44780_I2Cexp.h> // i2c expander i/o class header

hd44780_I2Cexp lcd; // declare lcd object: auto locate & auto config expander chip

// LCD geometry
const int LCD_COLS = 20;
const int LCD_ROWS = 4;

void setup()
{
   lcd.begin(LCD_COLS, LCD_ROWS);
   lcd.clear();
   lcd.print("Hello World");
   lcd.setCursor(0, 1);
   lcd.print("Millis ");
}

void loop()
{
   updateLCD();
}

void updateLCD()
{
   static unsigned long lcdTimer = 0;
   unsigned long lcdInterval = 500;  // update 2 times per second
   if (millis() - lcdTimer >= lcdInterval)
   {
      lcdTimer = millis();
      lcd.setCursor(8, 1);
      lcd.print("       "); // overwrite old data
      lcd.setCursor(8, 1);  // reset the cursor
      lcd.print(millis());
   }
}

The "Hello World" example that comes with the library has error reporting code so is a bit more complex.

*Edited because the pin (1) was wrong as pointed out by @killzone_kid.

Thank you. Trying it out now.

Joseph

The I2CexpDiag sketch currently will not work on the smaller AVR parts as it is too big to fit. It currently needs about 14-15k of flash on AVR parts like the M328/UNO boards.
While the Wire library code is smaller on the smaller AVR parts, I2CexpDIag is still too large to fit.
Yeah, I2CexpDiag is a code size hog.

--- bill

Is this for the library? Because the chip has SDA on 0 and SCK on 2

1 Like

And you are right. That is what I get for trusting my memory.

physical pin 7 = SCL

I had the right physical pin, though. Any points for that?

Don’t blame you, it is just that I had display hooked to it a few days ago so it’s fresh for me https://twitter.com/killzone_kid/status/1470392002114117633?s=21

Thank you all for helping me. I mange to get my display up and running. I have been trying to figure it out for a while and Got lost. It seems to be the wiring was not my problem but the libraries is the problem. I need to find a library that works now.

Joseph

I know that the hd44780 library works for tiny85.

(using ATTinyCore). Did you try it?

Hello, I never never heard of the Attinycore before. This is a first time. But I will look for it Thank you.

Joseph

The ATTinyCore core documentation can be seen here. ATTinyCore is available for install via the IDE boards manager in the Tools menu.

1 Like

Thank you very much groundfungus. Happy Holidays to you and your family. As well as to everyone in the Arduino community Happy Holidays to you and your family.

Joseph