LCD not seen by i2c-scanner sketch

I have not had this issue in the past but for some reason I cannot connect an LCD with i2c adapter to any microcontroller.

Here are a few shots to show LCD's recently working:

The above is of my test board.

This image is of an enclosure in a well house.

Recent Computer Changes
I did upgrade my MBPro OSx to Sonoma 14.2. It was after this that I began having this problem but I cannot prove that this was the cause of my LCD issues. I suspect it has nothing to do with this but I can not be certain of this.

Sketch
I have used the following sketch to try and connect with the LCD:

// I2C Scanner
// Written by Nick Gammon
// Date: 20th April 2011

#include <Wire.h>

void setup() {
  Serial.begin (9600);

  // Leonardo: wait for serial port to connect
 
  while (!Serial) 
    {
    }

  Serial.println ();
  Serial.println ("I2C scanner. Scanning ...");
  byte count = 0;
  
  Wire.begin();
  for (byte i = 8; i < 120; i++)
  {
    Wire.beginTransmission (i);
    if (Wire.endTransmission () == 0)
      {
      Serial.print ("Found address: ");
      Serial.print (i, DEC);
      Serial.print (" (0x");
      Serial.print (i, HEX);
      Serial.println (")");
      count++;
      delay (1);  // maybe unneeded?
      } // end of good response
  } // end of for loop
  Serial.println ("Done.");
  Serial.print ("Found ");
  Serial.print (count, DEC);
  Serial.println (" device(s).");
}  // end of setup

void loop() {}

It takes this sketch a LONG TIME to produce the following result:

13:25:21.390 -> Done.
13:25:21.418 -> Found 0 device(s).

Arduino IDE
I have tried both versions of the IDE. Makes no difference which I use.

Boards Used
I have tried both a HUZZAH32 ESP32 and an ESP32-WROOM-32D board.

Board Connections
HUZZAH32: i2c adapter SDA to the SDA pin, i2c SCL to the SCL board pin
WROOM: i2c adapter SDA to GPIO21, i2c SCL to GPIO22

Level Shifter / Booster
The HUZZAH only has 3.3V logic so I have to use a booster to drive 3.3V up to 5.0V required by the LCD. The WROOM board has a 5V pin so no level shifter required.

Pull up Resistors
I have use 4K7 resistors on both SDA and SCL lines but that does not help. I have read that these are not necessary but using them or not makes no difference to the LCD.

I can provide all the images you may need but hopefully I have provided sufficient info for someone to point out my ignorance in this issue.

Thank you.

I thought it best to provide a few images of my LCD hookup.

This is the ESP32-WROOM-32D hookup.

This is the HUZZAH32 hookup with level shifter in foreground.

Thank you.

If the display is the problem, try another display.
I would start with an Arduino Uno, connect it to the display and run a I2C Scanner sketch.

Odd you mention the UNO because I was wondering if either the LCD or the i2c adapter were bad, using the UNO may help resolve that since the boards I have been using do not work.

I appreciate your help and will report back with my findings.

OK here is the UNO hookup.

My time is now 16:14 and this is the result of the i2c-scanner sketch:

15:56:35.589 -> 

15:56:37.029 -> I2C scanner. Scanning ...

So it has been scanning for approximately 18-19 minutes with no result. Does this mean the LCD or the i2c adapter is bad? I have no knowledge about this matter.

Thank you.

Well I think you may have solved my problem.

I changed to another LCD/i2c adapter combo and got the following results almost immediately:

16:21:06.869 -> 
16:21:06.869 -> I2C scanner. Scanning ...
16:21:06.902 -> Found address: 39 (0x27)
16:21:06.902 -> Done.
16:21:06.940 -> Found 1 device(s).

I will now try these components on the HUZZAH32 and the WROOM boards.

I cannot thank you enough for suggesting the UNO.

I will report back with my results later.

Thanks again for you help.

I got the same results when these same components were connected to the WROOM board:

16:31:27.429 -> I2C scanner. Scanning ...
16:31:27.429 -> Found address: 39 (0x27)
16:31:27.450 -> Done.
16:31:27.450 -> Found 1 device(s).

I am much relieved to know I was working with defective components.

Thank you.

Just connected a HUZZAH32 ESP32 and ran the i2c-scanner sketch. I first used the level-shifter then I removed it and ran the sketch.

After 5 minutes I gave up on the level-shifter hookup. Never got a result from the sketch.

