LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsReduce several environmental readings to a single weighted score out of 100, so conditions can be compared at a glance. Each reading is first scored on its own from 0 to 100, using distance from the ideal value: sitting exactly on target scores 100, and the score falls off as the reading drifts away. Those three scores are then blended with weights that add up to 1.0, temperature counts for half, humidity a third, light the rest. Changing a weight changes what the system considers important without touching any of the scoring code.
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
10k resistor: the fixed half of the light-sensing divider
DHT11 temperature and humidity sensor
LDR: its resistance falls as the light gets brighter
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_049_room_climate_score.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);
float idealTemp = 23.0;
float idealHum = 50.0;
int idealLight = 65;
float weightTemp = 0.5;
float weightHum = 0.3;
float weightLight = 0.2;
// 100 at the ideal, falling away by "falloff" points per unit of error
float scoreValue(float value, float ideal, float falloff)
{
float error = abs(value - ideal);
float score = 100.0 - error * falloff;
return constrain(score, 0, 100);
}
void setup()
{
analogReadResolution(10); // ESP32 is 12-bit; use 0-1023 like the examples
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();
int light = map(analogRead(34), 0, 1023, 0, 100);
if (isnan(t) || isnan(h))
{
delay(2000);
return;
}
float tScore = scoreValue(t, idealTemp, 8.0);
float hScore = scoreValue(h, idealHum, 2.5);
float lScore = scoreValue(light, idealLight, 1.5);
float total = tScore * weightTemp + hScore * weightHum + lScore * weightLight;
String grade;
if (total >= 85) grade = "EXCELLENT";
else if (total >= 70) grade = "GOOD";
else if (total >= 50) grade = "FAIR";
else grade = "POOR";
Serial.print("T:"); Serial.print(tScore, 0);
Serial.print(" H:"); Serial.print(hScore, 0);
Serial.print(" L:"); Serial.print(lScore, 0);
Serial.print(" Total:"); Serial.println(total, 0);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("CLIMATE SCORE");
display.setTextSize(3);
display.setCursor(0, 12);
display.print((int)total);
display.setTextSize(1);
display.setCursor(56, 20);
display.print("/100");
display.setCursor(56, 30);
display.print(grade);
// Three small score bars
int scores[3] = {(int)tScore, (int)hScore, (int)lScore};
const char* labels[3] = {"T", "H", "L"};
for (int i = 0; i < 3; i++)
{
int y = 42 + i * 7;
display.setCursor(0, y);
display.print(labels[i]);
display.drawRect(10, y, 102, 6, SSD1306_WHITE);
display.fillRect(11, y + 1, map(scores[i], 0, 100, 0, 100), 4, SSD1306_WHITE);
display.setCursor(114, y);
display.print(scores[i] / 10);
}
display.display();
delay(1500);
}
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.
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.
The LDR and the 10k resistor must meet at the analog GPIO: LDR to 3V3, resistor to GND.
Each reading is first scored on its own from 0 to 100, using distance from the ideal value: sitting exactly on target scores 100, and the score falls off as the reading drifts away. Those three scores are then blended with weights that add up to 1.0, temperature counts for half, humidity a third, light the rest. Changing a weight changes what the system considers important without touching any of the scoring code.
A large score such as 82 /100 with the grade GOOD. Three horizontal bars showing the temperature, humidity and light sub-scores. Cover the LDR and the L bar shrinks, pulling the total down a little.
Yes. It is project 49 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), Carbon Film Resistor 1/4W 5% (Pack of 10), 0.96" OLED Display 128x64, Generic DHT11 Digital Temperature & Humidity Sensor Module, 5 mm LDR Light Dependent Resistor 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 advanced project and takes about 30 minutes. The build on this page has 6 steps.
No. This page has the complete, tested code (titan_kit_049_room_climate_score.ino).
About ₹885 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Weighted data aggregation; Scoring by distance from an ideal value; Why weights must sum to one; Turning several readings into one comparable figure.
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.