LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsMap temperature onto a colour gradient so an RGB LED glows deep blue when cold and red when hot. The gradient runs blue → cyan → green → yellow → red across the working temperature range, and it is built by splitting that range into four bands and fading between two colours inside each. Because every band is a straight-line blend, the transitions join up smoothly. The same mapping-a-number-onto-a-colour-spectrum idea drives every thermal camera image and every heat map you have ever seen.
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
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_050_temperature_color_visualiz.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 redPin = 32;
int greenPin = 5;
int bluePin = 23;
float coldEnd = 15.0;
float hotEnd = 40.0;
int r, g, b;
void temperatureToColour(float t)
{
float position = (t - coldEnd) / (hotEnd - coldEnd);
position = constrain(position, 0.0, 1.0);
float band = position * 4.0; // Four bands across the gradient
if (band < 1) // Blue to cyan
{
r = 0;
g = band * 255;
b = 255;
}
else if (band < 2) // Cyan to green
{
r = 0;
g = 255;
b = (2 - band) * 255;
}
else if (band < 3) // Green to yellow
{
r = (band - 2) * 255;
g = 255;
b = 0;
}
else // Yellow to red
{
r = 255;
g = (4 - band) * 255;
b = 0;
}
}
void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, 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();
if (isnan(t))
{
delay(2000);
return;
}
temperatureToColour(t);
analogWrite(redPin, r);
analogWrite(greenPin, g);
analogWrite(bluePin, b);
Serial.print(t);
Serial.print("C -> R");
Serial.print(r);
Serial.print(" G");
Serial.print(g);
Serial.print(" B");
Serial.println(b);
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("COLOUR VISUALISER");
display.setTextSize(3);
display.setCursor(0, 14);
display.print(t, 1);
display.setTextSize(1);
display.setCursor(74, 22);
display.print("deg C");
display.setCursor(0, 40);
display.print("R");
display.print(r);
display.print(" G");
display.print(g);
display.print(" B");
display.print(b);
// Position marker along a gradient scale
display.drawRect(0, 52, 128, 10, SSD1306_WHITE);
int marker = map(constrain(t * 10, coldEnd * 10, hotEnd * 10),
coldEnd * 10, hotEnd * 10, 2, 124);
display.fillRect(marker, 54, 3, 6, SSD1306_WHITE);
display.setCursor(0, 44);
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.
Check that it is the common-cathode type with the longest leg to GND, and that red, green and blue go to the GPIOs in the table.
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 gradient runs blue → cyan → green → yellow → red across the working temperature range, and it is built by splitting that range into four bands and fading between two colours inside each. Because every band is a straight-line blend, the transitions join up smoothly. The same mapping-a-number-onto-a-colour-spectrum idea drives every thermal camera image and every heat map you have ever seen.
At 18°C the LED glows blue-cyan. At 25°C it settles to green. Warm the sensor in your hand and it moves through yellow towards red.
Yes. It is project 50 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), 5mm RGB LED (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_050_temperature_color_visualiz.ino).
About ₹907 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Mapping variables to colour spectrums; Building a gradient from linear bands; Normalising a value to a 0.0–1.0 position; How thermal images assign colour to data.
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.