D12 input influenced by D9 output on Nano

I configured D12 as input with pullup, D9 as output. I would expect D12 to read a stable HIGH (being unconnected and having pullup), but instead it reads the value of D9. This happens on a naked Nano without any hardware attached whatsoever. As a sanity check, I tested it on two different Nanos, the result is the same on both.

Below a simple code to replicate the problem, the values read on D12 will follow the value of D9 instead of being stable 1.

void setup() {
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(9, OUTPUT); 
}

void loop() {
  digitalWrite(9, 1); 
  delay(100);
  Serial.println(digitalRead(12));
  delay(1000);
  digitalWrite(9, 0); 
  delay(100);
  Serial.println(digitalRead(12));
  delay(1000);
}

Two Nanos purchased from the same vendor in the same order? Perhaps they could be from a bad batch.

I will try to test your code on one of my Nano later.

Yes, same batch and same $1-2 Chinese copy from Alibaba. But still, I guess the chip is original, and the pullups are in the chip.

yeh, sure

1 Like


It seems to be the model above. But even for a Chinese copy, this is quite weird. Just tried with an external pullup, the same happens.

I just tried your code on one of my Nano. Its not a genuine Nano. Results as expected:

21:34:06.958 -> 1
21:34:08.050 -> 1
21:34:09.143 -> 1
21:34:10.236 -> 1
21:34:11.362 -> 1
21:34:12.455 -> 1
21:34:13.548 -> 1
21:34:14.640 -> 1
21:34:15.765 -> 1
21:34:16.857 -> 1
21:34:17.949 -> 1

Maybe the pullups are not the problem. Maybe there is a short between the tracks of those those 2 pins somewhere on the Nano board.

Use your multimeter to measure the resistance between those two pins, while the Nano is disconnected. I get about 16~17K between pin 12 and most other digital pins.

Have you tried other pairs of pins to see if you can get the same problem?

My "I really don't think so" meter was firmly in the red, but I tried your code on a couple of different clone Nanos I had here and the value read from D9 was not influenced on either of them by the value of D12. And looking at the PCBs with a magnifier, the traces for the two pins don't go anywhere near each other on either of my boards.

I think this could be one of those "the bitterness of poor quality remains long after the sweetness of low price is forgotten" moments.

1 Like

I would try reversing the pin assignments and see if the reverse happens.

Do you have a ohmmeter? If so check for shorts with power off.

Hi,
My test code.

void setup()
{
  Serial.begin(9600);
  pinMode(12, INPUT_PULLUP);
  pinMode(9, OUTPUT);
}

void loop()
{
  digitalWrite(9, 1);
  delay(100);
  Serial.print("Pin 9 OUTPUT HIGH   Pin 12 INPUT ");
  Serial.println(digitalRead(12));
  delay(1000);
  digitalWrite(9, 0);
  Serial.print("Pin 9 OUTPUT LOW   Pin 12 INPUT ");
  delay(100);
  Serial.println(digitalRead(12));
  delay(1000);
}

Results;

Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1
Pin 9 OUTPUT HIGH Pin 12 INPUT 1
Pin 9 OUTPUT LOW Pin 12 INPUT 1

What do you mean, what meter in what range testing what?

Tom.. :grinning: :+1: :coffee: :australia:

Thanks for everyone for doing the test!!!

In the meantime I realized that the problem may not be the poor quality cheap chip, but the fact that I forgot to tell an important piece of information (for which I apologize, I didn't realize how important it was!!!): it is not a simple Nano, but an RF-Nano (from a batch initially bought for another project).

And the RF-Nano seems to have an onboard nRF24L01+ chip connected to D9-D13. The chip still allows the use of these pins as output pins (well, with a potential unexpected behavior in radiofrequency...), but it seems D12-13 cannot be used as input pins.

So I believe the mystery is solved. Thanks again for your time, and I apologize for hiding this information!!!

2 Likes

Yep, D9 is the chip enable signal for the nRF24L01+ chip, that's where the interference came from. Cutting the D9-D10 wires on the RF-Nano PCB miraculously solved the problem, so this is a short term cure until the batch of regular Nanos arrives.

Sorry again for this, I didn't realize how important piece of information the RF part in the name was!!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.