8 years, 1 month ago.

My module has address 0x27 How I can configure i2c LCd

My module has address 0x27 How I can configure i2c LCd

Can you help please?

Question relating to:

1 Answer

8 years, 1 month ago.

I assume you want to use a PCF8574 I2C port expander to control the LCD.

The 7bit I2C slaveaddress for a PCF8574 is 0x20..0x27 depending on the three selectable addressbits for the device. Note however that the mbed libs use the 8bit format for I2C addresses, You should leftshift the 7bit address by one bitposition to get the 8bit address. That results in 0x40..0x4E again depending on the three selectable addressbits. So in your case (0x27), the slaveaddress in the parameterlist for TextLCD lib should be 0x4E.

You should also check the F302 platform page to identify the correct pins for I2C and make sure you have pull-up resistors installed.

//KL25Z example pins
//I2C i2c_lcd(PTE0,PTE1); // SDA connected to PTE0, SCL connected to PTE1

//F302 example pins
I2C i2c_lcd(PB_9,PB_8); // SDA connected to PB_9, SCL connected to PB_8

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

First thanks for your precise and quick reply. I used pull up resistors at SDA and SCL. I tried the above code with my code and it didn't work. Here is my code for review. The only thing I realised that the LCD is blinking and then nothing. Anymore help will be appreciated.Thanks in advance. My module chip is PCF8574T. The code is working when im using another LCD without I2C module.

KL25Z example pins I2C i2c_lcd(PTE0,PTE1); SDA connected to PTE0, SCL connected to PTE1

F302 example pins I2C i2c_lcd(PB_9,PB_8); SDA connected to PB_9, SCL connected to PB_8

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

int main() { lcd.printf("Hellow World!"); }

posted by Zaher Mohd 01 May 2016

Which LCD module type (and controller) are you using? Are you using 5V or 3V3 supply (note that some controllers dont work on 3V3 supply voltage. The I2C will however work on 3V3.

Which PCF8574 module are you using, note that many different types are found in (web)shops and they have different wiring between the I2C portexpander and the LCD. You may have to select a different expander module in the sourcecode of my lib. Do you get a blinking cursor after power-on? In that case the wiring is probably correct. If you see a blinking cursor the LCD contrast voltage is probably also correct. Does the cursor remain visible after printing Hello World or does the display go blank?

Check information on the TextLCD notebook here.

Please provide as much details as possible (code, schematic, pictures) or it will be difficult to assist.

posted by Wim Huiskamp 01 May 2016