I2C Scanner does not function as expected

Hi, I was trying to display a temperature value on an I2C LCD using my RP PICO, but nothing would show up each time I tried to print. I expected that my issue was probably caused by using the incorrect address. I assumed it was 0x27 from the datasheet, but no result. To solve this issue, I used my Arduino Uno as an I2C scanner to see what address I needed to use with the LCD I bought. There has been an issue, however. Whenever I tried to scan with the provided code below, the serial monitor would hang up on the scanning portion and loop through that.

// --------------------------------------
// i2c_scanner
//
// Version 1
//    This program (or code that looks like it)
//    can be found in many places.
//    For example on the Arduino.cc forum.
//    The original author is not know.
// Version 2, Juni 2012, Using Arduino 1.0.1
//     Adapted to be as simple as possible by Arduino.cc user Krodal
// Version 3, Feb 26  2013
//    V3 by louarnold
// Version 4, March 3, 2013, Using Arduino 1.0.3
//    by Arduino.cc user Krodal.
//    Changes by louarnold removed.
//    Scanning addresses changed from 0...127 to 1...119,
//    according to the i2c scanner by Nick Gammon
//    https://www.gammon.com.au/forum/?id=10896
// Version 5, March 28, 2013
//    As version 4, but address scans now to 127.
//    A sensor seems to use address 120.
// Version 6, November 27, 2015.
//    Added waiting for the Leonardo serial communication.
// 
//
// This sketch tests the standard 7-bit addresses
// Devices with higher bit address might not be seen properly.
//

#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 = 8; address < 127; address++ ) 
  {
    // The i2c_scanner uses the return value of
    // the Write.endTransmisstion to see if
    // a device did acknowledge to the address.
    Wire.beginTransmission(address);
    error = Wire.endTransmission();

    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("Unknown 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
}

So far I tried one method of troubleshooting the scanner. I tried disconnecting the SCL and SDA pins from the end of the LCD. When I did this, the serial monitor instantly changed to show that no I2C device had been

Post your lcd i2c module image or link.

https://www.digikey.com/en/products/detail/sunfounder/CN0295D/18668612 The datasheet should be in here

You have SDA connected to A4 and SCL to A5, correct?
Power and ground?

I had it connected to the pins labeled SCL and SDA. If you re-read my post I say that it works when no device is connected: it instantly shows that. WHenever I disconnect the SCL and SDA pins it saays no device found. It just gets stuck in scanning when connected to a device.

I tried disconnecting the SCL and SDA pins from the end of the LCD. When I did this, the serial monitor instantly changed to show that no I2C device had been

The symptoms you describe are characteristic of sda shorted to scl or either one of them shorted to ground. Look very carefully at the soldering of the chip.

I read it. That is why I questioned which pins are connected where.
Got a voltmeter? Check the voltages on A4 and A5 when connected and powered up. Should be around 4 to 5 volts on both pins.

Not the case here. The soldering looks perfectly done from under the board

Try another I2C device.

What value do the required pullup resistors on SDA and SCL have?

1 Like

One thing that I know will hang the I2C scanner on the R3 is the SCL or SDA line being pulled low rather than high. It doesn't even have to be pulled down very hard; a 10K resistor to ground will do it.

Be sure you have pull up resistors in the 4.7K range. Do you have a multimeter?

Hello ryandyc

Welcome back.

Post a picture of the hardware used.

A picture is always worth a thousand words.

1 Like

WHile it may seem trivial to request a schematic, as the circuit is so simple, the effort in producing one is also trivial so its worth doing to prevent any confusion.

FOr example - how are the Vcc and Ground connected? and ..

a schematic would show what it you meant