Inspiration

Schools make energy decisions every day - a thermostat change, dimmed lights, a device policy - but almost none of those decisions are tested before they reach a real classroom.

We kept seeing the same pattern: energy tools were either dashboards that reported the past, or black-box AI that produced numbers nobody could trust. For Earth Forward, we asked a sharper question:

What if a classroom had a safe, deterministic twin where every change could be simulated, optimized, and explained before it happened?

EcoTwin is our answer. It turns "observe a classroom" into "simulate a classroom," and turns opaque recommendations into a traceable decision loop:

Physical world -> digital twin -> simulate -> optimize -> recommend -> impact -> grounded explanation

Buildings are a major driver of global energy use, and a classroom is the perfect place to prove that a small, explainable decision can be tested and understood before it affects real people, real budgets, and the climate. That is the heart of Earth Forward: cutting wasted energy and building climate literacy one decision at a time.

What it does

EcoTwin is an end-to-end energy decision twin, built for classrooms first.

  • A living classroom twin visualizes geometry, occupancy, schedules, controls, equipment, and environmental context in one spatial, perspective-based scene.
  • A deterministic physics engine models bidirectional HVAC, lighting, device loads, occupant sensible heat, electricity, CO2, and cost.
  • A constrained optimizer searches 455 feasible configurations - it saves energy, but it cannot cheat by turning the room off entirely.
  • A scenario engine tests three real-world situations: Heatwave Tomorrow, Empty Classroom, and Eco Mode.
  • A clear Current -> What-if -> EcoTwin Response flow keeps every saving attached to an explicit comparison basis.
  • A sensor-informed mode combines Arduino indoor temperature and humidity with Open-Meteo outdoor context through a transparent psychrometric model.
  • Space presets - Classroom, Open office, and Gymnasium - reuse the same engine to show the demo scaling beyond one room.
  • Impact at scale shows what happens if an entire campus follows the same plan.

Most importantly: the numbers come from EcoTwin. AI only explains them.

How we built it

EcoTwin is built with Next.js, React, TypeScript, and Tailwind CSS, deployed on Vercel. The analytical core is deliberately isolated from every external provider - determinism is the source of truth.

The daily modeled energy is a transparent sum:

$$ E_{\mathrm{daily}} = E_{\mathrm{HVAC}} + E_{\mathrm{lighting}} + E_{\mathrm{devices}} $$

HVAC load comes from a signed thermal balance between envelope heat transfer and occupant heat gain:

$$ Q_{\mathrm{net}} = A\,U\,(T_{\mathrm{out}} - T_{\mathrm{set}}) + n\,q_{\mathrm{person}} $$

$$ E_{\mathrm{HVAC}} = \frac{|Q_{\mathrm{net}}|\,h}{1000\,\mathrm{COP}} $$

Annual energy, carbon, and cost scale directly from that daily result:

$$ E_{\mathrm{annual}} = E_{\mathrm{daily}}\,D_{\mathrm{year}}, \qquad C = E\,I_{\mathrm{grid}}, \qquad \mathrm{Cost} = E\,p $$

The decision core is a chain of isolated, typed layers:

  • Immutable Digital Twin snapshot - classroom definition, operating state, and environmental context are frozen and hashed, so every result carries full provenance.
  • Deterministic physics engine - bidirectional heating/cooling, lighting, device loads, occupant heat, schedules, electricity, CO2, and cost.
  • What-if engine - parameterized futures that never mutate the baseline state.
  • Constrained optimizer - grid search over feasible thermostat, lighting, and device combinations.
  • Impact analysis - deterministic savings, emissions, and component-level contribution.
  • Grounded explanation - a provider-neutral adapter that passes structured evidence to AI and validates every returned section. Cloudflare Workers AI is the production provider, with a deterministic fallback.

On the sensing side, an Arduino Edge Node reads a DHT11 sensor and streams newline-delimited JSON over Web Serial into the browser. Indoor readings feed a humidity-aware HVAC estimate, clearly labeled as a modeled estimate rather than measured consumption. Open-Meteo supplies outdoor weather context, with an explicit fallback when requests fail.

