LPG gas leak alarm
A kitchen gas sniffer that beeps and flashes the moment LPG levels climb.
Shop by category
Shop all componentsDuring a drop, everything falls together and the accelerometer reads almost 0 g: that is how phones detect falls. When the box lands, the reading spikes. The MMA8452 is a 12-bit 3-axis accelerometer with a +-8 g range. The Nano checks the total acceleration 100 times a second, counts drops (near 0 g for over 100 ms) and hard knocks (over 3 g) and remembers the worst one.
Use a protected 18650 cell and pack it so it cannot be crushed.
Tick anything you already have and the total updates.
MMA8452 GY-45 3-axis accelerometer
Follow the colours: red is power, dark grey is ground, blue is a signal.
One 18650 through the 5 V module, so it can travel inside a parcel.
drop_logger.inoVerify & upload in Electrolark#include <Adafruit_SSD1306.h>
Adafruit_SSD1306 oled(128, 64, &Wire, -1);
#include <SparkFun_MMA8452Q.h>
#include <EEPROM.h>
MMA8452Q accel;
struct Log { uint16_t drops, knocks; float worst; } logd;
unsigned long lowSince = 0;
void setup() {
pinMode(3, INPUT_PULLUP);
Wire.begin();
oled.begin(SSD1306_SWITCHCAPVCC, 0x3C); oled.setTextColor(WHITE);
accel.begin(Wire, 0x1D);
accel.setScale(SCALE_8G);
EEPROM.get(0, logd);
if (digitalRead(3) == LOW || isnan(logd.worst)) { logd = {0, 0, 0}; EEPROM.put(0, logd); }
}
void loop() {
if (!accel.available()) return;
accel.read();
float x = accel.getCalculatedX(), y = accel.getCalculatedY(), z = accel.getCalculatedZ();
float g = sqrt(x * x + y * y + z * z);
bool changed = false;
if (g < 0.3) { if (!lowSince) lowSince = millis(); }
else {
if (lowSince && millis() - lowSince > 100) { logd.drops++; changed = true; }
lowSince = 0;
}
if (g > 3.0) { logd.knocks++; changed = true; delay(200); }
if (g > logd.worst) { logd.worst = g; changed = true; }
if (changed) EEPROM.put(0, logd);
static unsigned long lastShow = 0;
if (millis() - lastShow > 500) {
lastShow = millis();
oled.clearDisplay(); oled.setTextSize(1); oled.setCursor(0, 0);
oled.print("Drops "); oled.println(logd.drops);
oled.print("Knocks "); oled.println(logd.knocks);
oled.setTextSize(2); oled.setCursor(0, 30); oled.print(logd.worst, 1); oled.print(" g max");
oled.display();
}
}
Try address 0x1C in accel.begin().
The logger is loose in the box; pad it tightly.
The OLED uses power; turn it on only when a button is pressed for long trips.
Yes, while falling freely; tumbling can add a little spin.
It depends on the product; fragile electronics may be marked to survive around 30-50 g with packaging.
So the results survive if the battery runs down.
8 parts: MMA8452 GY-45 3-Axis Accelerometer Module – I2C Digital Output, Generic Nano CH340 Development Board (Soldered), 0.96" OLED Display 128x64, 5V 2A Charge-Discharge Integrated Module, 18650 Li-ion Rechargeable Cell, 18650 Battery Holder, 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 (drop_logger.ino).
About ₹767 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Free-fall detection; Measuring shock in g; Logging events to EEPROM.
Use a protected 18650 cell and pack it so it cannot be crushed.
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.