LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsSort the current conditions into named comfort zones by testing temperature and humidity together rather than separately. A single threshold cannot answer this question: 28°C is pleasant at 40% humidity and unpleasant at 85%. Classification needs both variables at once, so the sketch scores each one separately and then combines the scores. Reaching a verdict by adding up partial judgements, rather than nesting if statements ten deep, keeps the logic readable and makes it easy to add a third variable later.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
Every part for this build comes in the Geekobot Titan Kit box, a Geekobot exclusive, together with the parts for all 120 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
ESP32 DevKit V1 (38-pin): the brain of every Titan Kit project, with Wi-Fi and Bluetooth
Male-to-female and female-to-female leads for the modules
LEDs from the kit's red, green, yellow and blue packs
220 ohm resistors: one in series with every LED
DHT11 temperature and humidity sensor
ESP32 expansion board from the kit: every GPIO has its own S, V, G header
Follow the colours: red is power, dark grey is ground, blue is a signal.
titan_kit_043_weather_comfort_indicator.inoVerify & upload in Electrolark#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <DHT.h>
#define DHTPIN 13
#define DHTTYPE DHT11
Adafruit_SSD1306 display(128, 64, &Wire, -1);
DHT dht(DHTPIN, DHTTYPE);
int greenLed = 27;
int yellowLed = 26;
int redLed = 25;
int scoreTemperature(float t)
{
if (t >= 20 && t <= 26) return 0; // Ideal
if (t >= 17 && t <= 29) return 1; // Acceptable
return 2; // Harsh
}
int scoreHumidity(float h)
{
if (h >= 40 && h <= 60) return 0;
if (h >= 30 && h <= 70) return 1;
return 2;
}
void setup()
{
pinMode(greenLed, OUTPUT);
pinMode(yellowLed, OUTPUT);
pinMode(redLed, OUTPUT);
Serial.begin(9600);
dht.begin();
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println("OLED not found");
while (true) { }
}
display.setTextColor(SSD1306_WHITE);
}
void loop()
{
float t = dht.readTemperature();
float h = dht.readHumidity();
if (isnan(t) || isnan(h))
{
delay(2000);
return;
}
int total = scoreTemperature(t) + scoreHumidity(h);
String verdict;
String advice;
if (total == 0)
{
verdict = "COMFORTABLE";
advice = "Ideal conditions";
digitalWrite(greenLed, HIGH);
digitalWrite(yellowLed, LOW);
digitalWrite(redLed, LOW);
}
else if (total <= 2)
{
verdict = "ACCEPTABLE";
advice = "Slightly off ideal";
digitalWrite(greenLed, LOW);
digitalWrite(yellowLed, HIGH);
digitalWrite(redLed, LOW);
}
else
{
verdict = "HARSH";
if (t > 29 && h > 70) advice = "Hot and humid";
else if (t > 29) advice = "Too hot and dry";
else if (t < 17) advice = "Too cold";
else if (h > 70) advice = "Very humid";
else advice = "Very dry air";
digitalWrite(greenLed, LOW);
digitalWrite(yellowLed, LOW);
digitalWrite(redLed, HIGH);
}
Serial.print(verdict);
Serial.print(" - ");
Serial.println(advice);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print(t, 1);
display.print("C ");
display.print(h, 0);
display.print("% RH");
display.setTextSize(2);
display.setCursor(0, 18);
display.print(verdict);
display.setTextSize(1);
display.setCursor(0, 42);
display.print(advice);
display.setCursor(0, 54);
display.print("Score: ");
display.print(total);
display.print(" of 4");
display.display();
delay(2000);
}
Use a micro-USB data cable (some cables only charge), install the CP210x or CH340 driver if no port appears, pick Tools > Board > ESP32 Dev Module and hold the BOOT button on the board until the upload starts.
Turn it round: the long leg (anode) goes to the GPIO side through the 220 ohm resistor, the short leg to GND.
Check SDA on GPIO21 and SCL on GPIO22, power from 3V3, and that the sketch uses address 0x3C (some boards are 0x3D).
Check that DATA goes to the GPIO in the sketch, and wait two seconds between reads: the DHT11 is slow.
A single threshold cannot answer this question: 28°C is pleasant at 40% humidity and unpleasant at 85%. Classification needs both variables at once, so the sketch scores each one separately and then combines the scores. Reaching a verdict by adding up partial judgements, rather than nesting if statements ten deep, keeps the logic readable and makes it easy to add a third variable later.
23.0C 50% RH with a large COMFORTABLE and the green LED lit. Warm the sensor by hand: ACCEPTABLE appears with the yellow LED. Breathe on it steadily: HARSH / Hot and humid with the red LED.
Yes. It is project 43 of 120 in the Geekobot Titan Kit, in level 9 (Environmental science). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Titan Kit project is wired on the ESP32 expansion board and the breadboard with jumper wires.
9 parts: ESP32-WROOM-32 38-Pin Development Board, USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), 3 × Through-Hole LED Pack (Pack of 10), Carbon Film Resistor 1/4W 5% (Pack of 10), 0.96" OLED Display 128x64, Generic DHT11 Digital Temperature & Humidity Sensor Module and ESP32 38-Pin Expansion Board. 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 45 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (titan_kit_043_weather_comfort_indicator.ino).
About ₹922 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Multi-variable logical classification; Scoring variables separately then combining; Why single thresholds fail for comfort; Giving specific advice rather than a bare verdict.
The ESP32 is a 3.3V board: never connect a 5V signal straight to a GPIO pin.
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.