I removed the level-shifter and ran the sketch again. After two minutes I did get a report back from the sketch:

16:50:23.534 -> ⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮⸮Done.
16:52:15.048 -> Found 0 device(s).

I hate to assume that both of the HUZZAH32 boards I tested with are defective. They both run BLINK without fail, but I need them to run LCD's and neither will do that.

Will continue testing.

Thank you.

I always use a level shifter when interfacing any 3v MCU with these LCD backpack devices. The reason being is that the LCDs need 5v to get proper contrast and using 5v for VCC causes the on board PCF8574 to run at 5v which means it is using/expecting a 5v i2c bus that shouldn't be connected to a 3v MCU which is using/expecting a 3v i2c bus.

Also, some of these LCD backpacks have pullups on them and some don't.
So that can be a difference between devices.

Also, when they have onboard pullups they are pulled up to the VCC input voltage.
That is normally 5v. This is why I always run a level shifter.

As far as level shifters goes, I have seen two types.

One type has a 5v input on the high side, and the 3v on the low side is an output.
With these devices I hook up 5v input to the MCU 5v and leave the 3v output disconnected.
I prefer this type of level shifter.

The other type has two voltage inputs.
i.e. a 5v input and 3v input for this application.
This type of level shifter must be hooked up to 5v for the 5v side and 3v for the 3v side.

Using an UNO is not necessarily a good test as the AVR Wire library turns on the pullups on the SDA and SCL lines.
If the backpack does not have pullups on it, it will still usually work on the AVR even without external pullups.
But that same device will not work on most of the 3v MCUs since they typically don't have pullups on their boards so there will be no pullups on the SDA and SCL lines.

--- bill

Just to clarify a little.
When I mentioned level shifters. I meant using them on the i2c signals to bridge between the 3v i2c bus on the MCU and the 5v BUS on the LCD i2c backpack.
I use the 5v from the MCU board to the VCC input on the backpack, then use a level shifter on SDA and SCL signals to connect the 3v i2c signals on the MCU to the 5v i2c signals on the backpack.

Using level shifters ensures that both the master and the slave are not attempting to operate outside of voltage level specs on the SDA and SCL signals.

--- bil

Add

  Serial.print("SDA:");Serial.println(SDA);
  Serial.print("SCL:");Serial.println(SCL);

before you do the scan in your i2c scanner and check if you are using the correct pins.

In general: the ESPs are 3.3 V devices, why don't you use a 3.3V LCD for an ESP?

1 Like

Bill,

Thank you very much for taking your time to provide me a mini-tutorial on level shifters and their use. A lot of the i2c protocol can get confusing so your in-depth info is a great help.

In the past I have always used 'buck boosters' to raise 3.3v to whatever higher voltage I may need. In my case that would be 5v for the LCD and 10v for some LED's I use in an enclosure for a water tank project I recently finished.

These are the 'buck boosters' I use: Amazon.com

Here is a grab of the interior of the enclosure lid mentioned above.

I sincerely appreciate your help.

Got it! Thanks so much for all the info you have provided me.

I have ordered level shifters and will use those in the future to power LCD's instead of the 'buck boosters' I currently use. They take up a lot less space as well.

Thanks again for your help.

Thank you for that snippet of code. I was not aware of that. I will add that to my i2c_scanner sketch.

Yes, using 3.3v LCD's would be a good option. However, I am 'invested' in too many 5v LCD's at the moment. In truth, only recently did I become of aware of the low voltage LCD's. When I deplete my 5v LCD inventory I will purchase the 3.3v variety and save myself a lot of extra work.

I appreciate your help.

Someone was kind enough to bring to my attention that I was referring to buck booster's as level shifter's. That is correct and I apologize for my ignorance.

I was not even aware of level shifter's until I began this thread. I now know better and have ordered some to replace the boosters I would normally use to power a 5v LCD.

Thank you.

If you install and use the hd44780 library,
you run the included hd44780_I2C i/o class I2CexpDiag example sketch.
As part of its diagnostic tests,
it will test the i2c signals and then print out the pins used for I2C bus signals.

--- bill

The level shifters go on the I2C lines not the power lines.
You still need he buck/boost to provide power.

Bill,

Once again, thank you for your informative post. I will definitely look into all that you noted.

Not necessarily.
Most of the MCU boards have a 5v output pin available that comes from the USB connector.

--- bill

1 Like

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