Setting A5 as internal pullup resets cpu

I made this on an Uno with no problems, I then made a few boards and assembled them so that I can put my project in a smaller enclosure. Out of 30 Ive made 10 have this problem. The other 20 are fine.

Pin A5 has a 4k7 resistor pulling it down externally. I use this pin to detect moisture by pulling it high with a transistor. I have checked and cannot find any shorts between this pin and others.

As soon as I enable the internal pullup on A5 the cpu resets.
Things I have tried so far.

  • I have move this around in the code to make sure it has nothing to do with timeing
  • The 3.3v power is stable and very clean
  • I added extra decoupling caps
  • Replaced the cpu, crystal(8Mhz) and crystal caps
  • tried this on more than one faulty board with same results

If I do not use the pullup, which I dont really need. The code still resets later on when trying to write to EEProm. This seems to indicate that its power, which does not make sense as it is very stable.

This is the first problem Ive had which I cannot find others having, which makes me think Im doing something stupid.
I hope Ive posted this in the right place, thanks in advance for any help.

Well what you have tried is not stupid but also it will not result in the things you see. So that only leaves you not having implemented what you think, or you being in a very electrically noisy environment.

So what would be good is a photograph of your wiring along with a schematic of what you have implemented.
Their is no need at all for the pull down resistor so remove that and enable the internal pull ups. If you still have problems take that resistor and make it a pull up as well as the internal pull-ups.

I have attached a schematic of the port. There is no real wiring as its all on a PCB so I attached what the pcb looks like as it is much clearer than a picture will be. The board must be correct as there are several units that work fine. Also there are no shorts I can detect.

With regards to noise. The unit is battery powered and Ive added extra capacitors everywhere I can. I can also see on an oscilloscope that the power line looks clean.

I need the 4k7 pull down for the circuit to work. What I dont need is the pullup in the cpu. However on the boards that work the pullup in on and it works.

If I take the pullup off it still resets only now at a point where I write to EEprom.

This is your schematic.


See image guide for how to post like this.

Their is nothing in that circuit that would cause a reset of the processor. What about the code? Have you got the watchdog enabled? What Arduino are you using? How is this circuit wired to the Arduino?
Your other image was a PCB layout which without the schematic is some what useless.

If I take the pullup off it still resets only now at a point where I write to EEprom.

Is the power for the sensor coming from the same place as the power to the Arduino?

Ive solved the problem

For anyone in the future who has this here is what I found.
When I disabled brownout, it would not reset any more, it just would not work. This means its definitely something to do with power.

I have a 10nH inductor from vcc to Avcc. My parts tray had some capacitors mixed in with the inductors.

so the Avcc was floating. This is what caused it. With the inductor fitted all is working now.