I am using an arduino mega with a 20 x 4 LCD module which is hanging/freezing while running the lcd.init() or lcd.begin() function. The SDA and SCL are connected to pin 20 and 21 respectively.
For this reason I used a basic I2C address scanner code without connecting the LCD module which too hangs and cannot scan any addresses.
I also used a hd44780 diagnostic tool on which with/without any LCD connections gives the following result:
********************************************************************
Serial Initialized
--------------------------------------------------------------------
I2CexpDiag - i2c LCD i/o expander backpack diagnostic tool
--------------------------------------------------------------------
hd44780 lib version: 1.1.1
--------------------------------------------------------------------
Reported Arduino Revision: 1.8.12
CPU ARCH: AVR - F_CPU: 16000000
--------------------------------------------------------------------
SDA digital pin: 20
SCL digital pin: 21
--------------------------------------------------------------------
Checking for required external I2C pull-up on SDA - YES
Checking for required external I2C pull-up on SCL - STUCK LOW
********************************************************************
ERROR: SDA or SCL stuck pin
********************************************************************
I2C bus not usable
While this code runs successfully with another spare arduino mega which displays on LCD and reads out addresses.
Is there any problem with my previous mega? Please help!
Interesting.
I've not ever seen that error except during my testing.
So are you saying that this error shows up when there is nothing connected to the SDA and SCL pins?
sanketpatel87:
Yes Bill.. Nothing is connected to it..
Is my arduino mega I2C unusable?
Unless there is some kind of soldering issue on your board, it sounds like there is a processor issue on that pin.
Look carefully at the header pins for SCL signal.
Look at both locations. It will be the pins on both ends of the headers on the top row of headers on the mega board.
I would write a small test program to test it.
Do you have a resistor?
In setup() initaize the serial port and set pin 21 to INPUT mode.
In loop() read pin 21 and print it to the serial monitor.
Take the resistor and connect one end to 5v and the other end to pin 21 and see if you read HIGH or 1.
(you may have to use an additional wire to reach)
bperrybap:
Unless there is some kind of soldering issue on your board, it sounds like there is a processor issue on that pin.
Look carefully at the header pins for SCL signal.
Look at both locations. It will be the pins on both ends of the headers on the top row of headers on the mega board.
I would write a small test program to test it.
Do you have a resistor?
In setup() initaize the serial port and set pin 21 to INPUT mode.
In loop() read pin 21 and print it to the serial monitor.
Take the resistor and connect one end to 5v and the other end to pin 21 and see if you read HIGH or 1.
(you may have to use an additional wire to reach)
--- bill
So nothing looks damaged on the board or headers. The SDA and SCL pins both read close to 5 V on multimeter.
I also tried running the test program with resistor. But SDA reads HIGH and SCL reads LOW.
sanketpatel87:
So nothing looks damaged on the board or headers. The SDA and SCL pins both read close to 5 V on multimeter.
I also tried running the test program with resistor. But SDA reads HIGH and SCL reads LOW.
what sized resistor? Is it 2k or less?
(Technically, you don't need to use the resistor and could use a jumper wire,
I was suggesting using it in case there was a wiring or solderin gissue on the board.)
With nothing attached to the mega, SDA (20) and SCL (21) should read HIGH on a Mega board as there are 10k pullups on the Mega board.
When you attach one end of the resistor to 5v and the other to a pin, it should read HIGH.
When you attach one end of the resistor to GND and the other to a pin, it should read LOW.
If you don't see a high using digitalRead() on pin 21 when the pin is connected to 5v, then it appears that processor has an issue on that pin.
Was the pin ever exposed to voltage higher than the 5v processor voltage?