# Arduino and resistors

So , hopefully this is my last question on this system

1. about the transistor, i want to use it like a switch, so i wanted to know how to determine the value of the resistance needed before the base, i searched a bit and found this on resistance , IC, and transistors half way through the page there are some calculations, according to them i need about 250 ohms (if anyone wants to redo the calculations, the resistance of the relay is 400 ohms and max IC current is 20 mA), why did he use a 10K?
2. why did he wire the temperature sensors like this? can't we just wire them 1 pin ground 1 Vin and 1 Vout?
3. do we have to use resistors before the sensors? if yes how to determine it and how is this guy is not ? if no, why? (note: i will be using a LM35 not LM335) edit:according to this i will need to put a shield if i am going to connect the sensor away from the arduino , then i will need a cable and a shield how is that going to affect the resistance need

1. Your relay needs 12 V / 400 Ohms = 30 mA of current in the coil. The transistor you are using has a DC current gain of at worst 110 (from the datasheet). So you need at least 0.27 mA going into the base. The Arduino puts out 5 V and the transistor base is at 0.7 V, so the maximum resistor you can use is (5V-0.7V)/(0.27mA) = 15.8 kOhm. Any larger and you will be limiting the current available to the coil. 10 kOhm is a nice round value that is sufficient. You could use smaller, but then you'd be wasting power on the base current.

The page linked says you need hFE at least 5 times the ratio of collector and base current. This is crazy. Yes, you need some design margin, but there's nothing special about 5x and it seems like overkill.

1. Because that's how that particular sensor has to be wired, check the datasheet.

2. Again, read the datasheet for the parts in question. As for a shielded cable, that seems like overkill unless you are in a seriously electrically noisy environment (like a factory). Try it without and if the measurement seems noisy try putting a capacitor to ground at the input pin of the Arduino. You might also want a series resistor to form a low-pass RC filter.

• i edited my post, check it out plz Commented Jan 27, 2015 at 0:33
1. Because they saw other people using a 10kohm resistor and decided that it was good enough.

2. Nope. See the datasheet for the full answer, but the short answer is that this sensor drops a certain voltage at a given temperature and the resistor drops the rest.

3. That guy is using a different sensor, one with separate input and output.

• i will be using this ( ti.com/lit/ds/symlink/lm35.pdf ) does that change anything? and about question 1 , what if i used 250 ohms? Commented Jan 26, 2015 at 22:20
• It changes everything. That sensor works differently. As for the resistor, I'll trust your calculations. Commented Jan 26, 2015 at 22:23
• just saw the LM335 :D it actually changes everything the LM335 is way easier but i cant find it anywhere Commented Jan 26, 2015 at 22:30
• No, the LM35 is easier, I assure you. Commented Jan 26, 2015 at 22:31
• do i really need a shield? Commented Jan 26, 2015 at 22:32