Arduino + HD44780 I2C + lcdproc

Hi all!

My together project Arduino + HD44780 with I2C (PCF8574N) and lcdproc/lcdsmartie software does not work! :frowning:
The I2C LCD example is work with the new liquid driver and good configuration in lcdproc (I think).

Generates the following: Led blinking, and LCD works but nothing words and graphics. :frowning:
My LCD driver is LiquidCrystal_I2C V2.0

Here my code:

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>

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

void setup() { 
  Serial.begin(9600);  

  lcd.init();                      // initialize the lcd 
  lcd.backlight();
  lcd.print("LCD Proc");
}

byte serial_getch(){

  int incoming;  
  while (Serial.available()==0){
  }
  // read the incoming byte:
  incoming = Serial.read();

  return (incoming &0xff);
}

void loop(){

  byte rxbyte;
  byte temp;

  rxbyte = serial_getch(); // Fetch byte

  if(rxbyte==0xFE) // If command 
  { 
    lcd.command(serial_getch()); // Pass through
  }
  else{
    lcd.write(rxbyte); //Otherwise just dump it as text
  }
}

What is wrong? What i do not notice? 3 days ago of these convulsions :frowning:
Please help me!

Thank you everybody!

There are many different LiquidCrystal_I2C libraries.
They are not all the same. Some allow configuring how the PCF8574 pins are mapped to the hd44780 display and some hard code the pin mappings.
This can be an issue since not all i2c hd44780 backpacks wire up their output port pins the same way to the hd44780 display.

As an alternative, I would recommend my hd44780 library package.
It is available in the IDE library manager so it can quickly and easily be installed from the IDE gui using the library manager.
It can auto detect everything, the i2c address, the pin mappings, and the backlight control.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library

The github page contains information about the library including installation instructions.
Use the IDE library manager as it is easier and faster than trying to do it manually or using the zip install.
Also, by using the IDE library manager it ensures that the library is installed properly not to mention that you will also get the latest tested version of the library.

The library package includes support for several different i/o interfaces.
Each i/o interface has its own i/o class.
The i/o class you will want to use for that backpack which contains an i2c i/o expander chip is hd44780_I2Cexp
That i/o class includes a diagnostic sketch (I2CexpDiag) which will test the i2c signals and internal RAM of the LCD module to verify that the the library is properly communicating with the LCD module.
It is useful to first run this sketch to verify that the library is properly talking to your backpack and LCD module.
Read the instructions in the sketch for how to run it and what to expect on the serial monitor.

After running the diagnostic sketch, you can run and look at other sketches for the hd44780_I2Cexp i/o class like the HelloWorld sketch to see what header files need to be included and how to declare the lcd object.

The library package includes an lcdproc sketch that you can use or modify for your particular display size.

The hd44780 library contains additional capabilities not available in other libraries like

  • ability to read the display RAM or LCD status
  • return status to tell if API functions are not working correctly (usually do to i2c communication issues)
  • ability to enable automatic line wrapping
  • faster than other libraries as Arduino can run in parallel with LCD commands/instructions
    This extra speed is good when using the display for something like lcdproc.

The library will also properly honor the lcd command timing when doing raw commands to ensure that sketches like lcdproc which use this capability do not ever overrun the display or corrupt the 4 bit host interface.
Other libraries do not do this.

I would recommend first running the diagnostic skech I2CexpDiag to verify that everything is working, then you can run and look at the other examples included in the hd44780_I2Cexp i/o class (like HelloWorld) to see the what header files need to be included and how to declare the lcd object.

--- bill

Bill's hd44780 library works quite good. I tinkered with Bill's library and also with Francisco Malpartido's NewLiquidCrystal library. I wrote an article for beginners (that's what I am myself - helping my comrades in arms!).
Here is the link: http://www.zonnepanelen.wouterlood.com/arduino-bare-basics/2-using-the-i2c-expander-for-16x2-and-20x4-lcd-displays/

cheers

