I can't figure out what the problem is with the value that is displaying on the serial monitor. It is reading 466.80 *F. I have tried different programs, as well as.
Please help me figure out my error.
Here is my code:
float temp;
float tempF;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
temp = analogRead(A0);
temp = temp * 0.48828125;
tempF = (temp * 9.0 / 5.0) + 32.0;
Serial.print("Temperature ");
Serial.print (temp);
Serial.print("*F");
Serial.println();
delay(1000);
}
Code compiles/works, so there could be something wrong with the sensor/wiring.
I assume you use an Uno. Post pictures.
Read the "how to post" sticky at the top of every main page.
That also shows you how to post with code tags.
This sketch (not tested with a TMP35/LM35) uses the 1.1volt internal reference, is more stable, and has a 5x higher resolution.
Prints to 0.1F, because a ~0.2F resolution is all you're going to get with a 10-bit A/D.
Leo..
// TMP35 to Fahrenheit
float calibration = 0.1039; // change last digit(s) of 0.1039 if needed
float tempF; // holds temp in Fahrenheit
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // use internal 1.1volt Aref
}
void loop() {
tempF = analogRead(A0) * calibration * 1.8 + 32.0; // sensor output on pin A0
Serial.print("Temperature: ");
Serial.print(tempF, 1); // one decimal place
Serial.println(" F");
delay(1000); // use a non-blocking delay when combined with other code
}