Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade
Temperature sensors are essential components in various applications, from weather stations to home automation systems. In the Arduino environment, using a temperature sensor is straightforward and can be achieved with minimal components. This article will guide you through setting up a temperature sensor system using an Arduino board and a common temperature sensor, the LM35.
The LM35 is a precision integrated-circuit temperature sensor with an output voltage linearly proportional to the Centigrade temperature. It provides a simple way to measure temperature with an accuracy of ±0.5°C at room temperature.
Below is a sample code to read the temperature from the LM35 sensor and print it to the Serial Monitor.
const int sensorPin = A0; // Pin connected to VOUT of LM35
void setup() {
Serial.begin(9600); // Start the serial communication
}
void loop() {
int sensorValue = analogRead(sensorPin); // Read the analog value from the sensor
float voltage = sensorValue * (5.0 / 1023.0); // Convert the analog reading to voltage
float temperatureC = voltage * 100; // Convert the voltage to temperature in Celsius
Serial.print("Temperature: ");
Serial.print(temperatureC);
Serial.println(" °C");
delay(1000); // Wait for a second before reading again
}