LM35 Interfacing with Arduino UNO to Monitor Temperature

In this Arduino project I’m sharing how to a LM35 Interfacing with Arduino UNO to analyses the temperature using serial monitor. When the power on the LM35 send voltage differences to the Arduino board and Arduino will displaying the real-time temperature in degree Celsius. To view the values you need to connect the board to PC or computer and open serial monitor in Arduino IDE software.

Advertisements

LM35 Interfacing with Arduino Connection Diagram

LM35 interfacing with arduino connection diagram

LM35 Pinout

LM35 Pinout

Connection

The second pin of LM35 is “Vout” which is connected to the Arduino UNO analogue pin A0. The positive and negative Pins of LM35 is connecting to the Arduino 5V and Gnd connections. To power on the circuit you need to connect the board to your PC or laptop using a USB cable. The same time you can monitor the temperature in Celsius using the serial monitor.

Programming Code

Programming Code: Copy or Download as Text File
/*
 * Arduino Sketch for Temperature Sensor Testing
 * This code reads the analog value from an LM35 temperature sensor connected
 * to pin A0 of the Arduino UNO and prints the temperature in Celsius to the
 * Serial Monitor. The sensor's +Vs pin is connected to the 5V pin, and the
 * GND pin is connected to the GND pin of the Arduino.
 */

// Pin definitions
const int sensorPin = A0; // LM35 Vout connected to A0

void setup() {
  // Initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

void loop() {
  // Read the analog value from the sensor:
  int sensorValue = analogRead(sensorPin);
  // Convert the analog value to voltage (assuming 5V reference):
  float voltage = sensorValue * (5.0 / 1023.0);
  // Convert the voltage to temperature in Celsius:
  float temperatureC = voltage * 100.0;
  // Print the temperature to the Serial Monitor:
  Serial.print("Temperature: ");
  Serial.print(temperatureC);
  Serial.println(" °C");
  // Wait for a second before taking another reading:
  delay(1000);
} 
  

Working of Code

This circuit is designed to measure temperature using an LM35 temperature sensor. For better reliability and compact design, this temperature monitoring circuit can also be implemented using professional PCB assembly methods. PCB assembly helps create a stable and organized hardware setup for Arduino-based sensor projects.

Advertisements

The sensor out pin is connected to analog pin A0 of the Arduino UNO. The LM35 outputs an analog voltage that is directly proportional to the temperature in Celsius.

It outputs 10 millivolts (0.01 volts) for every degree Celsius. The Arduino reads this analog voltage using its analogRead() function, which converts the input voltage into a digital value between 0 and 1023. This value is then converted back to voltage by multiplying it with “(5.0 / 1023.0)”, where 5.0 represents the reference voltage of the Arduino.

Once the voltage is calculated, it is converted into temperature in Celsius by multiplying it by 100, since 1°C = 10mV for the LM35. The resulting temperature is then printed to the Serial Monitor using “Serial.print()” and “Serial.println()”, this allowing real-time temperature readings to be observed on a connected computer display. The “delay(1000)” function pauses the loop for one second between readings. This will providing a steady stream of updated temperature values at one-second intervals.

Akhil Satheesh

Akhil Satheesh

Akhil Satheesh is an electronics expert and the Founder and CEO of Soldering Mind. He specializes in designing innovative electronic circuits and custom, high-performance PCB layouts. Every project he shares on solderingmind.com is rigorously bench-tested to ensure accuracy for makers and hobbyists alike.

Leave a Reply