LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsSimulate a growing environment that tracks temperature, humidity and light against a target range and reports what needs adjusting. This is a control loop with three parallel channels. Each one has an ideal band, and each reports one of three states: too low, in range, or too high. The overall verdict is simply how many channels are in range. Real greenhouse controllers work exactly this way before they act, they establish the error on every channel first, then decide which actuator to move, because heating the air also changes the humidity.
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
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_048_greenhouse_environment_mon.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 statusLeds[3] = {27, 26, 25};
float tempMin = 20, tempMax = 28;
float humMin = 50, humMax = 75;
int lightMin = 40, lightMax = 90;
// -1 too low, 0 in range, 1 too high
int check(float value, float low, float high)
{
if (value < low) return -1;
if (value > high) return 1;
return 0;
}
String describe(int state, String name, String lowWord, String highWord)
{
if (state < 0) return name + " " + lowWord;
if (state > 0) return name + " " + highWord;
return "";
}
void setup()
{
analogReadResolution(10); // ESP32 is 12-bit; use 0-1023 like the examples
for (int i = 0; i < 3; i++)
{
pinMode(statusLeds[i], OUTPUT);
}
Serial.begin(9600);
dht.begin();
if (!display.begin(SSD1306_SWITCHCAPVCC, 0x3C))
{
Serial.println("OLED not found");
while (true) { }
}
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
}
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;
}
int tState = check(t, tempMin, tempMax);
int hState = check(h, humMin, humMax);
int lState = check(light, lightMin, lightMax);
digitalWrite(statusLeds[0], tState == 0);
digitalWrite(statusLeds[1], hState == 0);
digitalWrite(statusLeds[2], lState == 0);
int inRange = (tState == 0) + (hState == 0) + (lState == 0);
String action = "";
if (action == "") action = describe(tState, "Heat:", "raise", "vent");
if (action == "") action = describe(hState, "Mist:", "on", "dehumidify");
if (action == "") action = describe(lState, "Lamp:", "on", "shade");
if (action == "") action = "All conditions ideal";
Serial.print(t); Serial.print(" ");
Serial.print(h); Serial.print(" ");
Serial.print(light); Serial.print(" in range: ");
Serial.println(inRange);
display.clearDisplay();
display.setCursor(0, 0);
display.print("GREENHOUSE ");
display.print(inRange);
display.print("/3 OK");
display.setCursor(0, 14);
display.print("Temp ");
display.print(t, 1);
display.print("C ");
display.print(tState == 0 ? "OK" : (tState < 0 ? "LOW" : "HIGH"));
display.setCursor(0, 26);
display.print("Humid ");
display.print(h, 0);
display.print("% ");
display.print(hState == 0 ? "OK" : (hState < 0 ? "LOW" : "HIGH"));
display.setCursor(0, 38);
display.print("Light ");
display.print(light);
display.print("% ");
display.print(lState == 0 ? "OK" : (lState < 0 ? "LOW" : "HIGH"));
display.drawLine(0, 50, 127, 50, SSD1306_WHITE);
display.setCursor(0, 54);
display.print(action);
display.display();
delay(1000);
}
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.
This is a control loop with three parallel channels. Each one has an ideal band, and each reports one of three states: too low, in range, or too high. The overall verdict is simply how many channels are in range. Real greenhouse controllers work exactly this way before they act, they establish the error on every channel first, then decide which actuator to move, because heating the air also changes the humidity.
Three rows showing temperature, humidity and light each marked OK, LOW or HIGH. The header counts how many are in range, such as 2/3 OK. One LED per channel lights when that channel is within its band.
Yes. It is project 48 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.
11 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), 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, plus 1 more. 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 7 steps.
No. This page has the complete, tested code (titan_kit_048_greenhouse_environment_mon.ino).
About ₹939 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Environmental control loops; Three-state checks instead of simple booleans; Prioritising one action from several faults; Why channels interact in a real controller.
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.