TextLCD I2C problems

03 Jul 2017

Hello all,

My previous programming has only been Arduino and PIC assembler, I am completely new to mbed and I have some problems, I cant get it to display anything through I2C, it's not even setting it up for 4 lines, if i hook it up in parallel it works.

The I2C address with these pins grounded should be 0x20 and if I run I2C scanner it also shows 0x20.

The board im working with is:

ST NUCLEO-F446RE http://www.st.com/en/evaluation-tools/nucleo-f446re.html

The I2C I/O expander is this one: PCF8574 from NXP http://www.nxp.com/docs/en/data-sheet/PCF8574_PCF8574A.pdf (SO16)

The display is this one:

MC41605 http://www.farnell.com/datasheets/2021730.pdf

The schematic is here, It's how I interpreted the connections from the TextLCD_Config.h for the PCF8574 https://i.imgur.com/4NhV6ps.jpg

Here's my code

include the mbed library with this snippet

#include <mbed.h>
#include <TextLCD.h>

//Serial communication to PC
//Serial pc (USBTX, USBRX);

//I2C I2C Setup
I2C i2c_lcd (D14, D15);  // D14 = SDA, D15 = SCL 

//I2C TextLCD Setup
TextLCD_I2C lcd(&i2c_lcd, 0x20, TextLCD::LCD16x4);//LCD16x4, HD44780);

//Variables

 
//Loop 
int main(){
    
    while(1){ 
   // pc.printf("test");
    lcd.printf("test test\n");
            
  }
}

I hope some of you guys can help me out.. :)

11 Jul 2017

I too have no luck in getting an LCD to work using I2C. The LCDs I have are using PCF8574. I see examples in the program library but I can nothing to respond. I hope someone who has actually set this up can chime in and help.

19 Apr 2018

Timothy:

I think it is too late. Anyway 1.- The address should be 0x40 Could you take a look here: https://os.mbed.com/forum/mbed/topic/5307/

2.- In the library file TextLCD_Config.h Check the following

By default Select Serial Port Expander Hardware module (one option only)

  1. define DEFAULT 1
  2. define ADAFRUIT 0
  3. define DFROBOT 0
  4. define YWROBOT 0
  5. define GYLCD 0
  6. define SYDZ 0

that means

  1. if (DEFAULT==1) Definitions for default (WH) mapping between serial port expander pins and LCD controller This hardware supports the I2C bus expander (PCF8574/PCF8574A or MCP23008) and SPI bus expander (74595) interfaces See https://mbed.org/cookbook/Text-LCD-Enhanced Note: LCD RW pin must be connected to GND E2 is used for LCD40x4 (second controller) BL may be used to control backlight
  2. define D_LCD_PIN_D4 0 it should be 0
  3. define D_LCD_PIN_D5 1 it should be 1
  4. define D_LCD_PIN_D6 2 it should be 2
  5. define D_LCD_PIN_D7 3 it should be 3
  6. define D_LCD_PIN_RS 4 it should be 3
  7. define D_LCD_PIN_E 5 it should be 5
  8. define D_LCD_PIN_E2 6 it should be 6
  9. define D_LCD_PIN_BL 7 Not found
  1. define D_LCD_PIN_RW D_LCD_PIN_E2

By default these definitions should be fine so the only one modification is to change the address Try again Best Regards Pablo