Would this LM7805 voltage regulator require a heat sink?
It will regulate 12V to 5V and will be used for a 5V sensor which draws 4mA current.
No, this would not require a heatsink.
To answer your problem, you first need to know the power dissipated by the component. To do this, it is a simple calculation of P = IV. Thus, your power dissipated would be 4 mA * (12 V − 5 V) = 0.028 W which is equal to 28 mW.
Your next step is to look at the thermal properties of the component.
As you can see, the Max operating temperature is 125 °C.
Now you look at the Junction to Air Thermal Resistance. For the TO-220 package, it is 65 °C/W. Using this, you take your power value that you calculated earlier (0.028 W) and plug it into this equation. Doing that, you get: 65 °C/W * 0.028 W = 1.82 °C which means your 7805 will heat up by approximately 2 °C above the ambient temperature. If we assume you are working in an ambient of 25 °C, this means your component wil heat up to approximately 27 °C, this is well within the specified temperature range, and thus does not need a heatsink.
Following these steps will enable you to calculate similar things in the future.
ADDED
As Colin pointed out in his answer, the 78L05 might be cheaper for you, and is meant to be used in low current applications, as it has a max output current of 100 mA, which is still more than what you need.
Using the calculations from before, we can look at any datasheet for the component. I am using THIS one and we can find the thermal characteristics.
The TO-92 package is the 'Z' package which has a Junction to Air Thermal Resistance of 230 °C/W. We can now use this value in the previous equation: 230 °C/W * 0.028 W = 6.44 °C, which again, is more than fine for you to use without worrying.
EDIT:
I did forget to include the current of the 7805 IC itself. This was however, mentioned in the answer by Spehro Pefhany. However, if you remember to include the current of the IC you use, this method should enable you to calculate power and heat dissipation in future.
The power dissipated is (12V - 5V) * 0.004A + 12V * 0.006A (the latter term is to account for maximum regulator internal consumption).
Total is 100mW, which is well within the very conservative 600mW you can dissipate from a TO-220 without a heatsink.
You could use an LM78L05 as others have suggested, which would have similar dissipation, and still would be fine, however the line and load regulation is poorer for the LM78L05, it's not the same die. The TO-252 version of the LM78M05 is a good compromise.
The power dissipated will be 7 (V) * 0.004 (A) = 0.028 W. You shouldn't need a heatsink for that.
You may find a 78l05 is cheaper, which is a TO92 packaged version of the regulator, it's rated for less current, and can dissipate less power, but would still be adequate for this.
edit As Chris Stratton pointed out, I neglected the power dissipated by the regulator itself, which would be 12 (V) * 0.006 (A) = 0.072 W, giving a total dissipation of 100 mW. You should still be fine without a heatsink.
The power dissipation of this regulator is directly associated with the voltage it drops and the current the circuit draws.
At 4mA, dropping 12-5 = 7V, would be 4mA * 7V = 28 mW.
A TO-220 package has a thermal resistance to air (heatsink-to-ambient) of about 70 C/W. Meaning the unit will heat up approximately 2 degree C above ambient.
Heatsink is not required.
Supply Power =12V * (4mA + 8mA max {Iq(reg)} = 144 mW.
Load = 48mW. ,
Regulator= 144-48=96mW * 65’C/W =6.5’C junction rise above board temp
Conclusion < 40’C rise of insulated junction above board temp ambient is ok if the board is <40’C otherwise derate acceptable rise.
If load is much greater , recalc junction rise and consider heatsink designs.
“cool”.
Regulating from 12V to 5V means a voltage drop of 7V in the regulator. At 4mA, the total power dissipation in the regulator is of 0.028W.
This is quite low, and the 7805 can handle it without a heatsink