
Smoke & Gas Leak Alarm Over 4G SIM — Automatic SMS + Phone Call Alerts
ESP32 reads an MQ-2 sensor to detect smoke and gas leaks, and when the level crosses the threshold it automatically sends an SMS and then calls twice, two minutes apart, over a SIM A7680C 4G module.
This device uses an MQ-2 gas sensor to detect smoke and leaking gas (LPG, kitchen gas, fire smoke) indoors. When the concentration crosses a safe threshold, the ESP32 triggers a local buzzer/LED, and drives a SIM A7680C 4G module to send a warning SMS, then place two follow-up warning calls two minutes apart to a configured phone number, using a Vinaphone SIM with voice + SMS support.
Detailed guide
ESP32 + MQ-2 + SIM A7680C: detects smoke/gas, sends an SMS, then places two warning calls two minutes apart, using a Vinaphone SIM.
1. Introduction & How It Works
Gas leaks (LPG/kitchen gas) and smoke from fire are two common household risks, especially when no one is home to catch them in time. This device uses an MQ-2 gas sensor (detects LPG, propane, methane, smoke, H₂) to continuously measure gas concentration in the air. When the reading crosses the configured threshold:
- The local buzzer and warning LED turn on immediately
- The ESP32 drives the SIM 4G A7680C module to send one warning SMS to the configured phone number
- The device then places two warning calls, two minutes apart — a call is harder to miss than a text, since a ringing/vibrating phone grabs attention even if the owner isn't checking messages
The device uses a Vinaphone SIM supporting both SMS and voice — no WiFi or Internet needed, it works independently as long as there's cellular signal. The A7680C is a 4G LTE Cat.1 module, pin-compatible with the older SIM800L, but keeps working after Vietnam shuts down its 2G network (September 15, 2026).
2. ⚠️ Important Safety Notes — Read Before Installing
This is an educational/reference DIY project, not a certified fire/gas alarm device (e.g. TCVN-compliant or fire-safety certified). Do not use it as a replacement for:
- Certified smoke/gas detectors installed per residential fire-safety regulations
- Automatic gas shutoff valves or emergency ventilation systems
Technical limitations to be aware of:
- The MQ-2 needs a "burn-in" period of about 24–48 hours after first power-up for readings to stabilize; data during this time isn't reliable
- The alert threshold (NGUONG_GAS) must be calibrated in the real environment for your specific sensor and setting — the default value in the code is only a starting point
- If power or cellular signal is lost, the device cannot send an alert — consider adding a UPS/backup battery for critical applications
- This does not replace manual periodic checks of gas tanks, hoses, and shutoff valves
3. Installation Notes
Powering the SIM A7680C module is the easiest thing to get wrong: it needs a stable 3.3V–4.2V supply (VBAT) and can draw peak currents up to ~2A while connecting to the network — don't power it directly from the ESP32's 3V3 pin (the ESP32 DevKit's onboard LDO can't supply enough current, and will cause voltage drops/resets when the module is active). Use a separate external supply: a Li-Po/Li-ion battery through a charging circuit, or a 5V→3.7-4V buck converter rated ≥2A, with GND shared with the ESP32.
Plug the included SMA/IPEX antenna into the A7680C module for stable signal reception — without it, the module won't be able to register on the network.
4. Possible Future Extensions
- Add a relay to automatically cut power or close a gas valve when a leak is detected (needs a suitably-rated relay + PC817 opto-isolation)
- Log alert events to an SD card, or publish them over MQTT when WiFi is available
- Add a CO sensor (carbon monoxide is colorless and odorless, and the MQ-2 isn't sensitive to it) to broaden detection coverage