So this is my first blog its more of a log for myself, of my experiments and projects so i know what ive done and how ive done it.
Thermometer:
The temp sensor used is TMP36 the middle signal pin connects to analog input 0 on the arduino.
It outputs 10millivolts per degree c... to allow minus temps it has a 500mV offsett meaning 25c = 750mV, 0c = 500mV..
The code used was..
int temperaturePin = 0; // pins and corresponding inputs are assigned
void setup() // runs once
{
Serial.begin(9600); // initiates serial connection with comp
}
void loop() // loops over and over
{
float temperature = getVoltage(temperaturePin); // float stores the voltage from
// temperaturePin
temperature = (temperature - .5) * 100; // because the offset.. 0c = 500mV
// and each degree is 10mV..
// converts voltage into temp
Serial.println(temperature); // prints the result in degrees
delay(1000); // delay
}
float getVoltage(int pin){ // converts from 0 to 1023 digital range
return (analogRead(pin) * .0048828814); // to 0/5 volts each 1 dig range = 5mV
}
No comments:
Post a Comment