This project builds a real-time fire alarm system (RTOS) using temperature and gas sensors to detect potential fire risks and provide early warnings. The system utilizes FreeRTOS to manage multitasking, ensuring fast and stable response times.
CLIENT SIMULATION: RECEIVE DATA FROM SENSORS AND SEND TO SERVER
SERVER SIMULATION: RECEIVE DATA FROM CLIENT AND ISSUE ALERTS
- Microcontroller: ESP32 with FreeRTOS support
- Sensors:
DHT11
– measures temperature and humidityMQ-2
– detects gas (LPG, CO, smoke)
- RTOS: FreeRTOS
- Communication: TCP/IP (between ESP32 and Java Server)
- Simulation Language: Java (Server/Client)
- Synchronization Techniques: Thread, Semaphore, Socket Programming
[ESP32 Client] -----------------------> [Java TCP Server]
(DHT11, MQ-2 Sensor) (Real-time Monitor)
| |
FreeRTOS Alarm thresholds
Multitask Visual warning UI
- Each sensor operates on a separate thread and sends data periodically to the server.
- The server receives the data and displays it in real-time.
- If the values exceed a threshold, a warning system is triggered (via UI or indicator).
- Initializes FreeRTOS tasks:
readTempTask
– reads data from DHT11readGasTask
– reads data from MQ-2
- Sends data via TCP socket to the server.
- Listens for connections on port
12345
. - Each sensor connection is handled in a separate thread.
- Displays real-time values and triggers warnings when thresholds are exceeded.
- Client: Sensor simulation runs in Java (each sensor is a
SensorThread
) and sends periodic data. - Server: Displays sensor values and triggers alerts when thresholds are exceeded.
✅ Example threshold values:
- Temperature > 50°C
- Gas concentration > 70 ppm
- Real-time response using RTOS.
- Each sensor runs independently, reducing data bottlenecks.
- System is easily extensible for adding more sensors or clients.
- Supports integration with GUI monitoring tools.
javac SensorServer.java
java SensorServer
javac SensorClient.java
java SensorClient
📌 Make sure the IP address and port match (default
127.0.0.1:12345
)
📁 RealTimeFireAlarmRTOS/
│
├── 📁 src/
│ ├── SensorServer.java
│ ├── SensorClient.java
│ ├── SensorThread.java
│
├── 📁 esp32/
│ ├── main.ino # FreeRTOS code for ESP32
│
├── README.md
└── presentation.pdf # Optional: converted from PowerPoint
- This is an academic project, open-source and ready to be expanded with features like:
- Email/SMS alert integration
- Automatic fire suppression control
- Cloud service integration
This project is for educational and non-commercial research purposes.