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.
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.
Disclaimer:
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.
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).