Help choosing a resistor for pin floating

Hi guys,

I had a quick question on floating pins. I know it needs a pull up resistor to prevent the floating, but I'm not sure what value I need. I will be measuring >5V on A0 from a solar panel (approx 3.5V). Because the panel will be at 0 volts at night, or may be disconnected, the pin may float. What value would be appropriate, and will that resistor interfere with a true reading? i.e. it needs to be adjusted for in the calculation.


1 Like

Being at 0V and being disconnected are very different things. Do you expect both to happen at some time ?

I hope that you don't mean that more than 5V will be applied to pin A0. How are you intending to measure the higher voltage ?

Yes, it is possible for it to be disconnected with the chip running, so it must report 0 instead of float, and sorry yes less than 5V (3.5v Max). I'd be using a voltage divider otherwise.

Most common a resistor of 10K will do, but choosing a 22K or 47K is also possible.

1 Like

I know nothing about solar panels and my electronics knowledge is rusty.

The theory is that the output resistance of your solar panel is part of voltage divider; the other part is the input resistance of your Arduino.

For voltage sources like power supplies (and I assume your solar panel), the output resitance is low (can't give you a practical value). If it isn't, drawing current will result in a significant drop in output voltage on it's output.

For the analog input, the input impedance is (relatively) high, else it would affect what your measurement.

From your perspective, the pull-up (or pull-down) resistor will be part of the input resistance and you can calculate based on that. If the output resistance is 1 Ohm (no idea of actual values), a 100 Ohm resistor will result in approx. 1% error, a 10k will result in a 0.01% error in measurement.

What is it ?
>5V (greater than)
≈ 3.5V

10k on an analog input to GND is about the best value to use.

≈ 3.5V MAX
Typical voltage will read from 0-3.5V

I have put a 10K on ground and get a straight zero reading when nothing is connected (desired). When I connect a battery for testing, I get a 5V reading? (Even though battery is 1.5V).

My code:
float measurePnl() {
float vin = (analogRead(pnlPin) * 5.0 / 1023); //Not using a divider here so it's straight math
return vin;

There is a 10K resistor between the input and ground, with the input going straight to the pin (picture attached).

So I am unsure what I am doing wrong.

Are you using the 1.1V internal analog reference perhaps?

1 Like

Yes. Thank you for mentioning that.
Once I removed that line it is reading correctly.

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