DEV Community

Arman Sinha
Arman Sinha

Posted on

PHANTOM ROOM: Giving a Room's Sensor Data a Ghost Story with Local AI

Hacktoberfest Open-Source AI Challenge: Ghost in the Machine Submission 👻🌼

This is a submission for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machines

What I Built

What happens in your room when nobody is watching?

At 2:14 AM, the temperature suddenly drops.

At 2:16 AM, the distance sensor records an unexpected change.

At 2:18 AM, another sensor picks up an unusual reading.

What if your room could tell you its own story?

That's the idea behind PHANTOM ROOM, an AI-powered environmental monitoring system that transforms sensor readings into mysterious, atmospheric narratives using locally running open-weight AI.

Rather than simply displaying numbers and graphs, Phantom Room gives environmental data a voice.

It combines an ESP32 with three sensor modules:

  • DHT11: Temperature and humidity monitoring.
  • HC-SR04: Ultrasonic distance monitoring.
  • MQ-2: Raw gas and smoke sensor readings.

The application continuously collects readings, identifies unusual patterns and records events in a chronological timeline.

But here's where it gets interesting.

A local AI model takes those observations and turns them into eerie investigative stories, supported by actual sensor evidence.

Some of its key features:

  • Five simulation scenarios: Normal Night, Temperature Anomaly, Unknown Movement, Gas Anomaly and Phantom Sequence.
  • Environmental anomaly detection: Rolling baselines, configurable thresholds and event cooldowns.
  • Multi-sensor anomaly detection: Identifies multiple anomalies occurring in the same sample.
  • Local AI storytelling: Generates atmospheric narratives using Ollama and an open-weight language model.
  • Offline fallback: A rule-based narrative generator keeps the application functional when Ollama is unavailable.
  • Investigation dashboard: Live sensor cards, telemetry graphs, event timelines and a Phantom Intensity Score.
  • Session recording and replay: Preserves historical readings and events, with CSV and JSON exports.

The application also supports a complete simulation mode, so the experience can be demonstrated without connecting physical hardware.

And no, it doesn't actually detect ghosts. It detects environmental anomalies and gives them a fictional narrative interpretation.

Demo

Phantom Room currently runs locally rather than on a publicly deployed server.

You can launch it using the instructions in the repository:

Run Phantom Room — Quick Start Guide

For the most interesting demonstration:

  1. Start the application.
  2. Select the Phantom Sequence scenario.
  3. Watch the sensor readings and anomaly timeline change.
  4. Generate a story using the local AI engine.
  5. Explore the recorded session and its sensor evidence.

The repository also includes a hackathon demo walkthrough.

Code

The complete source code, ESP32 firmware, documentation and implementation specification are available here.

🔮 PHANTOM ROOM

Environmental Intelligence System & Haunted Room Simulator

"Sometimes, the room remembers things we don't. Phantom Room gives those silent signals a voice."

Built for the Hacktoberfest Open-Source AI Challenge Week 4: Ghost in the Machine.

License: MIT Local AI: Ollama Backend: FastAPI + SQLAlchemy Frontend: React + TypeScript Hardware: ESP32 DevKit


1. Concept & Problem Statement

What happens in your room when nobody is watching?

Traditional IoT environmental monitors display sterile, clinical numbers—22.4 °C, 48% RH, 115 cm, 320 ADC. Human observers are left to squint at graphs to notice if a sudden cold snap preceded an unusual distance deflection and a chemical spike.

Conversely, ghost hunting mobile apps fabricate random spooky sounds without grounding their experience in actual physical reality.

Phantom Room bridges real physical sensing and local open-weight AI:

  • It streams real environmental readings from an ESP32 (or its built-in 5-scenario simulation engine).
  • A statistical Event Detection Engine monitors rolling baselines, detects single-sensor anomalies…

GitHub: https://github.com/ArmanSinha7/phantom-room

The project is released under the MIT License.

How I Built It

I wanted the project to combine three things: IoT, open-source AI and an unusual user experience.

1. The hardware layer

An ESP32 collects readings from the DHT11, HC-SR04 and MQ-2 sensors.

It transmits the readings to a FastAPI backend over the local network using HTTP.

I also built a simulation engine with five predefined scenarios, allowing the entire application to work without physical hardware.

Both simulated and hardware readings enter the backend processing pipeline.

2. The event detection engine

I implemented a Python-based anomaly detection engine.

It maintains a rolling window of up to 50 readings and calculates sensor baselines.

It compares incoming readings against configurable thresholds, identifies anomalies and uses cooldown periods to prevent repetitive alerts.

When multiple sensors cross their thresholds in the same sample, the system can generate a combined anomaly event.

3. The AI layer

This is the heart of Phantom Room.

I integrated Ollama with Qwen 2.5 3B as the default model.

Instead of sending data to an external AI API, the application sends structured sensor observations to a locally running language model.

The model generates a structured narrative containing:

  • A mysterious title.
  • An atmospheric story.
  • A chronological event sequence.
  • Supporting sensor evidence.
  • An eerie closing line.

The generated narrative must respect the actual observations rather than invent sensor readings.

When the local model is unavailable, a Python-based rule-driven fallback generator takes over.

4. The application

The frontend uses React, TypeScript, Vite, Tailwind CSS, Recharts and Lucide React.

The backend uses Python, FastAPI, SQLAlchemy and SQLite.

The dashboard refreshes sensor information periodically and presents it through a cinematic environmental monitoring interface.

I also implemented session recording, historical replay and downloadable reports.

Why Does Open Innovation Matter?

This project made me think about something beyond the Halloween theme.

Environmental data can be surprisingly personal.

A room's temperature patterns, sensor activity and monitoring history are data that I believe users should retain control over.

Using open-weight AI and local inference makes that possible.

Here is what the open-based approach provides:

1. Privacy by design

Ollama runs the language model locally. Sensor readings are stored in a local SQLite database instead of being sent to a third-party AI API.

2. Offline capability

Once dependencies and the language model have been installed, the application can perform its monitoring, simulation and AI inference without requiring an internet connection.

3. No paid AI API dependency

There are no per-request cloud AI API charges or mandatory external AI subscriptions.

The model runs using the user's own hardware resources.

4. Freedom to experiment

The default model is configurable. The application can be adapted to use other compatible Ollama models without rebuilding the entire application around a proprietary API.

5. Ownership and extensibility

The data, backend and AI integration remain under the user's control. Developers can modify the event detection logic, change the model, add sensors or create entirely new scenarios.

A closed API could generate a similar story, but local inference makes privacy, offline operation and model control fundamental parts of the experience rather than optional features.

For Phantom Room, that distinction matters.

The Spirit of It

The most interesting part of this project isn't the generated horror story itself.

It's the idea that ordinary environmental readings, when observed together, can become a narrative.

A temperature fluctuation is just a measurement.

A sudden distance change is just another measurement.

But when these observations occur together, they create a sequence worth investigating.

I wanted to build something that makes people curious about the invisible activity around them, while keeping the underlying evidence accessible and transparent.

No artificial supernatural detections. No pretending that fiction is science.

Just real sensor observations, open AI and a little imagination.

Sometimes, the room remembers things we don't. Phantom Room gives those silent signals a voice.

Top comments (0)