Go Down

Topic: LCD 20x4 on ATTiny85 I2C problems (Read 2 times) previous topic - next topic

Keith Brown

Can some one tell me how to setup an ATiny85v to run a 20x4 LCD with an LCM1602 IIC V1 backpack?

I've downloaded and tried about 6 different Libraries. None seem to work.

SDA = Attiny85 pin 5 with pull up
SCL =  Attiny85 pin 7 with pull up
VCC = pin 8
GND = pin4

One of the problems is I don't know the I2c address and I cant seem to run the scanner on the tiny. When I setup the display on a Nano or a DueMilenove the address is 0x27. the backpack is running a PCF8574T.

Do I have to set any fuses or anything special first?

I've been googling and reading this forum all day and nothing seems to work for me. Any suggestions?

Thanks for your  help.

mrburnette


Keith Brown


This link may assist:
http://forum.arduino.cc/index.php?topic=183924.15




This is the first article I read and the first library I downloaded. No luck! Thanks though

n1spx


One of the problems is I don't know the I2c address and I cant seem to run the scanner on the tiny. When I setup the display on a Nano or a DueMilenove the address is 0x27. the backpack is running a PCF8574T.


The address of the backpack should be the same regardless of which uC you are using to talk to it.

HugoPT

#4
Feb 21, 2014, 07:21 pm Last Edit: Feb 21, 2014, 07:23 pm by HugoPT Reason: 1
Where did you get that board?
There are some Chinese ebay boards using the PCF8574T with the pins swapped and so you can't use the original library for it.
I have one of this Chinese board and my address is 0x20.
Here is the library for the Chinese version.
Remember, you must remove from the libraries folder the older one and  insert this new one.
Post results
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Keith Brown

ok the chinese library worked for my ...milenove, but the char display acts as a 16x2 and not a 20x4 even is i try to print to the other char positions the 16x2 positions only print...

my address is 0x27 according to the i2c_scanner.

any suggestions on how to use the full display?

HugoPT

Quote
but the char display acts as a 16x2 and not a 20x4 even is i try to print to the other char positions the 16x2 positions only print...

Did you specify the size in:
Quote
LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 20 chars and 4 line display
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Keith Brown

This is my code and attached is the output.

Code: [Select]
//YWROBOT
//Compatible with the Arduino IDE 1.0
//Library version:1.1
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27,20,4);  // set the LCD address to 0x27 for a 16 chars and 2 line display

void setup()
{
  lcd.init();                      // initialize the lcd
  lcd.init();
  // Print a message to the LCD.
  lcd.backlight();
  lcd.setCursor(3,0);
  lcd.print("Hello, world!");
  lcd.setCursor(2,1);
  lcd.print("Ywrobot Arduino!");
   lcd.setCursor(0,2);
  lcd.print("Arduino LCM IIC 2004");
   lcd.setCursor(2,3);
  lcd.print("Power By Ec-yuan!");
}


void loop()
{
}

HugoPT

Thats very wierd since I have a chinese board like your and a LCD 20x4 and I'm sure it displays all the characters correctly.
When I get home I will try your code with mine to double check that.
Looking to your code I just have one thing to ask
Why are you initializing the lcd two times?
Quote

lcd.init();                      // initialize the lcd
 lcd.init();
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Keith Brown

the two init(); are in the example. I thought it was weird too...

in any case i just got another SainSmart 20x4 in the mail (just now); hooked it up and it works fine.

is there a way to fix the other one? replace a resister/component?

HugoPT

Are the second LCD same brand and model?
Debian,Mint,Ubuntu
Arduino Mega 2560
Arduino Nano
Arduino Duemilanove
MAC OS Montain Lion
Raspberry PI Model B

Keith Brown

there is  no brand on the other one

kowalski

#12
Mar 07, 2014, 02:24 pm Last Edit: Mar 07, 2014, 03:04 pm by kowalski Reason: 1
Did you use external pullup resistors? The internal are too weak on the ATtiny. Some I2C LCD adapter modules do not have them at all and require external.

Please see https://github.com/mikaelpatel/Cosa/issues/86


More info on http://cosa-arduino.blogspot.se/2013/07/object-oriented-lcd-management.html

Cheers!

Keith Brown


Did you use external pullup resistors? The internal are too weak on the ATtiny. Some I2C LCD adapter modules do not have them at all and require external.

Please see https://github.com/mikaelpatel/Cosa/issues/86


More info on http://cosa-arduino.blogspot.se/2013/07/object-oriented-lcd-management.html

Cheers!



Thanks for the info!
do you have a simple sample sketch?
When working with the 85 do you call pin 5 or Pin 0?

Thanks again for your help

kowalski

#14
Mar 07, 2014, 04:02 pm Last Edit: Mar 07, 2014, 04:26 pm by kowalski Reason: 1

do you have a simple sample sketch?
When working with the 85 do you call pin 5 or Pin 0?

First of all I need to explain that Cosa is an object-oriented platform for Arduino with over 100+ classes. It is an Arduino core but supports all AVR processor based boards plus ATtiny and Mighty. It is also stand-alone and does not depend on any Arduino code more than the IDE build process.

The simplest example sketch is the LCD hello world that I use for footprint benchmarking.
https://github.com/mikaelpatel/Cosa/blob/master/examples/LCD/CosaLCDsize/CosaLCDsize.ino

The pin-out is described in the Board description file for ATtiny.
https://github.com/mikaelpatel/Cosa/blob/master/cores/cosa/Cosa/Board/TinyX5.hh#L41
Pins in Cosa are symbols, e.g. Board::D0 instead of integers as in Arduino/Wiring.

You can basically develop on Mega, Uno, etc, and simply select ATtiny85 and compile-and-burn with more libraries than in any other Arduino package. SPI, TWI, 1-Wire etc are all support. LCD support is an abstract class that is implemented for HD44780, PCD8544, ST7565. The HD44780 driver also has an adapter layer for 4-bit parallel, Shift Register 3-wire (Pin or SPI), Shift Register 4-wire and a whole range of different I2C adapters. You can see how the configuration works in the CosaLCDsize sketch above.

Cheers!

Mikael

Go Up