avr_fred:
Yes, the parts you selected are the same.
Actually there is no way to know if the i2c lcd backpack matches the one used in the project.
There are many different vendors that make these backpacks and they are not all made the same way.
Many can look the same even when they are not.
The project code appears to be using fm's newLiquidCrystal library so it can work with any of them; however,
if the i2c backpack does not exactly match the one used in the project, the project sketch code will have to be modified to match the backpack being used.
These things can change:
i2c address, pin mapping, backlight control.
The parameters to the LiquidCrystal_I2C constructor provide this information to the library.
If the parameters are incorrect for the specific backpack being used, it will not work.
While not terribly difficult to figure out it can be a real challenge depending on a persons technical expertise.
As an alternative, I'd recommend using my hd44780 library package instead.
It can quickly and easily be installed using the IDE library manager.
It auto-detects everything so it is much easier to use. It will automatically detect the i2c address, pin mapping and backlight control active level.
This allows to you use any cheap i2c lcd backpack and not care about its i2c address or how it is internally made and wired up to the lcd signals or backlight.
It is also faster than the other i2c backpack libraries.
You can read more about it here: GitHub - duinoWitchery/hd44780: Extensible hd44780 LCD library
The i/o class for i2c backpacks is called hd44780_I2Cexp.
It includes examples including a diagnostic sketch (I2CexpDIag) that will test your i2c signals and the internal LCD RAM to make sure that the library and lcd device are properly communicating.
The modifications to the project sketch code are very minimal.
You will need to make come some changes and fix a few bugs that are in that code as well.
In fact most of the changes are because the sketch code has some bugs in it.
For example, the code is using the old constructor which requires using the obsolete lcd.setBacklightPin() pin function.
With the proper constructor declaration, this is not necessary.
Also,
lcd.setBacklight(HIGH);
is just plain wrong.
setBacklight(dimlevel) is for setting dimming level.
Since HIGH is set to 1, setBacklight(HIGH) asking the device to set the backlight level to 1 which is as dim as possible.
In this case, it is only working because the library made the decision to turn on the backlight when dimming was asked for when dimming is is not supported.
My suggesting is to fix the code to use the proper constructor and API function calls, even if you don't use my hd44780 library.
But of course my recommendation would be to switch to hd44780 and get an easier to use solution that is also faster.
To switch to hd44780 all you have to do is:
-
change the header files included to use the two hd44780 header files.
-
change the constructor to a simpler one for hd44780_I2Cexp that will never change for any backpack
-
only use lcd.begin(cols, rows) for initialization.
-
use backlight(), noBacklight() if you want to turn backlight on/off.
begin() will automatically turn the backlight on.
See the included examples for the hd44780_I2Cexp i/o class for which header files to use and how to declare the lcd object.
--- bill