All projects
🚨🟢 Beginner 40 min

Temperature Alarm

A buzzer and flashing light that warn you when something gets too hot.

What You'll Build

This is a safety gadget. It watches the temperature and stays completely silent while everything is normal, but the moment things get too hot the red LED flashes and the buzzer sounds. Point it at a radiator, a greenhouse or a cup of hot chocolate.

What You Need

  • Arduino Uno
  • TMP36 or DHT11
  • Piezo buzzer
  • Red LED
  • 220Ω resistor

How It Works

A TMP36 sensor outputs a voltage that rises steadily with temperature — 10 millivolts per degree, offset by 500 millivolts at 0 °C. The Arduino reads that voltage, converts it to degrees, and compares it with a limit. If the reading is over the limit, the alarm code runs; otherwise everything stays quiet.

Wiring

  1. 1TMP36 flat side facing you: left leg → 5V, middle → A0, right → GND.
  2. 2Buzzer + → pin 8, − → GND.
  3. 3LED → pin 7 through a 220Ω resistor to GND.

Step-by-Step Instructions

  1. 1

    Wire the sensor the right way round

    A TMP36 plugged in backwards gets extremely hot within seconds. Check the flat face before powering up.

  2. 2

    Convert volts to degrees

    Multiply the reading by 5.0 and divide by 1024 to get volts, then subtract 0.5 and multiply by 100 to get Celsius.

  3. 3

    Check against a real thermometer

    Compare your value with a room thermometer. If it is consistently off by a degree or two, add a small correction.

  4. 4

    Add the alarm

    Use tone() for the buzzer so you can choose the pitch, and flash the LED in the same rhythm.

  5. 5

    Set your limit

    Pick a threshold that makes sense for your test. 30 °C is easy to reach with warm hands.

Arduino Code

temperature-alarm.ino
const int SENSOR = A0;
const int BUZZER = 8;
const int LED = 7;
const float LIMIT = 30.0;   // degrees C

void setup() {
  pinMode(BUZZER, OUTPUT);
  pinMode(LED, OUTPUT);
  Serial.begin(9600);
}

float readCelsius() {
  float volts = analogRead(SENSOR) * 5.0 / 1024.0;
  return (volts - 0.5) * 100.0;
}

void loop() {
  float t = readCelsius();
  Serial.println(t);

  if (t > LIMIT) {
    tone(BUZZER, 1200);
    digitalWrite(LED, HIGH);
    delay(250);
    noTone(BUZZER);
    digitalWrite(LED, LOW);
    delay(250);
  } else {
    noTone(BUZZER);
    digitalWrite(LED, LOW);
    delay(500);
  }
}

Understanding the Code

float volts = analogRead(...) * 5.0 / 1024.0

Turns the 0–1023 number back into the actual voltage the sensor produced.

(volts - 0.5) * 100.0

The TMP36's own formula: remove the half-volt offset, then scale to degrees.

tone(BUZZER, 1200)

Plays a 1200 Hz note. Higher numbers sound more urgent.

noTone(BUZZER)

Stops the sound. Without it the buzzer would scream forever.

Challenges & Upgrades

Add a button that silences the alarm for one minute.
Show the temperature on an LCD alongside the alarm.
Add a second, lower threshold that warns when it gets too cold.

Troubleshooting

😖 Sensor reads about 500 °C

Fix: Your maths order is wrong, or the sensor is reversed. Check the wiring first.

😖 Buzzer is very quiet

Fix: Passive buzzers need tone(); active buzzers just need digitalWrite. Check which one you have.

Up next

🏠 Mini Smart Home

Build This