LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe HTU21D is a small, accurate I2C humidity and temperature sensor. After a hot shower bathroom humidity jumps from around 60% to over 90% in minutes. The ESP32 turns the fan on above 75% and only off again below 65%; the gap (hysteresis) stops it clicking on and off. A relay module switches the fan.
Mains wiring is dangerous: have a qualified electrician connect the fan, and keep all electronics out of the wet zone.
Tick anything you already have and the total updates.
HTU21D humidity and temperature sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
5 V USB charger in a dry place outside the bathroom.
bath_fan.inoVerify & upload in Electrolark#include <Adafruit_HTU21DF.h>
Adafruit_HTU21DF htu;
const float ON_RH = 75, OFF_RH = 65;
const int RELAY = 26;
const bool ACTIVE_LOW = true; // most relay modules
bool fanOn = false;
void setFan(bool on) { fanOn = on; digitalWrite(RELAY, ACTIVE_LOW ? !on : on); }
void setup() {
Serial.begin(115200);
pinMode(RELAY, OUTPUT); setFan(false);
while (!htu.begin()) { Serial.println("HTU21D not found"); delay(1000); }
}
void loop() {
float rh = htu.readHumidity(), t = htu.readTemperature();
if (!fanOn && rh > ON_RH) setFan(true);
if (fanOn && rh < OFF_RH) setFan(false);
Serial.printf("%.1f %%RH %.1f C fan %s\n", rh, t, fanOn ? "ON" : "off");
delay(5000);
}
Check SDA/SCL and that the module is on 3.3 V.
The room never drops below OFF_RH; raise it or add a maximum run time.
Set ACTIVE_LOW to false for a module that triggers on HIGH.
Humidity control runs the fan only as long as it is needed.
Yes, high on the wall away from spray; the ESP32 and relay should stay outside.
Yes, add a small web page or Home Assistant over Wi-Fi.
5 parts: HTU21D Temperature & Humidity Sensor Module – I2C Interface, ESP32-WROOM-32 38-Pin Development Board, 5V Relay Module with Optocoupler, Solderless Breadboard and Dupont Jumper Wires (40 pcs). On this page you can tick the parts you already have and add only the rest to your cart.
It is a intermediate project and takes about 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (bath_fan.ino).
About ₹685 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading humidity over I2C; Hysteresis to stop relay chatter; Switching a fan with a relay module.
Mains wiring is dangerous: have a qualified electrician connect the fan, and keep all electronics out of the wet zone.
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
See the smoke level live on a crisp screen and get a loud warning when it spikes.
An infrared eye that spots an open flame and raises the alarm.
Walk into the room and it sounds the alarm: the classic first security build.
Lessons are free to read. Maker (₹499/month) and Pro add quizzes, worked problems and certificates, paid with your Geekobot account. See plans
Learning project. Check every circuit and the datasheet of each part before you power it up.