Student prototype
Smart Indoor Safety and Environmental Monitoring System
An ESP32 model-house prototype combining environmental sensing, local alerts, automated outputs and a Wi-Fi / HTTPS cloud dashboard.
Chathuranga Polkotuwa & Suad Abujarad
Wireless Sensor Networks · Kristianstad University, Sweden
Presented 26 May 2026 · Model-house prototype
Explore the ESP32 firmware
The supplied complete sketch is now available as a credential-free teaching copy, with step-by-step explanations, sensor examples and logic diagrams. It clarifies output-polarity, sensor-fault and security limitations not visible in the report excerpts.
Code & step-by-step walkthrough6
Monitored conditions
2 s
Configured cloud interval
2
Servo mechanisms
Educational prototype, not a certified safety system. Photos and dashboard readings come from the supplied materials. No live hardware connection or safety guarantee is implied.
Architecture and communication
This team project joins five sensor modules, an ESP32, local decision logic and a cloud-hosted web dashboard. The DHT11 supplies two environmental measurements, so the system observes six quantities or conditions: temperature, humidity, gas-sensor level, flame, movement and brightness. The ESP32 was chosen for its integrated Wi-Fi, mixed analog/digital GPIO, affordability and Arduino ecosystem.
The documented final implementation uses Wi-Fi, HTTPS POST and JSON—not MQTT or Node-RED. Those technologies appeared in the earlier portfolio summary, but are not the communication stack described in these supplied materials. The separate ESP32/MQTT wireless-sensor-network project remains unchanged.
At startup, firmware initializes the serial connection, GPIO, DHT11 and servo motors, then connects to Wi-Fi. It reads inputs, evaluates conditions and updates the local buzzer, status LED, room light, relay and window servo. Sensor readings and actuator states are sent to the cloud approximately every two seconds. The server response can carry a door command, which the ESP32 converts into a servo position.
The reporting interval is 2,000 ms. This is a configured transmission cadence, not a measured alarm-response time or delivery guarantee. Local decision logic is distinct from dashboard communication; however, startup waits for Wi-Fi in the supplied flowchart, and offline behavior has not been verified. The subsequently supplied full sketch is reviewed on the linked code walkthrough: it disables server-certificate verification and uses a device-secret header. Cloud-side authorization is not supplied; review the walkthrough before reproducing the example.
Two paths, one controller
Local output path
Buzzer, RGB status, room light, relay and model window
Monitoring + command path
Wi-Fi → HTTPS POST / JSON → cloud dashboard
Cloud response → ESP32 → door servo
Hardware and GPIO map
The physical prototype is a model house with a breadboard-based ESP32 circuit. Inputs include a DHT11, an MQ-series gas sensor, a PIR sensor, a flame module and an LDR. Outputs include a buzzer, RGB status LED, room-light LED, relay and two SG90 servo motors. One servo moves the model window; the other demonstrates remote door operation. The presentation also lists an external battery pack.
The table below reproduces the report's GPIO assignments. It is a signal map, not a complete electrical wiring diagram. Supply voltages, resistor values, relay polarity and protection circuitry are not fully specified. Before reproducing the build, confirm the exact board and sensor variants, ensure analog signals stay within ESP32 input limits, and use an appropriately rated supply for the actuators with a shared signal ground.
| Component | GPIO | Signal | Role |
|---|---|---|---|
| DHT11 | 4 | Digital input | Temperature and humidity |
| MQ-series gas sensor | 35 | Analog input | Raw gas-sensor reading |
| PIR motion sensor | 27 | Digital input | Motion detection |
| Flame sensor | 13 | Digital input | Active-low flame indication |
| LDR | 34 | Analog input | Ambient brightness |
| Buzzer | 25 | Digital output | Local audible indication |
| RGB LED — red | 16 | Digital output | Status indicator channel |
| RGB LED — green | 17 | Digital output | Status indicator channel |
| RGB LED — blue | 18 | Digital output | Status indicator channel |
| Relay | 23 | Digital output | Temperature-based load simulation |
| Window servo | 19 | PWM | Prototype window mechanism |
| Door servo | 14 | PWM | Remote door mechanism |
| Room light LED | 22 | Digital output | Motion + darkness lighting |
Firmware and automation rules
The firmware was developed in Arduino IDE using C++ and the WiFi, HTTPClient, WiFiClientSecure, DHT and ESP32Servo libraries. The following excerpts are transcribed from the report. They illustrate decision rules, not a complete compilable program.
Environmental measurements
The DHT library supplies temperature and relative humidity readings:
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
A production-oriented implementation would also need invalid-reading handling, sensor fault reporting and explicit sampling schedules. These are not established by the excerpt.
Motion-aware room lighting
The room-light LED turns on only when the LDR reading is below 2,500 and the PIR input is HIGH. Brightness alone or motion alone is not enough:
bool roomDark = (ldrValue < 2500);
bool motionDetected = (motionValue == HIGH);
bool roomLightOn = (roomDark && motionDetected);
The LDR threshold is a raw ADC comparison for this setup, not a calibrated lux measurement. The design avoids unnecessary illumination when the room is bright or unoccupied; no measured energy savings are provided.
Gas and flame indication
The report treats a gas ADC reading above 1,300 as an event, and a LOW flame input as flame detection. Either condition selects the prototype's danger state:
bool flameDetected = (flameValue == LOW);
bool gasDetected = (gasValue > 1300);
bool dangerDetected = gasDetected || flameDetected;
The MQ reading is not a calibrated gas concentration in ppm. The exact MQ model, calibration curve, reference gas and validated detection threshold are not supplied. Equality at 1,300 does not satisfy the report's strict greater-than comparison.
In the documented response, the buzzer activates, the RGB status changes and the window servo moves to 90°. The report says the window closes again after the danger condition disappears; the flowchart shows 0° as the closed door position and 90° as open.
bool windowOpen;
if (dangerDetected) {
digitalWrite(buzzerPin, HIGH);
setRGB(LOW, HIGH, LOW);
windowServo.write(90);
windowOpen = true;
Serial.println("Danger! Buzzer ON, Window OPEN");
}
The report prose describes a red warning LED. The subsequently supplied full sketch defines an inverted common-anode helper, so this danger call requests green and the normal branch requests red. Buzzer pin levels also conflict with the active-low startup comment. The linked code walkthrough explains the exact commands without assuming the physical wiring.
Safety boundary: This is an educational model, not a certified fire or gas alarm. Automatic window opening is a demonstrated mechanism, not a generally safe response to fire or gas. Appropriate real-world responses depend on the hazard and must be professionally designed. Do not recreate testing with released gas or open flames; use simulated input states under supervision. Keep mains loads out of the student model.
Temperature relay and cloud timing
The report's relay snippet activates the output below 27°C. It alternately describes the load as a heater and a fan, so this page calls it a temperature-based relay/load simulation rather than claiming a verified heating or cooling installation.
if (temperature < 27) {
digitalWrite(relayPin, HIGH);
relayOn = true;
Serial.println("Temp < 27C -> Relay ON");
}
const unsigned long SEND_INTERVAL_MS = 2000;
The supplied flowchart describes the relay as off when that temperature condition is false. No hysteresis or minimum on/off times are implemented in the supplied full sketch. An invalid temperature leaves the relay pin unchanged while reporting relay_on as false; the linked walkthrough explains this discrepancy.
Documented danger-state logic
Gas ADC > 1,300
Raw threshold comparison
Flame input = LOW
Active-low digital detection
Buzzer ON · RGB status change · window servo to 90°
Dashboard and remote interaction
The web dashboard brings environmental readings and actuator states into a desktop/mobile view. The presentation lists temperature and humidity gauges, a gas-value graph, flame and motion indicators, window status, room-light indication and a door-control button. The source screenshots show normal and warning states; their values are snapshots from testing, not current measurements.
An example packet on presentation slide 17 contains:
{
"temperature": 26.5,
"humidity": 58,
"gas_detected": true,
"flame_detected": false,
"motion_detected": true
}
This is a supplied example payload, not a live reading or the full API schema. The report also describes brightness, relay and actuator-state fields, but does not provide their complete field definitions. Door commands return through the cloud response and are applied to the second servo. There is no live control connection on this portfolio page.
Implementation and testing
Development proceeded incrementally: establish ESP32-to-cloud communication, connect and inspect individual sensors in the Serial Monitor, verify each output, then integrate the model-house circuit. The Serial Monitor at 115200 baud supported inspection of measurements, actuator states and Wi-Fi communication messages.
The presentation credits Chathuranga Polkotuwa and Suad Abujarad. It describes Kanban planning with Jira, moving work through To Do, In Progress, Testing and Completed, and GitHub for version tracking and collaboration. The repository is shown in a screenshot; no new repository link is inferred from that image.
| Test area | Reported evaluation approach | Evidence boundary |
|---|---|---|
| DHT11 | Compare temperature/humidity with room conditions | No calibrated reference or error statistics supplied |
| PIR + LDR | Vary movement and illumination; observe room-light behavior | Functional check, not an occupancy-detection accuracy study |
| Gas + flame inputs | Observe transition into danger mode and output response | Reported laboratory testing; use simulated inputs for reproduction |
| Window and door servos | Observe automatic window response and remote door command | Demonstration mechanisms, not certified access/safety hardware |
| Temperature relay | Vary conditions and observe relay response | Load description and dashboard label require reconciliation |
| Cloud dashboard | Inspect readings, states and command responses | Approximately two-second updates reported; no delivery statistics |
The report states that the integrated prototype operated as intended, with occasional cloud/Wi-Fi delays of a few seconds. These are team-reported observations, not independently reproduced performance results. Neither document supplies a time-series dataset, test duration, accuracy distribution, power measurement or packet-loss log. Consequently, the diagrams on this page show architecture and logic—not invented performance curves.
Limitations and source discrepancies
Gas threshold mismatch. The firmware excerpt uses gasValue > 1300. The presentation's warning screenshot displays a gas value of 1284 with a gas warning. It may capture a different configuration, prior state or timing mismatch; the documents do not establish the cause. The report comparison is shown as documented, not asserted as the rule used by every dashboard screenshot.
Relay description mismatch. The report alternates heater and fan terminology and switches below 27°C. The warning screenshot labels 28.6°C as “Warm — relay active.” Without the firmware version and dashboard mapping, those representations cannot be reconciled. Neither is silently rewritten into a cooling specification.
Power claims are goals, not measurements. The presentation emphasizes low-power operation and battery support, but the report explicitly notes the gas sensor's heating element consumes relatively high power. There is no bill of materials total, current log or battery-runtime test, so quantified cost or battery-life claims are omitted.
Sensor limitations. DHT11 accuracy and response are limited; MQ readings depend on warm-up, temperature, air conditions and aging. Noise, mounting and threshold tuning can affect decisions. Calibration, filtering and hysteresis are useful next steps, not confirmed features of the supplied build.
Network and security limits. Cloud operation depends on Wi-Fi and internet availability. The supplied full sketch waits indefinitely for Wi-Fi at startup, disables certificate verification, lacks an explicit reconnect routine and uses whitespace-sensitive substring matching for door commands. The linked walkthrough documents these limitations; cloud-side authorization remains unverified. The academic demonstration does not establish suitability for unattended safety monitoring.
Setup and troubleshooting
- Install Arduino IDE, the ESP32 board package and the required libraries.
- Confirm the exact modules and electrical requirements before following the GPIO signal map. Connect only a safe, low-voltage model setup.
- Read the linked code walkthrough and download the credential-free sketch. Rotate the exposed original credentials and configure replacement values privately in your local copy; never publish them in a repository or screenshot.
- Select the correct ESP32 board and serial port, upload using a data-capable USB cable, and inspect startup at 115200 baud.
- Verify inputs and outputs individually before integration. Use controlled movement, lighting changes and simulated event inputs rather than hazardous gas/flame sources.
- Confirm dashboard updates and door-command behavior, including authorization and loss-of-network behavior, before relying on remote interaction.
| Symptom | Checks |
|---|---|
| Wi-Fi will not connect | Inspect credentials privately, signal strength and router connectivity |
| Dashboard shows no readings | Verify internet access, configured endpoint and device authorization; do not disable security controls |
| Gas readings drift | Follow the exact sensor manufacturer's warm-up/calibration procedure; the report's brief warm-up note is not a universal specification |
| DHT11 readings fail | Check supply, ground, data wiring and the module's pull-up requirements |
| Servo stalls or resets the ESP32 | Check signal mapping, mechanical movement, supply rating and shared ground |
| Room light stays off | Inspect PIR positioning, raw LDR value and the documented AND condition |
| Upload fails | Check board/port selection, USB data cable and driver installation |
Future development
The materials propose more accurate sensors, camera monitoring, AI-based prediction, push notifications, database logging, voice integration and solar/battery operation. These are future directions, not completed features. A stronger next iteration would first document the exact hardware, review the supplied credential-free firmware and its documented limitations, reconcile the dashboard rules, characterize sensor error and power draw, and test reconnect and fault behavior. That evidence would make later multi-node or intelligent-monitoring extensions easier to evaluate.
The main learning outcome is integration: bringing mixed sensor interfaces, state-based local outputs, structured network messages and a cross-device dashboard into one working academic prototype, while recognizing the difference between a successful demonstration and validated safety engineering.
Original project materials
This case study is based on the supplied 16-page report and 37-slide presentation. Original screenshots and excerpts are preserved with their limitations. The subsequently supplied full firmware is explained on the linked code page; calibration records, cloud server code and measured test logs remain unavailable.