I2C LCD not working

Hi,

I have been trying to run the sample programs on the I2C_LCD break out board.
All the samples fail to execute on the LCD.
I have tested my voltage, 5v.
I have done a factory reset on the LCD and still am unable to execute any of the sample code.

Arduino Uno Wifi
Connections :
VCC
GND
SCL
SDA

I did run an I2C bus scanner and when it gets to 0x51, I get an error 4 returned. All other I2C devices do not return an error. I attached the code.

#include <Wire.h>
void setup()
{
  Wire.begin();
  Serial.begin(9600);
  while (!Serial);             // Leonardo: wait for serial monitor
  Serial.println("\nI2C Scanner");
}

void loop()
{
  byte error, address;
  int nDevices;

  Serial.println("Scanning...");

  nDevices = 0;
  for(address = 1; address < 127; address++ ) {
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    Serial.print("address: ");
    Serial.print(address);
    Serial.println("  !");

    Serial.print("error: ");
    Serial.print(error);
    Serial.println("  !");

    if (error == 0){
      Serial.print("I2C device found at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.print(address,HEX);
      Serial.println("  !");

      nDevices++;
    }
    else if (error==4) {
      Serial.print("Unknow error at address 0x");
      if (address<16) {
        Serial.print("0");
      }
      Serial.println(address,HEX);
    }    
  }
  if (nDevices == 0) {
    Serial.println("No I2C devices found\n");
  } else {
    Serial.println("done\n");
  }
  delay(5000);           // wait 5 seconds for next scan
}

Hi,

I have run a diagnostics program called I2CexpDiag.

This was the output from that run.
00:15:22.697 ->
00:15:22.697 -> ********************************************************************
00:15:22.791 -> Serial Initialized
00:15:22.791 -> --------------------------------------------------------------------
00:15:22.884 -> I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
00:15:22.930 -> --------------------------------------------------------------------
00:15:23.024 -> hd44780 lib version: 1.3.1
00:15:23.024 -> --------------------------------------------------------------------
00:15:23.116 -> Reported Arduino Revision: 1.8.13
00:15:23.163 -> CPU ARCH: AVR - F_CPU: 16000000
00:15:23.209 -> --------------------------------------------------------------------
00:15:23.257 -> SDA digital pin: 20
00:15:23.303 -> SCL digital pin: 21
00:15:23.303 -> --------------------------------------------------------------------
00:15:23.395 -> Checking for required external I2C pull-up on SDA - YES
00:15:23.441 -> Checking for required external I2C pull-up on SCL - YES
00:15:23.488 -> Checking for I2C pins shorted together - Not Shorted
00:15:23.629 -> --------------------------------------------------------------------
00:15:23.723 -> Scanning i2c bus for devices…
00:15:23.723 -> i2c device found at address 0x27
00:15:23.770 -> i2c device found at address 0x40
00:15:23.815 -> Unknown error at address 0x51
00:15:23.861 -> i2c device found at address 0x60
00:15:23.908 -> Total I2C devices found: 3
00:15:23.908 -> --------------------------------------------------------------------
00:15:24.001 -> Scanning i2c bus for all lcd displays (4 max)
00:15:24.095 -> LCD at address: 0x27 | config: P01245673L | R/W control: Yes
00:15:25.303 -> Total LCD devices found: 1
00:15:25.303 -> --------------------------------------------------------------------
00:15:25.397 -> LCD Display Memory Test
00:15:25.397 -> Display: 0
00:15:25.444 -> LCD stuck BUSY status
00:15:25.444 -> --------------------------------------------------------------------
00:15:25.537 -> No working LCD devices

I see too many devices on your I2C bus.Can you just connect i2C_LCD?The pull up resistance will be modified when i2C devices are connected in parallel. @drbyte0001

Hi Baozhu,

Thank you for the response.

I went back to basics and plugged the I2C_LCD directly into the Arduino board SCL/SDA/VCC/GND, and I could finally see Hello World on the I2C_LCD screen.

I attached the Base Shield (https://www.seeedstudio.com/Base-Shield-V2.html) onto the Arduino and plugged the I2C_LCD into a Base Shield I2C port. This works and I can see Hello World on the I2C_LCD screen.

I started to run the I2C Bus Scanner and get the following output;
11:10:53.495 -> I2C Scanner
11:10:53.495 -> Scanning…
11:10:53.495 -> I2C device found at address 0x51 !
11:10:53.543 -> I2C device found at address 0x60 !
11:10:53.589 -> done

The I2C_LCD shows up at address 0x51, which is the default address.

I then plug in my I2C 4Ch Dimmer board and see the following;
11:12:33.871 -> Scanning…
11:12:33.917 -> I2C device found at address 0x27 !
11:12:33.917 -> Unknow error at address 0x51
11:12:33.964 -> I2C device found at address 0x60 !
11:12:34.011 -> done

The I2C 4Ch Dimmer board shows as address 0x27 but now, the I2C_LCD at address 0x51 gives an error. The return error is error 4.

I then remove the I2C 4Ch Dimmer board and plug in the I2C TH02 (Temperature/Humidity) sensor.
11:14:44.789 -> I2C Scanner
11:14:44.789 -> Scanning…
11:14:44.789 -> I2C device found at address 0x40 !
11:14:44.837 -> Unknow error at address 0x51
11:14:44.883 -> I2C device found at address 0x60 !
11:14:44.883 -> done

The I2C TH02 (Temperature/Humidity) sensor shows as address 0x40 and the I2C_LCD at address 0x51 gives an error. The return error is error 4.

If I leave the I2C TH02 (Temperature/Humidity) sensor plugged in and plug in the I2C 4Ch Dimmer board, I get the following;
11:25:14.741 -> Scanning…
11:25:14.741 -> I2C device found at address 0x27 !
11:25:14.788 -> I2C device found at address 0x40 !
11:25:14.835 -> Unknow error at address 0x51
11:25:14.835 -> I2C device found at address 0x60 !
11:25:14.881 -> done

The I2C_LCD at address 0x51 is still in an error state with an error 4.

I even tried to change the address of the I2C_LCD to 0x10, but still had the same results, the I2C_LCD now at address 0x10 gives the error 4.

11:27:15.554 -> Scanning…
11:27:15.554 -> Unknow error at address 0x10
11:27:15.602 -> I2C device found at address 0x27 !
11:27:15.649 -> I2C device found at address 0x40 !
11:27:15.695 -> I2C device found at address 0x60 !
11:27:15.695 -> done

So… The big question on my mind is how do I resolve this.
What is error 4? How can error 4 be resolved?
Do you have any solutions that would resolve this?
You mentioned pull up resistance. Is this resistance on the VCC/GND or SCL/SDA?

I plan to add a second I2C 4Ch Dimmer board to the I2C bus.

Any help would be appreciated.

  • Bruce
    I need to get this resolved.

This error comes from your scanning code. Not from sensors. Is there an explanation for error 4?

Hi Baozhu,

The error is an error returned from an attempt to end transmission with LCD. The code calls Wire.endTransmission() for each of the devices that are found on the I2C bus but only the LCD has a return code of 4. All the other devices have a zero return code. The error code 4 is listed as “other error”.

The problem is with the LCD device connected to the I2C bus with other I2C devices. The other devices work without issue, even with the LCD connected to the I2C bus
.
23:23:23.476 -> Scanning…
23:23:23.476 -> Unknow error at address 0x10 <- LCD
23:23:23.523 -> I2C device found at address 0x27 ! <- 4Ch Dimmer
23:23:23.523 -> I2C device found at address 0x40 ! <- TH02 sensor
23:23:23.570 -> I2C device found at address 0x60 ! <- Arduino Wifi
23:23:23.618 -> done

To me is looks like the LCD device would give the same error if connected to an I2C bus with other I2C devices.

Any thoughts on how to proceed?

Bruce

Hi Baozhu,

Do you get the following compile warnings in the LCD.cpp file?

C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp: In member function ‘virtual size_t I2C_LCD::write(uint8_t)’:
C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp:217:29: warning: unused variable ‘Fontsize_Y’ [-Wunused-variable]
uint8_t Y_Present, Y_New, Fontsize_Y, fontIndex;
^~~~~~~~~~
C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp: In member function ‘void I2C_LCD::DrawCircleAt(int8_t, int8_t, uint8_t, LCD_DrawMode)’:
C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp:309:9: warning: comparison is always true due to limited range of data type [-Wtype-limits]
if(x<128 && y<64 && r<64)
~^~~~
C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp: In member function ‘void I2C_LCD::DrawFullScreen(const uint8_t*)’:
C:\Users\drbyte\Documents\Arduino\libraries\I2C_LCD_Library\I2C_LCD.cpp:348:15: warning: comparison is always true due to limited range of data type [-Wtype-limits]
for(i=0; i<1024; i++)
~^~~~~

Bruce