Trying I2C LCD 16x2 HD44780 1602A PCF8574T on KL25Z

Hi guys,
Im trying to print a “Hello World!” on my new LCD 16 x 2 HD44780 1602 with my KL25Z:


Using I2C i2c_lcd(PTE0,PTE1)

My “main.cpp” :

    /* Hello World! for the TextLCD Enhanced Library*/

#include "mbed.h"
#include "TextLCD.h"
 
// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx
 
// I2C Communication
I2C i2c_lcd(PTE0,PTE1); // SDA, SCL

// LCD instantiation 
TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD16x2, TextLCD::HD44780); // I2C exp: I2C bus, PCF8574 Slaveaddress, LCD Type, Ctrl Type

//“TextLCD Enhanced Test”

And my TextLCD_Config,h:

//Select Serial Port Expander Hardware module (one option only)
#define DEFAULT        0
#define ADAFRUIT       0
#define DFROBOT        0
#define LCM1602        1
#define YWROBOT        0
#define GYLCD          0
#define MJKDZ          0
#define SYDZ           0
#define WIDEHK         0
#define LCDPLUG        0

Actual state:

I think the problems maybe is something related with the chipsets: 1602A PCF8574T
When I use Slave Address: 0x4E Screen goes black
If I use Select Serial Port Expander Hardware DEFAULT 1 module display blink
Thanks!!! :smiley: :smiley: :smiley:

Hi Cristian,

It looks same like my expander from Aliexpress.

On the picture is not visible what is on display behind the green color but a fully filled first line = no communication.

I use this constructor and settings
TextLCD_I2C lcd (&i2cBus, PCF8574A_SA7, TextLCD::LCD16x2); // HD44780 is default
and in the TextLCD_Config.h file I use DFROBOT but I tried also with your LCM1602 and also is working.

BR, Jan

Is not working :frowning:
You are using KL25Z PTE0,PTE1 I2C ports?
The LCD display : AZDelivery HD44780 1602 LCD

Nope, I have only ST boards.

You can also verify your I2C connection and address with simple code bellow.

#include "mbed.h"

I2C i2c(I2C_SDA, I2C_SCL); 

int main(){
    printf("\nI2C Scanner running...\n");
    //i2c.frequency(400000);
    int error, address, nDevices;
    nDevices = 0;
    for(address = 0; address < 128; address++ ){
        thread_sleep_for(10);
        error = i2c.write(address  << 1, "1", 1);

        if (error == 0){
            printf("I2C device found at address 8bit: 0x%X 7bit: 0x%X\n", address, address << 1);
            nDevices++;
        }
    }
    if (nDevices == 0){
        printf("No I2C devices found\n");
    }else{
        printf("\ndone\n");
    }
}

BR, Jan


Adjusting the contrast on the blue box and

#include “mbed.h”
#include “TextLCD.h”

// Host PC Communication channels
Serial pc(USBTX, USBRX); // tx, rx

// I2C Communication
I2C i2c_lcd(PTE0,PTE1); // SDA, SCL

// LCD instantiation
TextLCD_I2C lcd(&i2c_lcd, 0x4E, TextLCD::LCD16x2);