LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsThe AM2301, also sold as the DHT21, is a capacitive humidity sensor in a plastic case with a cable, made for mounting outdoors under a shelter. It uses the same one-wire timing as the DHT22, so the usual DHT library reads it. The ESP32 stays indoors, reads the sensor every 30 seconds and serves a small page with the current reading and the day's high and low.
Tick anything you already have and the total updates.
Asair AM2301 wired temperature and humidity sensor
Follow the colours: red is power, dark grey is ground, blue is a signal.
5 V USB supply for the ESP32 indoors.
weather_post.inoVerify & upload in Electrolark#include <WiFi.h>
#include <WebServer.h>
#include <DHT.h>
DHT dht(4, DHT21);
WebServer web(80);
float t = NAN, rh = NAN, hi = -100, lo = 100;
void page() {
web.send(200, "text/html", "<meta name=viewport content='width=device-width'><meta http-equiv=refresh content=30>"
"<h2>Outside</h2><p style='font-size:2em'>" + String(t, 1) + " C, " + String(rh, 0) + "%</p><p>High " + String(hi, 1) +
" C, low " + String(lo, 1) + " C</p>");
}
void setup() {
Serial.begin(115200); dht.begin();
WiFi.begin("YOUR_WIFI", "YOUR_PASSWORD");
while (WiFi.status() != WL_CONNECTED) delay(300);
Serial.println(WiFi.localIP());
web.on("/", page); web.on("/reset", [] { hi = -100; lo = 100; web.send(200, "text/plain", "reset"); });
web.begin();
}
void loop() {
web.handleClient();
static unsigned long last = 0;
if (millis() - last < 30000) return;
last = millis();
float nt = dht.readTemperature(), nh = dht.readHumidity();
if (isnan(nt)) return;
t = nt; rh = nh; hi = max(hi, t); lo = min(lo, t);
}
Wrong colour code or missing pull-up; check the sensor label.
Sun is reaching it; move it into shade or under a louvred shield.
Phone and ESP32 must be on the same Wi-Fi.
It is splash resistant but should be kept under a cover from direct rain.
Yes, change DHT21 to DHT22; the AM2301 just has a tougher case and cable.
Open /reset on the same address, or restart the ESP32 at midnight.
6 parts: Asair AM2301 Capacitive Digital Temperature & Humidity Sensor – Digital 1-Wire Output, ESP32-WROOM-32 38-Pin Development Board, Resistor Assortment Kit (30 Values), Official Raspberry Pi 4 USB-C Power Supply – 15.3W, 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 beginner project and takes about 1-2 hours. The build on this page has 6 steps.
No. This page has the complete, tested code (weather_post.ino).
About ₹1,627 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Reading a DHT-family sensor; Keeping a daily high and low; Sheltering an outdoor sensor.
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.