1602 LCD I2C problem

Hi everybody,I use the library on “TextLCD.h”. It can built, but LCD didn’t print “hello Mbed”. I have some question for the LCD Controller Device, Where can i find LCD Controller Device type? The other question is "What kind of the bit in I2C for LCD? "( 7 bit or 8bit). thanks


These information are usually in a product data sheet, but with products from china where are some ICs clones it can be different

  • I use this TextLCD and also this useful guide about all things around it
  • also take care about correct setting in TextLCD_Config.h . My i2c to parallel bridge looks same and i use settings for DFROBOT (TextLCD_config.h lines 70-80) and the address you will found in example below (also macro from TextLCD_config line 447).
  • set correct contrast with potentiometer
#include "mbed.h"
#include "TextLCD.h"

DigitalOut led(LED1);
I2C i2cBus(I2C_SDA, I2C_SCL);
TextLCD_I2C lcd(&i2cBus, PCF8574A_SA7, TextLCD::LCD16x2);

int main(){
    printf("LCD test\n");
    lcd.printf("LCD hello\n");


    while(1) {
        led = !led;

Just for sure you can use a I2c scanner code for obtain real i2c address

#include "mbed.h"

I2C i2c(I2C_SDA , I2C_SCL ); 

int main() {
    printf("\nI2C Scanner");
    while(1) {
        int error, address;
        int nDevices;
         nDevices = 0;
        for(address = 1; address < 127; address++ ) 
            error = i2c.write(address << 1); //We shift it left because mbed takes in 8 bit addreses
            if (error == 1)
              printf("I2C device found at address 7bit: 0x%X 8bit: 0x%X\n", address, address << 1);

        if (nDevices == 0) printf("No I2C devices found\n");
        else printf("done\n");
        thread_sleep_for(5*1000);           // wait 5 seconds for next scan

BR, Jan

I use PCF8574T to LCD, and it address is 0x27.
“TextLCD_I2C lcd(&i2cBus, 0x27, TextLCD::LCD16x2);” Is it correct?


if your address is correcnt, then it is correct, but 0x27 seems to be 7bit so you need to shitf it because Mbed I2C API use 8bit format, just try it like this

TextLCD_I2C lcd(&i2cBus, PCF8574_SA7, TextLCD::LCD16x2);
// or
int address7bit = 0x27;
int address = address7bit << 1
TextLCD_I2C lcd(&i2cBus, address, TextLCD::LCD16x2);

BR, Jan