News for hackers. Stuff that matters.
Re:Ask HN: What's the purpose of the resistor in this circuit? by brk on Thursday March 19, 2009 @09:54PM (#524362)
It's a pull-down resistor.

Without it, when the temp sensor/thermistor was at infinite resistance, the Arduino pin would essentially be floating, and you'd get erratic readings.

A pull down resistor is usually proportionally very high resistance in relation to the sensor or other device that is the variable in the circuit.

If it were tied to Vcc, it would be a pull UP resistor, but same concept.

The idea behind it is that the pin is never just left "open". If there is no voltage coming through the sensor (temp sensor in this case), then the resistor pulls the pin to ground and you would get a reading of zero volts.

You want the resistance of the pull-down (or pull-up) to be high, 10K-100K are typical values. Voltage drops across all elements in a circuit, in proportion to that elements resistance in relation to the total circuit resistance.

If the temp sensor ranged from 0K to 10K, and you used a 10K pull-down, then you would have a range of 5V-2.5V for readings at that pin. As you scale up the value of the pull-down resistor, you will get less voltage drop across that resistor, meaning that you have a wider voltage range at the input pin for the same temperature variance, which results in more precise readings.

Re:Ask HN: What's the purpose of the resistor in this circuit? by robotrout on Thursday March 19, 2009 @10:41PM (#524415)
That's actually not quite true. In digital circuits, we do often use pull-ups or pull-downs to keep an input from floating. That's not what's happening here.

You're making a voltage-divider. One half of the voltage-divider is your temperature sensing resistor (thermistor), and the other half is the resistor you're asking about. Go look up voltage-dividers. In the meantime, I made a little javascript helper app as one of my very first 'learn javascript' apps a while ago. Check out http://eebug.com to play with a voltage divider. In the app, both legs of the voltage divider are constant resistors, while in this circuit, one leg's resistance varies with temperature, but it's the same concept.

Re:Ask HN: What's the purpose of the resistor in this circuit? by brk on Friday March 20, 2009 @06:33AM (#524738)
Thanks for the clarification. I looked at it quickly last night, but didn't really think enough about it.
Re:Ask HN: What's the purpose of the resistor in this circuit? by HackerJoe on Thursday March 19, 2009 @10:43PM (#524417)
R2 is not a pull-down resistor.

They are taking an analog reading here, and the resistor is used as part of a voltage divider. You can use Ohm's law to calculate the output voltage.

To understand why R2 is needed, imagine the circuit without it. It would always read 5V, no matter the temperature.

Pull-down (and up) resistors are used on digital components with floating outputs, like switches, buttons, etc. For example, if a button is either open or connecting to a high potential, you would use a pull-down resistor to give meaning to that open state.