Site icon AranaCorp

Temperature measurement with LM35

The temperature sensor LM35 is a small easy to use, easy to find device. Its output voltage is directly proportional to the temperature and gives a precise measurement.

Material

Wiring

Code

The datasheet of the sensor LM35 gives the temperature range measurement, -55 to 150°C , and the conversion rule between voltage and temperature value, 10 mV/°C. The value is read with an analog port of the Arduino, so the output voltage (0 to 5V) is converted on a digital value (0 to 1023).

// Constants
#define DELAY 1000 // Delay between two measurements in ms

// Parameters
const int sensorPin = A0; // Pin connected to sensor

// Variables
float voltage, temperature;

void setup(void) {
  Serial.begin(9600);
}

void loop(void) {
  voltage= analogRead(sensorPin) * (5.0 / 1023.0); // Convert digital value to voltage
  Serial.print("Sensor voltage = ");
  Serial.println(voltage); // the voltage reading
  temperature=100*voltage; // conversion from V to °C
  Serial.print("Sensor reading = ");
  Serial.println(temperature); // the temperature reading
  
  delay(DELAY);  
}

Application

Source

Find other examples and tutorials in our Automatic code generator
Code Architect

Exit mobile version