Arduino Nano & Uno - Digital Input pin current more than 50mA

Hi!

I feel kind of stupid and really don't know where to ask for help. I have been playing with Arduinos for 8 years, and now I am stuck with such a weird problem.
When I configure digital pin as an input:

pinMode(2, INPUT_PULLUP);

then at first glance stuff works. Only my Arduino gets hot. Too hot. And so, I ended up measuring digital input pin currents. If D2 is connected to GND, to logical 0, Input sources currents excess 50mA Up to 83mA. How could that be? And it is the same in Nano and Uno. Used different versions. Both chinese and original boards. All behave the same.
Also when pin is configured:

pinMode(2, INPUT);

then, to get logical reading "1" from that input, D2 draws again more than 50mA from 5V.

Then I noticed that my I2C interface is working ok. I configured Analog input to digital input:

pinMode(A0, INPUT_PULLUP);

No excessive currents, stuff works fine with internal PULLUP and without.

I was using. 1.8.7 and updated to 1.8.8 - still the same.

It looks like there is some configuration error with input pins. Output mosfets aren't programmed to be closed.

Has anyone nooticed that? Or I am just stupid and did not read instructions well?

Please provide schematics how you measured. An input pin with internal pullup, shorted to ground, should draw less than 0.1 0.25 mA.

It is possible that you have blown up pins with ESD. But the likelyhood that that happens on multiple boards is low.

Other possibility is that D2 was configured as output in a sketch and you shorted the output (to Vcc or GND) before uploading a new sketch. So the old sketch was initially still running and you damaged the pin on the microcontroller.

To avoid all bad schematics problems, I just configure:

pinMode(2, INPUT_PULLUP);

and then connect D2 to GND.

Current from D2,D3,D4,D5 to GND is around 80mA.

When I do the same with A0,A1 pin, everything works ok. Current from A0 to GND is 0,14mA

I have tried it on 2 different UNO. and 4 different Nano boards. All same. One thing to do, is to test, if Digital pins work as outputs, if we assume that output transistor is blown.

But as I just tested, the same pin, D2, if configured as output, works perfect. It could source 3,2mA and sink 3,2mA. LED blinks there as it should.

It is possible that you have blown up pins with ESD. But the likelyhood that that happens on multiple boards is low.

It's not so unlikely that the same problem would occur on multiple boards if all those boards were subjected to the same damaging process. The "chip gets super hot under normal operating conditions" thing comes up here fairly regularly. Perhaps it could be caused by damage to the chip from exceeding the rated maximum operating parameters.

After discovering that weird problem, I went to nearby electronic shop and bought brand new NANO. I took it out and tested right away. getting exactly the same results. Then I took an UNO board from existing project and tested it, getting the same results. Then I replaced Atmel ATMEGA328P chip on that board with unused one, and got the same problem. I have 3 more similar chips to test. Still, when configured as OUTPUT, it works as it should.
But logically, what could be wrong there? One of output transistors remained OPEN in INPUT configuration?

Do all the 328P chips get hot?

Still like to see how you measure the current. May we assume that nothing is connected to your board; further as below with 5V connected to the board?

measure_inputleakage.png

Note:
Your meter in above basically is a short; no need to short further. If you short the pin to GND, the meter should read 0.

Yes, current from D2 pin was measured exectly like this.

I’ve tried the pinMode(2, INPUT_PULLUP) on D2 of an (original) Uno using above schematic. Result was 0.14 mA.

Noticed that I made a mistake in the number in first reply; with a minimum value for the internal pullup (Rpu) of 20kOhm (datasheet), it should have been 0.25 mA @ 5V. I did correct the post.

I tested same thing with Arduino Due board INPUT. if no pullup resistors are programmed active, there is no detectable current with tester. If pullup resistor is active, current that sinks to ground is 0,07mA.

Did the same with Wemos D1 board. basically ESP8266. INPUT currents to ground are as specified.
How comes that all my ATMEGA 328P chips are damaged? 6 of them. I have some more to test. But it sounds weird.

Now I am little embarrassed. It appears that I am simply stupid. Problem resolved.

As I used a code I created few months ago, quite lenghty one, I forgot that I changed pinMode later in the code at certain occasion. Not only in a setup section. So basically pins were reprogrammed to be output again.

So, when testing, keep schematics and code to absolute minimum. Point taken.

Case closed, this thread can be deleted. Thanks for people who replied!

It should not be deleted

So we can have a good giggle.
2)
Others learn from your mistake.