We built it with Vitest: 253 automated tests across 37 test files, covering simulation, optimization, scenarios, impact, decision, sensor mode, hardware validation, API routes, and server-rendered components.

Challenges we ran into

Scientific honesty was the hardest challenge. It would have been easy to make the model look more powerful by mixing measured data with modeled predictions, or by calling it an "AI optimizer." We spent real effort drawing clear boundaries: a daily sensor result is a current-condition modeled estimate, while monthly and annual values are illustrative same-condition extrapolations - never measured consumption or weather-normalized forecasts.

Keeping AI grounded. Generative output is persuasive but unreliable with numbers. We made the simulation and optimizer the only source of numerical truth, then validated every AI section and fell back automatically when provider output cannot be trusted.

Modeling an empty room honestly. "Empty classroom" does not mean "zero energy" - systems stay on and the envelope still transfers heat. We modeled occupancy removal without pretending the building stops consuming.

An optimizer that cannot cheat. Turning everything off would trivially win. We constrained the search to realistic thermostat, lighting, and device-allowance ranges so Eco Mode has to find a genuinely efficient plan.

Real hardware is unforgiving. Web Serial only works in Chromium browsers, one application can own a serial port at a time, and stale or noisy DHT11 readings can never be shown as current. We built protocol validation, disconnect recovery, stale-telemetry detection, and explicit unsupported-browser messaging.

Accomplishments that we are proud of

  • A trustworthy end-to-end decision loop - physical context -> digital twin -> simulate -> optimize -> recommend -> impact -> grounded explanation - working live in the browser.
  • A 24.2% modeled daily-energy reduction for the default classroom's Eco Mode plan, found across 455 feasible configurations.
  • 253 passing tests across 37 files, so every number users see is reproducible, not vibes.
  • "The numbers come from EcoTwin. AI explains them." - a grounded-AI design that keeps calculation deterministic and AI honest.
  • Real hardware, not a mockup - an Arduino Edge Node streams actual indoor temperature and humidity into the twin over Web Serial.
  • Honest modeling as a feature - explicit assumptions, limitations, and clear labeling of estimates versus measurements.

What we learned

  • There is a huge gap between monitoring energy and deciding what to do; the hard part is making a decision explainable, not making a dashboard.
  • Grounding AI changes how you build. AI is great at explanation and dangerous at calculation, so we kept numbers deterministic and treated AI as a translator of evidence.
  • Scientific honesty matters in climate tech. A model that admits its assumptions earns more trust than one that pretends to be a utility meter.
  • Constraints make optimization meaningful. A fair optimizer needs boundaries, or it will simply turn everything off and call it a win.
  • Hardware reality is humbling. Sensor placement, calibration, browser support, and stale data all matter far more than expected.

What is next for EcoTwin

The product direction is Classroom -> Building -> Campus -> Portfolio. Closer in, we want:

  • Higher-fidelity hourly simulation (solar gain, thermal mass, equipment curves)
  • Calibrated energy-meter integration to validate modeled estimates against real consumption
  • More sensors - occupancy, CO2, and light - for richer context
  • Building-management-system integration for closed-loop control
  • Carbon-intensity-aware optimization that shifts load toward cleaner grid hours
  • Uncertainty and confidence bands around modeled outputs

EcoTwin is not just an energy dashboard, an energy calculator, or a sensor project. It is an end-to-end Energy Decision Digital Twin built around one principle:

Simulate before you change.

Built With

  • arduino
  • artificial-intelligence
  • climate-tech
  • cloudflare-workers-ai
  • data-visualization
  • dht11
  • digital-twin
  • energy-efficiency
  • iot
  • next.js
  • open-meteo
  • react
  • sensor
  • simulation
  • sustainability
  • tailwindcss
  • typescript
  • vercel
  • vitest
  • web-serial
Share this project:

Updates

Submission history