Good morning,
I have a problem with a tmp36 temperature sensor.
The output is very strange (more than 100°C).
I attach the output of the serial monitor.
I tried to read the data from the sensor using the voltage and then I converted it to a temperature value.
Then I tried to read data from the sensor using the library TMP36.h.
Also in this case the output value is very strange.
#include <TMP36.h>
#define sensorPin A0
TMP36 myTMP36(A0, 5.0);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor with analog value: ");
Serial.print(sensorVal);
float voltage = (sensorVal/1024.0)*5000.0;
//Serial.print(", Volts: ");
//Serial.print(voltage);
Serial.print(", degrees C: ");
float temperature = (voltage - 500)/10;
Serial.println(temperature);
float celsius = myTMP36.getTempC();
Serial.print("Using the TMP36 lib: ");
Serial.println(celsius);
delay(500);
}
Hi,
Your TMP36 is not connected to the wires that connect to the arduino. That crease in the breadboard separates the two halves of the breadboard so that the two halves are not electrically connected.
Try moving the chip alongside your connecting wires.
G
The LM36 is not connected at all.
Google "breadboard layout" (images) to see how a breadboard is internally connected.
<TMP36.h> doesn't seem to use a stable reference.
Readout is then dependent on temperature and on supply voltage.
That makes this library in my book bad/useless.
Try to code this sensor without a library.
Leo..
const byte tempPin = A0; // connect TPM36 to 3.3volt (less noise) A0 and (not-shared) ground
float calibration = 0.1039; // calibrate temp by changing the last digit(s) of "0.1039"
float tempC;
void setup() {
Serial.begin(9600);
analogReference(INTERNAL); // use the stable internal 1.1volt Aref
}
void loop() {
tempC = (analogRead(tempPin) * calibration) - 50.0;
Serial.print("Temperature: ");
Serial.print(tempC, 1); // one decimal place is all you get with a 10-bit A/D
Serial.print(" C");
delay(1000); // use a non-blocking delay when combined with other code
}