Need Code for ESP32 to 4004 Character LCD Module with I2C Interface

That's likely just luck and subject to change with conditions. If the display board does not include the pullups, you must add them.