Hi all not sure what’s happening here - I have an LM335A temperature sensor and when I run this snippet of code it reads the surrounding temperature (although it seems to read high) but when I put it near a heat source (like a lamp) the temperature reading goes down.
I tried it with an LM35DZ (and different code) and it works fine.
The code is below and any help would be greatly appreciated:
//TMP36 Pin Variables
int sensorPin = A0;
/*
* setup() - this function runs once when you turn your Arduino on
* We initialize the serial connection with the computer
*/
void setup()
{
Serial.begin(9600); //Start the serial connection with the computer
//to view the result open the serial monitor
}
void loop() // run over and over again
{
//getting the voltage reading from the temperature sensor
int reading = analogRead(sensorPin);
int KelvinC=273;
float _sensorValue;
float _Kelvin;
float _Celsius;
float _Fahrenheit;
_sensorValue = analogRead(sensorPin);
_Kelvin = (((_sensorValue / 1023) * 5) * 100); // convert
_Celsius=_Kelvin-KelvinC;
_Fahrenheit=(_Celsius)*(9/5)+32;
Serial.print(_Celsius); Serial.println(" degrees C");
delay(1000); //waiting a second
}