battery temp sensing

hi all,
ive been away from the arduino scene for a while due to other projects and was wondering if anyone can assist me on my code below,

its for a battery charger and i want to add in a temp sensor, but i am unsure how to factor in the values for it, is anyone able to give me any pointers?
thanks in advance and if there is anything else wrong, please let me know, as i still have a lot to learn!

mike

// Automatic battery charger for audio use, designed by Mike Quirke 2014.
// my username on the arduino forum is "jupiterengineering".

//this program is for an automatic nimh battery charger designed to integrate with a piece of hi fi equipment
//designed to run on batteries, as they provide the perfect DC supply.

//my particular setup is a few battery packs in 24v configuration,which power a highly sensitive turntable
//preamp,however can be set to charge any voltage configuration via a voltage divider circuit.

//when the preamp is switched off in standby mode, the charging monitor is engaged, should the battery voltage
//in this state drop below 23.50v, the charge relay and flashing status led will activate,
//should the battery voltage rise above 28.00v, the charge relay and flashing status led will deactivate.
//when the power switch to the preamp is switched to the on position, a 5v signal is applied to the power toggle
//input, which instructs the charger to keep the charge relay and status indicator led illuminated, regardless
//of battery voltage.
//the temp sensor will monitor the temperature of the battery packs, should this temperature rise over 80c,
//the charger will disconnect the charging relay and fast pulse the status led as an added level of protection
//to a hardware fuse, charging will continue after the temperature has reduced to a more conservative 40c.
//when the power switch is turned off,the charger is then reenabled to continue monitoring battery voltage.

//i am using an attiny85 for this project, as it is very cheap, compact and it provides sufficient in/out
//pins for this purpose.

void setup(){
pinMode (0,INPUT); //battery voltage input via voltage divider
pinMode (1,OUTPUT); //charge relay driver output
pinMode (2,OUTPUT); //status led output
pinMode (3,INPUT); //power on/off toggle to disengage charger when in use
pinMode (4,INPUT); //temp sensor input

}
void loop(){
int batteryLevel = analogRead(0); // sample battery voltage (0-1023(0-5v))
int highVolt = 988; //(4.83v)
int lowVolt = 802; //(3.92v)
int statusLed = 2; //status indicator led
int powerToggle = 3; //power on/off state input
int tempPin = 4; //temp sensor input
if (batteryLevel >=highVolt){ //if battery level over 28v (4.83v)
digitalWrite (1,LOW); //turn off charging relay
digitalWrite (2,LOW); //turn off status indicator led
float temp; //keep an eye on the ever changing temp of battery
temp = analogRead(tempPin); //read from the analog pin of the temp sensor
for (int i=0; i<=255; i+=5) //0 - 255 range
temp = temp * 0.48828125; //temp sensor vairable for tmp 35-37 sensor
delay (1000); //wait a second between reads

}
if (batteryLevel <=lowVolt){ //if battery level below 23.50v (3.92v)
digitalWrite (1,HIGH); //turn on charging relay
digitalWrite (2,HIGH); //turn on status indicator led (start charge mode flashing sequence)
delay (1000); //wait for one second
digitalWrite (2,LOW); //take status led state low
delay (300); //wait 300mS
if (powerToggle = HIGH) //if toggle input recieves a 5v signal
digitalWrite (1,LOW); //turn off charging relay
digitalWrite (2,HIGH); //permanantly illuminate status led
}
}
//end of loop

Take a peek at Arduino Playground - Thermistor

When you're buying a thermistor you're looking for one in the 10K to 50K range. The resistance value reflects the part's resistance at room temperature. Too low a value (outside this range) and you start to waste too much power through the thermistor and with too high a value the Arduino's ADC will have more difficulty getting a good reading. The resistor used with the thermistor should be generally equal in value (10K resistor with 10K thermistor).

If you can point us to some candidate parts that are available from suppliers on your side of the planet we can provide more accurate advice. It would also be helpful to know what temperature range you're measuring.

thanks for the reply,

i am using a TMP36 three pin sensor (to92 package) and want to measure only between 0c to 100c

mike

We have some 30k Ohm thermistors(NOS) , they have small size and good for fitting in a charging circuit board.

http://www.ebay.com/itm/30K-ohm-Uni-Curve-PRECISION-CURVE-MATCHED-INTERCHANGEABLE-THERMISTORS-UUT-43J1-/331138648626?pt=Vintage_Electronics_R2&hash=item4d1966ca32

Figure 3.8.3.