Show live readings on the LCD and sound the buzzer when the room crosses a threshold you set. The interesting part is what happens at the boundary: a naive version chatters on and off as the reading wobbles by a tenth of a degree. You fix it with hysteresis — switch on at one value, off at a lower one — which is the same technique a real thermostat uses.
Every item is in the kit — nothing extra to buy.
All 24 parts in one box, with this project and 15 more to build from them.
One of each part. Packs (resistor assortment, jumper wires) already hold more than a single build needs. Backorder parts ship once they arrive — the kit above has every part boxed today. Delivery is free on orders AED 150.00+.
Written for the board in the kit. Copy it into the Arduino IDE; change the pin numbers if you wire it differently.
/*
05 — Temperature and humidity alarm
Board: ESP32. Parts: DHT11, buzzer module, LCD 1602 (I2C backpack).
Libraries: "DHT sensor library" (Adafruit) + Adafruit Unified Sensor,
"LiquidCrystal I2C" (Frank de Brabander).
Wiring:
DHT11: VCC -> 3V3, GND -> GND, DATA -> GPIO 4
Buzzer: VCC -> 3V3 (or VIN), GND -> GND, IO -> GPIO 23 (active buzzer: HIGH = sound)
LCD: VCC -> VIN (5 V), GND -> GND, SDA -> GPIO 21, SCL -> GPIO 22
The alarm switches ON above ALARM_ON and OFF only below ALARM_OFF. That gap
(hysteresis) is what stops it chattering when the reading wobbles by 0.1 C —
the same trick a real thermostat uses.
*/
#include "DHT.h"
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
const int DHT_PIN = 4;
const int BUZZER_PIN = 23;
const float ALARM_ON = 30.0; // C — set for your room
const float ALARM_OFF = 28.5; // must be lower than ALARM_ON
DHT dht(DHT_PIN, DHT11);
LiquidCrystal_I2C lcd(0x27, 16, 2);
bool alarm = false;
void setup() {
Serial.begin(115200);
pinMode(BUZZER_PIN, OUTPUT);
digitalWrite(BUZZER_PIN, LOW);
dht.begin();
lcd.init();
lcd.backlight();
lcd.print("Warming up...");
}
void loop() {
delay(2000);
float t = dht.readTemperature();
float h = dht.readHumidity();
if (isnan(t) || isnan(h)) {
lcd.setCursor(0, 1); lcd.print("sensor error ");
return;
}
if (!alarm && t >= ALARM_ON) alarm = true;
if ( alarm && t <= ALARM_OFF) alarm = false;
digitalWrite(BUZZER_PIN, alarm ? HIGH : LOW);
lcd.setCursor(0, 0);
lcd.print("T:"); lcd.print(t, 1); lcd.print("C H:"); lcd.print(h, 0); lcd.print("% ");
lcd.setCursor(0, 1);
lcd.print(alarm ? "ALARM >" : "ok >");
lcd.print(ALARM_ON, 1); lcd.print("C ");
Serial.print(t); Serial.print(" C "); Serial.print(h); Serial.print(" % ");
Serial.println(alarm ? "ALARM" : "ok");
}
The DHT11 sends both temperature and humidity down a single data wire using its own timing protocol, so a library does the decoding for you. Wire three pins, install the…
Send a pulse, time the echo, divide by two, convert to centimetres. Unlike an analog sensor this is a timing measurement, so you meet pulse timing and microsecond resolu…
Take the distance reading and turn it into beep rate: slow far away, faster as you close in, solid at the stop point. Short to build, and it teaches you to turn a number…