How detect LCD module size by programming

Hello there,

I need to create an LCD tester for different LCD sizes but I would like to politely know, please is there any possibility to detect what is the LCD connected on Arduino (like if is 16x2 or 20x4...) by programming? I mean, for example, if I connect a 16x2 LCD on Arduino Uno the display prints "16x2" then print the messages that do not exceed the maximum number of characters that will fit on this display and when I connect a 20x4 the display prints "20x4" then write the messages to this size and, so on.

Thank you!

Look at the manual for the LCD controller chip to see if provides that information. I don't think it does so there may not be a way to get the information from the LCD.

Maybe use a button or switch to select the LCD type before testing? Maybe build a separate tester for each type?

Here is the data sheet for the hd44780 LCD controller. That controller is used on the 1602 (16x2) and 2004 (20x4) LCD boards.
I found no hint that what you want to do is possible.

How are you identifying the interface? There are, commonly, the 4 bit parallel or I2C (PCF8574) and rarer, SPI and MCP23008 based I2C interfaces.

Thank you, guys.
I am identifying the interface using the 4-bit parallel. I found no information in the datasheet about it.

It is not possible to identify the geometry in software.

However, you can draw a suitable "box" or graphic that will allow a human to immediately recognise a 16x2 or 20x4 or whatever.

Fairly pointless when you can just tell a 4-line by its shape.
But it will help with distinguishing a 16x4 from a 20x4.
Or a 20x2 from a 16x2.


That is not relevant.

The only difference between a 1602 and a 2004 display is additional "slave" chips, but these are simply "daisy chained" with data flowing unidirectionally from one to the next so the controller does not recognise how many are following.

My idea was basically to test displays regardless of the geometry by printing a text that fits on it one and using only one Arduino board, so I wouldn't have to configure the display geometry and compile it every time I changed the display. The idea was to change only the hardware, changing only the wires or having a cable for each different display... but it seems that it's not possible. The ideal, in this case, would be to make a tester for each display?

To set two parameters, compile & upload doesn't take so much time, do it?

As alternative you could introduce a start up menu on the LCD, where the user chooses 8x1, 8x2, 16x1 (A), 16x1 (B), 16x2,... by a simple button press.

It doesn't...
But I liked this alternative, so I will do it.
Thank you very much.

You can display 16x2, 20x4, ... etc.
The User selects which screen "looks" correct.
The program saves the selection in EEPROM.

Subsequent runs will use the selected geometry stored in EEPROM.
You compile once. The User configures once. Job done.

All that it needs is the user to press a button or tick a box if something "looks wrong".
99.9% of runs will just start and "look ok".


Sorry if I miss any information, I didn't get how to do this. Could you explain it, please?
How to set up the lcd.begin(LCD_COLS, LCD_ROWS) function saving the selection in EEPROM?


This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.