【DIY Electronics Project】Fire Hazard Alarm Based on BW21-CBV-Kit
In emergencies like fires, gas leaks, and explosions, a reliable safety monitoring system can be built using simple sensors such as a flame sensor, MQ-2 gas sensor, and a buzzer. Let technology be the first line of defense for life.
Core Components
- Flame Sensor Function: Detects open flames using infrared spectrum (wavelength 760nm~1100nm); responds within milliseconds. Use case: Ideal for flame-prone areas such as kitchens and living rooms.
- MQ-2 Smoke Sensor Function: Detects smoke, liquefied gas, methane, propane, and other flammable gases. Outputs analog signal (voltage increases with gas concentration). Advantages: Low cost, adjustable sensitivity. Suitable for gas leakage monitoring.
- Buzzer Function: Sound alert device.
- Camera Function: Provides real-time video for monitoring fire status or detecting false alarms. Can be integrated with push notifications or MQTT-based alerts and automation.
System Design & Implementation Steps
Hardware List
- Flame Sensor ×1
- MQ-2 Gas Sensor ×1
- BW21-CBV-Kit Development Board ×1
- Buzzer Module ×1
- XH2.54 Connectors
- Several Terminal Wires
- Flame Sensor → BW21-CBV-Kit Pin 20
- MQ-2 Sensor → BW21-CBV-Kit Pin A0 / GPIO11
- Buzzer → BW21-CBV-Kit Pin PWM / GPIO8
- Dual-Validation Mechanism: Trigger alarm only when both flame and smoke sensors are activated to reduce false alarms (e.g., candle flame).
- Remote Alerts: Push alarm notifications via MQTT apps or WeChat.
- Firefighting Linkage: Connect relay module to activate extinguishing devices (e.g., magnetic valve sprinkler system).
- Safety Tips:
- Regular Sensor Calibration: MQ-2 requires a 1-minute warm-up; test sensitivity monthly.
- Avoid high temperature/humidity: Long-term exposure may affect sensor lifespan.
- Emergency Evacuation Plan: After alarm is triggered, prioritize evacuation and contact emergency services.
Sample Core Code (Arduino)
This project uses the ArduinoJson library for JSON conversion. The syntax may vary by version. Example:
JsonDocument doc;
DynamicJsonDocument doc(1024);
Using incorrect syntax may result in compilation errors.
HA-MQTT Configuration
Use Docker to access the Home Assistant container and edit configuration.yaml. Always back up the original file before modification. Add the necessary YAML configuration (ensure correct indentation). Reload the YAML configuration to apply changes.
3D Case Design
Designed using FreeCAD.
MQ-2 Sensor: includes a small window to allow gas intake (airflow slightly restricted).
Flame Sensor: tapered hole for better detection.
Buzzer: salvaged from a POS machine; mismatched shape, directly wired.
Type-C port: side opening using a female connector.
- V and 5V (MQ-2 VCC + Flame VCC) wired in parallel
- G and GND also wired in parallel
- Data pin left unconnected
- Debugging port: Not reserved in this version. Wi-Fi credentials were hardcoded since BLE provisioning was unclear.
- Camera: Stream less smooth compared to AiPi-Cam-D200. Planning a revision using AiPi-Cam-D200 for better results and a more compact design.
Front view: 3D printed result is slightly rough. Poor support caused warping.
Internal structure: Terminal connectors are convenient, solder-free, and secure.
Side view: Powered by Type-C connector.
Ai-Thinker
Boris Landoni
CaptMcAllister
Simon Trendel