{"id":24375874,"url":"https://github.com/csvancea/fire-alarm","last_synced_at":"2026-04-20T09:35:02.167Z","repository":{"id":130856202,"uuid":"362118400","full_name":"csvancea/fire-alarm","owner":"csvancea","description":"Smart Fire Alarm. Connects to the local WiFi network and notifies the owner's phone/PC in case of fire (smoke + flame detection).","archived":false,"fork":false,"pushed_at":"2023-06-01T15:12:21.000Z","size":18294,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-18T23:23:47.626Z","etag":null,"topics":["arduino","esp32"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/csvancea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-04-27T13:16:21.000Z","updated_at":"2024-02-14T11:53:09.000Z","dependencies_parsed_at":null,"dependency_job_id":"3954a88c-9bfa-46ee-9f07-84228a640d53","html_url":"https://github.com/csvancea/fire-alarm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/csvancea/fire-alarm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csvancea%2Ffire-alarm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csvancea%2Ffire-alarm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csvancea%2Ffire-alarm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csvancea%2Ffire-alarm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/csvancea","download_url":"https://codeload.github.com/csvancea/fire-alarm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/csvancea%2Ffire-alarm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32041681,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-20T00:18:06.643Z","status":"online","status_checked_at":"2026-04-20T02:00:06.527Z","response_time":94,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","esp32"],"created_at":"2025-01-19T05:58:29.581Z","updated_at":"2026-04-20T09:35:02.126Z","avatar_url":"https://github.com/csvancea.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Fire Alarm - Internet of Things 2023](https://ocw.cs.pub.ro/courses/iothings/proiecte/2022sric/fire-alarm)\n\nAuthor: [Cosmin-Răzvan Vancea (SAS1)](csvancea@gmail.com)\n\n## Introduction\n\n- The purpose of this project is to create a smart *FireAlarm*. Upon fire\n  detection, the device will collect environmental data from the sensors and\n  send it to a remote server, which in turn will notify all the users about the\n  incident.\n- The FireAlarm also comes with an easy-to-use configuration app, which is\n  required to connect the FireAlarm device to a local Wi-Fi network.\n- Such a project could prove itself to be extremely helpful. In extreme cases,\n  a fire alarm could be a decisive factor for saving lives and goods.\n\n## Overview\n\n![fire-alarm-schema-logica.png](docs/img/fire-alarm-schema-logica.png)\n\n- Upon initialization, the microcontroller reads the configuration data from\n  its internal flash:\n  1. SSID and password of the Wi-Fi network;\n  2. URL of a remote server where the measurements must be sent to;\n  3. GUID that uniquely identifies the FireAlarm device (this ID is sent along\n  with each measurement).\n- The RGB led provides feedback to the user:\n  - green: the device was able to validate the configuration data and connect\n  to the remote server;\n  - red: there is valid configuration data stored inside the flash memory, but\n  it could not be used to connect to the server (network issue);\n  - blue: the device is in configuration mode (happens on the initial startup).\n- The microcontroller monitors the pins of the sensors;\n- If any sensor reads data that could indicate a fire, the ESP32 would query\n  all the sensors and send the data to the remote server. Also, it turns on\n  the buzzer alarm;\n- The remote server relays the fire signal to each user device that is\n  registered for notifications (smartphone, laptop etc).\n\n### Initial Setup/Configuration Mode\n\n\u003cimg align='right' src='docs/img/fire-alarm-schema-logica-configurare.png'\u003e\n\nIf the flash memory is empty or the user holds down the SETUP button while\nFireAlarm is starting up, then the device will switch to the configuration mode:\n\n- Wi-Fi starts in AP+STA mode, meaning that it would act as a hotspot;\n- a special WebServer is started. It listens to requests made to `192.168.4.1`\n(the IP of the FireAlarm on the local hotspot network);\n- the WebServer exposes a handful of REST API endpoints used to query and alter\nthe configuration;\n- once a client connects to the Wi-Fi hotspot and pushes a configuration, the\nFireAlarm would store it in the internal flash and restart itself to the normal\noperation mode.\n\nREST APIs implemented on the microcontroller:\n\n- `GET /api/v1/access-points`: returns a the list of Wi-Fi Access Points\naccessible to the FireAlarm device;\n- `GET /api/v1/settings`: returns the current configuration of the FireAlarm\ndevice;\n- `POST /api/v1/settings`: pushes a new configuration to the FireAlarm device;\n- `POST /api/v1/switch-mode`: forces the device to switch to the normal mode;\n- `POST /api/v1/ping`: echoes back the request. Useful to determine whether we\nare connected to a FireAlarm device.\n\n## Hardware Design\n\n### Components\n\n1. [WeMos LOLIN32](https://cleste.ro/placa-dezvoltare-esp-wroom-32-esp-32s.html)\n2. [MQ-2 Gas Sensor Module](https://www.optimusdigital.ro/en/gas-sensors/107-mq-2-gas-sensor-module.html)\n3. [IR Flame Sensor](https://www.optimusdigital.ro/en/optical-sensors/110-ir-flame-sensor.html)\n4. [Active Buzzer Module](https://www.optimusdigital.ro/en/buzzers/10-active-buzzer-module.html)\n5. [RGB LED Common Cathode](https://www.optimusdigital.ro/en/leds/483-rgb-led-common-cathode.html)\n6. [Resistors (3x 2.2k)](https://www.optimusdigital.ro/en/kits/4745-optimus-digital-resistor-assortment-kit-10-to-1m-600pcs-0616639927610.html)\n7. [Capacitors (1x 47uF)](https://www.optimusdigital.ro/en/capacitors/1880-electrolytic-condenser-from-10-uf-to-63-v.html)\n8. [Breadboard](https://www.optimusdigital.ro/en/breadboards/8-breadboard-hq-830-points.html)\n\n### Electronic Schematics\n\n![fire-alarm-schema-electrica.png](/docs/img/fire-alarm-schema-electrica.png)\n\n## Software Design\n\n### General Information\n\nWe will only focus on the microcontroller software.\n\nThe project is comprised of three main software components:\n\n1. [ESP32 Software](fire-alarm):\n  communicates with the sensors and sends the measurements to the remote server;\n2. [Remote Server](howl):\n  processes and stores the measurements; notifies the registered devices;\n  provides a web interface for visualizing the data;\n3. [Android Companion App](https://github.com/csvancea/howl-android):\n  consumes the configuration API and provides a human interface for setting up\n  the FireAlarm device; can also be used to visualize the data sent to the\n  remote server.\n\nWe will only focus on the microcontroller software.\n\n### ESP32 Software\n\nThe code is split into multiple \"modules\":\n\n- `SettingsManager`: manages the configuration data\n  - provides a mechanism for serializing and unserializing the data;\n  - provides an interface for reading and writing the configuration from/to\n  the flash storage.\n- `NetManager`: manages the Wi-Fi operation mode (station or client). Branches\ndown further in two modules:\n  - `NetClient`: the FireAlarm device acts as a client\n    - provides a mechanism for connecting to a remote web server through HTTPs;\n    - can only POST data (measurements).\n  - `NetConfigAP`: the FireAlarm device acts as a station (\"Hotspot\")\n    - implements a WebServer;\n    - the WebServer handles a series of REST API endpoints (explained above);\n    - can temporarily switch the Wi-Fi module to station mode in order to scan\n    for other APs.\n- `(Flame|Gas)Sensor`: abstraction layer for the sensors\n  - can register an interrupt on a pin;\n  - invokes a callback each time an interruption is raised (the value on the pin\n  changed);\n  - provides a mechanism for reading the sensor.\n- `Led`: abstraction layer for a 4-pin RGB led\n  - provides a way to change the color, intensity, blinking rate etc\n- `Buzzer`: abstraction layer\n- `FireAlarm`: puts together the components above; responsible for the general\nlogic of the program.\n\n### 3rd-party Libraries\n\nMoreover, the following 3rd-party libraries are used:\n\n- [ArduinoJson](https://arduinojson.org/): JSON serializer/deserializer. Used\nfor communicating through REST APIs and storing the configuration as a text\nfile.\n- [EasyButton](https://reference.arduino.cc/reference/en/libraries/easybutton/):\nabstraction layer for push buttons. Provides a debouncing mechanism and invokes\na user-defined callback on button press.\n\n### Interrupts\n\nDuring a network operation, the device might appear unresponsive due to the main\n`loop()` being busy processing the network request. In order to increase the\nresponsiveness of the FireAlarm device, **interrupts** are being used: each time\na sensor value changes, an interrupt is raised. The interrupt handler marks the\nevent for further processing in the main loop and changes the state of the\nbuzzer (on/off) so that the alarm appears to be responsive to the nearby people.\n\n### Server\n\nThe server software is written in [Flask](https://flask.palletsprojects.com/en/1.1.x/).\nIt is basically a web server that:\n\n- exposes an REST API endpoint for the ESP32 to post measurements to. Note that\neach POST request must contain the GUID of the FireAlarm, otherwise the server\nwould not be able to tell different devices apart;\n- provides a web interface for reading the measurement. The user must know the\nFireAlarm GUID.\n\nThe alarm notification is served though [PushBullet](https://pushbullet.com/).\nFor the notification mechanism to actually work, the user must associate a\nPushBullet token to their FireAlarm GUID. This operation can be done though the\nweb interface.\n\n### Android Companion App\n\nWritten in Java. It is basically a client that consumes both the API provided\nby the ESP32 (when in configuration mode) and the API provided by the remote\nweb server.\n\nThe app provides a step-by-step tutorial on how to configure the FireAlarm.\nAfter the configuration is done, the app stores locally the assigned GUID of\nthe FIreAlarm device so that the users are not needed to remember the GUID\nthemselves.\n\n## Results\n\n### FireAlarm Prototype\n\n![fire-alarm-photo.jpg](docs/img/fire-alarm-photo.jpg)\n![fire-alarm-photo-2.jpg](docs/img/fire-alarm-photo-2.jpg)\n\n### Web Interface\n\n![fire-alarm-web-interface.png](docs/img/fire-alarm-web-interface.png)\n![fire-alarm-phone-notification.png](docs/img/fire-alarm-phone-notification.png)\n\n### Android Companion App\n\n\u003cimg src='docs/img/fire-alarm-android-startup.jpg' height='600'\u003e \u003cimg src='docs/img/fire-alarm-android-config.jpg' height='600'\u003e \u003cimg src='docs/img/fire-alarm-android-interface.jpg' height='600'\u003e\n\n### Videos\n\n[![YouTube video](https://img.youtube.com/vi/ICl5pUPg5os/0.jpg)](https://www.youtube.com/watch?v=ICl5pUPg5os)\n\n[![YouTube video](https://img.youtube.com/vi/uGO8yVp4mvE/0.jpg)](https://www.youtube.com/watch?v=uGO8yVp4mvE)\n\n## Conclusion\n\nIt was a challenging and productive experience because I had to approach the\nproject from three different perspectives: a local system that collects data\nfrom sensors; a remote system that receives and processes measurements from\nmultiple devices; and a hybrid system that must communicate to both the local\nsystem (through a local network/\"Hotspot\") and to the remote system (through\nthe Internet).\n\n## Resources\n\n- [ESP32 Arduino Core’s documentation](https://docs.espressif.com/projects/arduino-esp32/en/latest/)\n- [Arduino ESP-32 Wi-Fi API](https://espressif-docs.readthedocs-hosted.com/projects/arduino-esp32/en/latest/api/wifi.html)\n- [Arduino ESP-32 WebServer library source code](https://github.com/espressif/arduino-esp32/tree/master/libraries/WebServer/src)\n- [ArduinoJson](https://arduinojson.org/)\n- [EasyButton](https://reference.arduino.cc/reference/en/libraries/easybutton/)\n- [Flask Documentation](https://flask.palletsprojects.com/_/downloads/en/1.1.x/pdf/)\n- [PushBullet API Documentation](https://docs.pushbullet.com/)\n- [Android API reference](https://developer.android.com/reference)\n- [TableView for Android](https://github.com/evrencoskun/TableView)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsvancea%2Ffire-alarm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcsvancea%2Ffire-alarm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcsvancea%2Ffire-alarm/lists"}