Temperature Measurement with TMP36

Temperature Measurement with TMP36

Objective

This experiment uses the TMP36 temperature sensor to measure the ambient temperature.

Required Components

Working Principle

The TMP36 sensor provides an analog voltage output that corresponds to the temperature, which can be read by the Arduino and converted to temperature in Celsius.

Wiring Instructions

Follow these steps to connect the UV sensor to the Arduino board:

  1. Locate the pins on your UV sensor: VCC, GND, and OUT.
  2. Connect the VCC pin of the UV sensor to the 5V pin on the Arduino to supply power to the sensor.
  3. Connect the GND pin of the UV sensor to any GND pin on the Arduino to complete the circuit.
  4. Connect the OUT pin of the UV sensor to the analog input pin A0 on the Arduino. This allows the Arduino to read the analog signal from the sensor.

Ensure all connections are secure and avoid reversing the pins, as this could damage the components. Double-check your wiring before powering the circuit.

Pro Tip: Use a breadboard for a more organized and stable setup, especially during prototyping.

Arduino Code


/*
 * Temperature Measurement with TMP36
 * This code reads the temperature from the TMP36 sensor.
 */

const int sensorPin = A0;  // TMP36 sensor connected to analog pin A0

void setup() {
  Serial.begin(9600);  // Initialize serial communication
}

void loop() {
  int sensorValue = analogRead(sensorPin);  // Read the sensor value
  float voltage = sensorValue * (5.0 / 1023.0);  // Convert to voltage
  float temperature = (voltage - 0.5) * 100;  // Convert voltage to temperature
  
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println(" °C");
  delay(1000);  // Wait for 1 second before the next reading
}
            

Results

The serial monitor will display the temperature readings in Celsius.

Applications

Conclusion

The TMP36 sensor is a reliable tool for measuring ambient temperature, with applications in environmental monitoring, weather stations, and home automation systems.