Cirkit Designer Logo
Cirkit Designer
Your all-in-one circuit design IDE
Home / 
Project Documentation

Arduino UNO and LM35 Temperature Sensor with Serial Monitoring

Image of Arduino UNO and LM35 Temperature Sensor with Serial Monitoring

Circuit Documentation

Summary

This circuit is designed to read temperature data from an LM35 temperature sensor and display the temperature in Celsius on the Serial Monitor using an Arduino UNO. The LM35 sensor is connected to the Arduino UNO, which reads the analog voltage output from the sensor, converts it to a temperature value, and prints it to the Serial Monitor.

Component List

  1. Temperature Sensor (LM35)

    • Description: The LM35 is a precision integrated-circuit temperature sensor whose output voltage is linearly proportional to the Celsius temperature.
    • Pins: +Vs, Vout, GND
  2. Arduino UNO

    • Description: The Arduino UNO is a microcontroller board based on the ATmega328P. It has 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz crystal, a USB connection, a power jack, an ICSP header, and a reset button.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0

Wiring Details

Temperature Sensor (LM35)

  • +Vs: Connected to 5V on the Arduino UNO
  • Vout: Connected to A0 on the Arduino UNO
  • GND: Connected to GND on the Arduino UNO

Arduino UNO

  • 5V: Connected to +Vs on the LM35
  • A0: Connected to Vout on the LM35
  • GND: Connected to GND on the LM35

Code Documentation

/*
 * 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);
}

This code initializes the serial communication, reads the analog value from the LM35 sensor, converts it to a temperature value in Celsius, and prints the temperature to the Serial Monitor every second.