interesting write up. I would comment on that web page but I don’t see a way to do so.
Some comments:

  • A4 and A5 for SDA and SCL is only for the UNO board. Other boards use different pins which is why there are now SCL and SDA pins on the headers next to AREF.

  • external pullup resistors on SCL and SDA signals are ALWAYS required.
    The I2C bus uses open drain signals and the only way to get a high signal is from the pullups.
    While it is sometimes possible to get away without using them when using a processor like the Atmega328 as the Wire library enables the internal pullups on the SCL and SDA pins, when doing so the i2c bus is way out of spec and is prone to having issues.
    The I2CexpDiag sketch included in the hd44780 library hd44780_I2Cexp i/o class will test for external pullups.
    This is a good thing to verify as some i2c LCD backpacks have them on the backpack, some don’t and some Arduino boards like the Mega2560 boards include them on the Arduino board, while boards like the UNO do not.

  • FM’s library is not called “LiquidCrystal_I2C”, fm’s library, just like hd44780, is a library that includes multiple sub i/o classes. There is a base class and then i/o classes for each h/w interface used to communicate with the LCD. In the case of fm’s library it is actually called “New LiquidCrystal” but when it is installed properly it replaces the Arduino IDE built in bundled LiquidCrstal library so as far as the Arduino IDE is concerned, it is called “LiquidCrystal”. It includes an i/o class called LiquidCrystal_I2C which has a corresponding header named LiquidCrystal_I2C.h

  • I do not recommend that people download and install the hd44780 library themselves, especially from places other than the original duinowitchery hd44780 github repository. In fact I highly discourage it because it is error prone.
    I encourage people to use the IDE library manager to install the hd44780 library as it is much easier, faster and simpler to use the IDE library manager built into the Arduino IDE GUI to install the hd44780 library. The IDE library manager also guarantees that the library is an official released and tested version that it is installed properly.
    fm’s New LiquidCrystal can not be installed using the IDE library manager since it replaces the IDE bundled library. Because of this it must be manually installed. hd44780 is easier to install since it can be installed using the library manager.

  • The pin mappings shown for fm’s library example may or may not work with a users backpack.
    The constructor:

LiquidCrystal_I2C lcd(0x3F, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address

does a lot more than set the i2c address. It also configures the pin mappings used as well as the backlight control active level.
Different backpacks use different pin mappings and if the mappings are incorrect, it will not work.
Years ago I write a tool that you might find floating around on the Arduino forum that can be used to help guess the pin mappings for fm’s LiquidCrystal_I2C i/o class.
When I wrote the hd44780 library, I took things to the next level and wrote code that can auto detect the PCF8574 backpack pin mappings.
This is one of the big advantages of the hd44780_I2Cexp i/o class, in that it can automatically figure these things out for you.

  • lcd.clear() clears the entire display
    There is an odd looking loop in the examples:
for (int j=0; j<4; j++){
lcd.setCursor(00,j);
lcd.clear(); // clears the line where the cursor is positioned
}

This will loop 4 times, and each time position the cursor and clear the entire LCD display.
The comment does not match what the code is doing.

— bill

Big thanks the all solution! Great, my project is worked the HD44780 I2CExp schema and must needed litle modify! Now all printed datas! :slight_smile: Huh, its was not easy but succeeded!
I did not know I needed it LCD backpack. But the LCD detect in HD44780Exp do not always succeed: reset-reset-reset-OK-reset-reset-OK ...

My code is work:

hd44780_I2Cexp lcd ({0x20}, I2Cexp_PCF8574, 4,5,6,0,1,2,3,7,LOW);

One more time THANKYOU!

Regards!

  1. Are you saying that the auto detect does not work correctly?
    There are a few backpacks that have a flawed backlight circuit that can cause the auto detection to not work correctly. These backpacks are not common.

  2. Are you using a pre-made backpack or have you wired up the PCF8574 chip yourself?
    That pin mapping is only used on one device I've seen the ElectroFun LCDxio board.
    That backpack can use a pre-defined entry:

hd44780_I2Cexp lcd (I2Cexp_BOARD_LCDXIOnBL);

or

hd44780_I2Cexp lcd (0x20, I2Cexp_BOARD_LCDXIOnBL);

If you want to hard code the i2c address to 0x20 vs auto locate it.

  1. What does the diagnostic sketch report?
    Are the pullups in place? Does it locate the i2c address? Does it report the proper pin mappings?
    Please post the output from the diagnostic sketch.

  2. Can post photos of your backpack? and your LCD?
    So that I can see the backpack PCB and back of the LCD module.

I want to understand why it is not working correctly on your device.
If you could respond to the 4 questions I posted above, it would be helpful.

--- bill

Dear Bill!

Your code is work and my latest post my modify code is ok but the lcdrpc run after obscure/ghosted! :frowning:

LCD: HD44780 1602A V2.0 (16x4)
I2C chip: PCF8574N and I2C detect 0x20

Where to find the bug? :frowning:

Before start lcdproc:

After start lcdproc:

Thank you!

I need you to answer the questions and post the information I asked for in post #5
--- bill

I2CExpDiag: 0x20? LCD:0 :o What? But HD44780 16x2

You had said that the auto detect was not working but based on what is on the LCD display, I do not see any issues.

In order to get the information on the LCD display in the photos, the library properly located the i2c address of the backpack and its pin mapping information and is displaying the expected information.
Based on that, I do not see the need for having to specify the i2c address, pin mapping parameters and backlight information in the constructor like you showed in post #4 as auto detect seems to be working as expected.

With respect to the “LCD:0” on the display, the ‘0’ is the instance of the LCD display as it is possible to hook up more than a single LCD. It represents the instance number of the LCD which can be from 0 to 15 as 16 devices is supported.

If there are still issues please describe them and then
I will need to get the answers to the 4 questions I asked in back in post #5.

But based on what I’m seeing on the LCD display in post #8, there does not seem to be any issues with the library.

— bill

It's a little curiosity:

The LCD Smartie perfect run in Windows and work BUT only seetron.dll driver. I tried many driver but order not working, order confused in lcd characters in linux. I use latest lcdproc software. HD44780 driver in lcdproc is bad? Why do you this to me? :frowning:

I have no idea what hd44780 library code & lcdproc you are running.
You have not answered the questions I asked back in post #5. I asked again in post #7 and post #9 still no answers.

You said auto detection was not working, but the LCD display screens in post #8 show that auto detection is working correctly.

The lcdproc display shown in post #6 is not from the latest hd44780 library code.
But since you have never provided the information I asked for back in post #5 I have no idea what version of hd44780 you are using.

From what I can tell the library and the examples are working correctly.
I sounds like you have are having some sort of configuration issue with the lcdproc on your machine.
Maybe it is something as simple as a buadrate mismatch.

Sorry but without more information, I simply cannot help.

--- bill

Thank you! I change baud rate 9600 to 115200 and works it now, but continuosly scroll right the text. I do not believe it, what is wrong again in LcdProc? I change and variation many options in LCDd.conf. I use example lcdproc in HD44780.

Thank you!

LCDd.conf

## This file was written by cme command.
## You can run 'cme edit lcdproc' to modify this file.
## You may also modify the content of this file with your favorite editor.


[server]
Driver=hd44780
DriverPath=/usr/lib/x86_64-linux-gnu/lcdproc/
NextScreenKey=Right
PrevScreenKey=Left
ReportToSyslog=yes
ToggleRotateKey=Enter

[hd44780]
Backlight=no
CharMap=ea_ks0073
ConnectionType=lcdserializer
DelayBus=true
DelayMult=2
Device=/dev/ttyACM0
KeyMatrix_4_1=Enter
KeyMatrix_4_2=Up
KeyMatrix_4_3=Down
KeyMatrix_4_4=Escape
Keypad=no
Lastline=yes
OutputPort=no
Port=0x20
Size=16x2
Speed=115200

[menu]
DownKey=Down
EnterKey=Enter
MenuKey=Escape
UpKey=Up

[UPDATE]

I reset Arduino and after fine works!
I finded in lcdproc the bug!
Thanks!