I don't have much experience with I2C so perhaps I'm doing something wrong here.
I'm trying to connect a SD1306 based display to Arduino Mega 2560. When running example from Adafruit_SSD1306 library it hangs on display.begin(...) statement, same happens with I2C temperature sensor.
I tried to run diag sketch I2Cexpdiag from hd44780 and I'm getting 'SDA - STUCK LOW' message (full output is below). It happens regardless of whether I2C display is connected to Arduino or not.
Not sure what else I can try here, hope someone could advise on the next step.
SDA digital pin: 20
SCL digital pin: 21
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - STUCK LOW
Checking for required external I2C pull-up on SCL - YES
********************************************************************
ERROR: SDA or SCL stuck pin
********************************************************************
I2C bus not usable
Ran I2cScanner on an empty board, it got stuck. I added some println statements and found that it hangs on Wire.endTransmission() statement on the first iteration.
Same result with the i2c display attached to the board.
jremington:
"STUCK LOW" suggests a wiring problem. One possibility is a solder blob is short circuiting the SDA line to ground.
Redo all connections, check them with a magnifying glass and use your multimeter to check for continuity and/or short circuits.
Hi jremington, appreciate the advice. Since I have this problem even without anything connected I focused on Arduino itself, here are my findings (all disconnected, power off):
resistance between SDA (p20) and 5V is 2kΩ
resistance between SLC (p21) and 5V is 10kΩ
resistance between SDA (p20) and GND is 1kΩ
resistance between SLC (p21) and GND is 11kΩ
I assume that the numbers above are supposed to be the same for SDA and SLC. Since resistance for SDA is much lower, does it indicate the short on the board?
I don't see any obvious shorts, but not sure what it's supposed to look like if there is one. Is there some particular place on Mega board I should be paying attention to?
Since resistance for SDA is much lower, does it indicate the short on the board?
The different resistances of SDA and SCL to GND and Vcc suggest a serious problem. However, I would expect 0 Ohms for a direct short circuit. The schematic of the Mega 2560 shows that both pins have external 10K pullups to Vcc. See https://www.arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf
If there are no obvious problems on the circuit board, it is possible that the SDA pin has been internally damaged.
When measuring resistances between pins and GND or Vcc using a multimeter, be sure to apply the leads both ways around, and use the "diode check" function as well. The input protection or body diodes on the inputs tend to confuse the readings.
If you see very similar readings for both multimeter lead orientations, that suggests you are measuring a genuine resistance value, and not the effects of diode conduction.
Sorry, I don't have a Mega to check. Perhaps someone else will chime in.
AleksGK:
Ran I2cScanner on an empty board, it got stuck. I added some println statements and found that it hangs on Wire.endTransmission() statement on the first iteration.
Same result with the i2c display attached to the board.
jremington:
The different resistances of SDA and SCL to GND and Vcc suggest a serious problem. However, I would expect 0 Ohms for a direct short circuit. The schematic of the Mega 2560 shows that both pins have external 10K pullups to Vcc. See https://www.arduino.cc/en/uploads/Main/arduino-mega2560-schematic.pdf
Thank you for the pointer. I check schematics and PCB diagram and found a resistor array of 4x10K resistors, it's marked as RN1. When checking resistors directly on the boards three out of four show 10K and one connected to SDA shows 2K (both directions).
Is there any way to fix it without damaging Arduino any further?
If the pin is damaged, hardware I2C won't work. It can be repaired only by replacing the processor chip.
You could try using software I2C, which allows you to use any two digital pins as SDA and SCL. You probably need to add pullup resistors to both pins (2.2K to 4.7K to Vcc).
jremington:
If the pin is damaged, hardware I2C won't work. It can be repaired only by replacing the processor chip.
You could try using software I2C, which allows you to use any two digital pins as SDA and SCL. You probably need to add pullup resistors to both pins (2.2K to 4.7K to Vcc).
yes, this could be a good alternative for me. I found SoftI2CMaster library and managed to run a successful i2c scan that detects my device.
My next challenge is to find SD1306 display library that is compatible with my software i2c library, no luck so far.