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.
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.
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?
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?