LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsParking sensors in car parks often use magnetometers buried in the ground. A car parked within a metre or two changes the field by a clearly measurable amount. The Adafruit MMC5603 is a precise 3-axis magnetometer on a STEMMA QT board. The ESP32 learns the empty-driveway field, then flags a car when the total change goes over a threshold, and logs times over serial.
Tick anything you already have and the total updates.
Adafruit MMC5603 3-axis magnetometer
Follow the colours: red is power, dark grey is ground, blue is a signal.
USB charger in a dry spot; the sensor can be a few metres away on a 4-core cable.
car_detector.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
#include <Adafruit_MMC56x3.h>
Adafruit_MMC5603 mag(12345);
float bx, by, bz;
const float CAR_UT = 8.0; // microtesla change that means a car
bool car = false;
void readMag(float &x, float &y, float &z) { sensors_event_t e; mag.getEvent(&e); x = e.magnetic.x; y = e.magnetic.y; z = e.magnetic.z; }
void setup() {
Serial.begin(115200);
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE);
mag.begin(MMC56X3_DEFAULT_ADDRESS, &Wire);
float sx = 0, sy = 0, sz = 0;
for (int i = 0; i < 100; i++) { float x, y, z; readMag(x, y, z); sx += x; sy += y; sz += z; delay(100); }
bx = sx / 100; by = sy / 100; bz = sz / 100;
}
void loop() {
float x, y, z; readMag(x, y, z);
float d = sqrt(sq(x - bx) + sq(y - by) + sq(z - bz));
if (!car && d > CAR_UT) { car = true; Serial.printf("%lu s: car arrived\n", millis() / 1000); }
if (car && d < CAR_UT * 0.5) { car = false; Serial.printf("%lu s: car left\n", millis() / 1000); }
oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0); oled.print("Change "); oled.print(d, 1); oled.print(" uT");
oled.setTextSize(2); oled.setCursor(0, 30); oled.print(car ? "CAR" : "Empty");
oled.display();
delay(200);
}
A metal gate, scooter or cable with current is near; move the sensor or raise CAR_UT.
The sensor is too far from the car; under 1.5 m works best.
Temperature changes; learn the baseline again now and then when the spot is empty.
Sometimes; a scooter has less steel, so set the threshold lower and expect false alarms.
Yes, in a sealed box a few centimetres down, as long as the cable is protected.
No, it only measures magnetic field, so there is no privacy issue.
5 parts: Adafruit MMC5603 Triple-Axis Magnetometer Sensor – I2C/SPI Interface, STEMMA QT, ESP32-WROOM-32 38-Pin Development Board, 0.96" OLED Display 128x64, 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 intermediate project and takes about 2 hours. The build on this page has 5 steps.
No. This page has the complete, tested code (car_detector.ino).
About ₹1,604 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
How cars disturb the Earth's magnetic field; Learning a baseline and detecting change; Hysteresis to avoid flicker.
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.