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.
Temperature Sensor (LM35)
Arduino UNO
/*
* 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.