Skip to content

ivanbard/goldilocks

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

24 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿป Goldilocks Kingston

Smart home climate advisor for Kingston, Ontario โ€” Real-time IoT sensors + AI-powered recommendations to optimize comfort, save money, and reduce carbon emissions.

Built for QHacks 2026.


๐ŸŒŸ Features

๐Ÿ  Smart Climate Control

  • Real-time monitoring with ESP32 + DHT11 sensor (temperature, humidity, pressure)
  • AI recommendations powered by Google Gemini 2.0 โ€” when to open windows, adjust thermostat, or use heating/cooling
  • Mold risk detection with historical humidity analysis
  • Indoor humidity estimation when sensor is offline

๐Ÿ’ฐ Energy Savings

  • Live Ontario electricity pricing (TOU/ULO/Tiered plans) with accurate time-of-use rates
  • Next rate preview โ€” see when prices change and plan accordingly
  • Cost calculator โ€” estimate heating/cooling costs in real-time
  • Savings tracker โ€” daily summaries of money saved vs. baseline behavior

๐ŸŒฑ Environmental Impact

  • Carbon footprint tracking โ€” kg COโ‚‚ avoided through smart ventilation
  • Community projections โ€” model citywide impact if Kingston households adopt Goldilocks
  • Equivalences โ€” trees planted, km not driven, household energy comparisons

๐Ÿค– AI Assistant

  • Conversational chat with live sensor data and weather context
  • Voice input/output (browser-native Web Speech API โ€” no dependencies)
  • Auto-generated suggestions โ€” proactive tips based on conditions, electricity rates, and weather forecasts

โ™ฟ Accessibility

  • Colorblind mode โ€” alternative color palettes (blue/teal/orange) for all visualizations
  • Toggle in settings โ€” persists via localStorage

๐Ÿ“Š Data Visualization

  • 24-hour humidity timeline with trend analysis
  • Forecast preview (3-hour intervals, precipitation probability)
  • Savings charts โ€” daily/monthly breakdowns
  • Carbon milestones โ€” cumulative impact with equivalences

๐Ÿ› ๏ธ Tech Stack

Layer Technologies
Frontend Next.js 14, React 18, Tailwind CSS, SWR, Recharts, Web Speech API
Backend Node.js, Express.js, better-sqlite3, Google Gemini AI SDK
Hardware ESP32 Dev Module, DHT11 Sensor (Keystudio)
APIs Google Gemini 2.0 (Flash/Flash-Lite), OpenWeatherMap
Database SQLite (local)
Deployment Vercel (frontend), Railway (backend, planned)

๐Ÿš€ Getting Started

Prerequisites

  • Node.js 18+ and npm
  • Arduino IDE (for ESP32 firmware)
  • ESP32 board + DHT11 sensor (optional โ€” demo mode works without hardware)

1. Clone the Repository

git clone https://github.com/yourusername/goldilocks-kingston.git
cd goldilocks-kingston

2. Install Dependencies

# Backend
cd backend
npm install

# Frontend
cd ../frontend
npm install

3. Environment Variables

Create a .env file in the project root:

# Required
GEMINI_API=your_gemini_api_key_here

# Optional
OPENWEATHERMAP_API_KEY=your_openweathermap_key  # For live weather (falls back to mock data)
DEMO_MODE=false                                   # Set to 'true' for simulated sensor data
BACKEND_PORT=3001

Get API keys:

4. Run the Backend

cd backend
npm run dev

Backend will start on http://localhost:3001

5. Run the Frontend

cd frontend
npm run dev

Frontend will start on http://localhost:3000

6. (Optional) Flash ESP32 Sensor

  1. Open esp32_sensor/esp32_sensor.ino in Arduino IDE
  2. Install DHT sensor library (Adafruit DHT) via Library Manager
  3. Update WiFi credentials and backend URL in the sketch:
    const char* ssid = "Your_WiFi_SSID";
    const char* password = "Your_WiFi_Password";
    const char* serverUrl = "http://YOUR_BACKEND_IP:3001/api/readings";
  4. Select Board: ESP32 Dev Module and flash

Wiring:

  • DHT11 Data โ†’ GPIO2
  • DHT11 VCC โ†’ 3.3V
  • DHT11 GND โ†’ GND

๐Ÿ“ Project Structure

goldilocks-kingston/
โ”œโ”€โ”€ backend/
โ”‚   โ”œโ”€โ”€ db/                  # SQLite database + init scripts
โ”‚   โ”œโ”€โ”€ logic/               # Business logic (AI, rates, weather, carbon, etc.)
โ”‚   โ”œโ”€โ”€ server.js            # Express API server
โ”‚   โ””โ”€โ”€ seedHistorical.js    # Data seeding script
โ”œโ”€โ”€ frontend/
โ”‚   โ”œโ”€โ”€ components/          # React components
โ”‚   โ”œโ”€โ”€ lib/                 # API client, utilities, Context providers
โ”‚   โ”œโ”€โ”€ pages/               # Next.js pages (dashboard, carbon, savings, settings, chat)
โ”‚   โ””โ”€โ”€ styles/              # Global CSS + colorblind mode variables
โ”œโ”€โ”€ esp32_sensor/
โ”‚   โ””โ”€โ”€ esp32_sensor.ino     # Arduino firmware for ESP32 + DHT11
โ”œโ”€โ”€ gateway/
โ”‚   โ””โ”€โ”€ index.js             # (Legacy) Gateway for serial ESP32 data forwarding
โ”œโ”€โ”€ PRD.md                   # Product requirements document
โ””โ”€โ”€ README.md

๐ŸŽฎ Demo Mode

No ESP32 hardware? No problem. Enable demo mode to simulate realistic sensor data:

  1. Set DEMO_MODE=true in .env
  2. Restart backend
  3. Simulated readings will be generated automatically (temperature cycles, humidity patterns)

๐ŸŽจ Colorblind Mode

  1. Go to Settings โ†’ Accessibility
  2. Toggle "Colorblind Mode"
  3. All green/yellow/red indicators switch to blue/teal/orange

Affects: badges, charts, recommendation cards, carbon widgets, sensor status indicators.


๐Ÿ“Š Electricity Rates

Rates sourced from Utilities Kingston (OEB Nov 1, 2025):

Plan Description Key Rates
TOU Time-of-Use Off-Peak: 9.8ยข, Mid-Peak: 15.7ยข, On-Peak: 20.3ยข
ULO Ultra-Low Overnight Overnight: 3.9ยข, Mid-Peak: 15.7ยข, On-Peak: 39.1ยข
Tiered Fixed tiers by usage Tier 1: 10.3ยข, Tier 2: 12.5ยข

Winter peak hours (current):

  • Weekdays: On-Peak 7โ€“11am & 5โ€“7pm, Mid-Peak 11amโ€“5pm
  • Weekends: All Off-Peak

Rates update dynamically based on EST timezone, season (winter/summer), and time of day.


๐Ÿงช Seeding Historical Data

To populate the database with 24 hours of backfilled readings (for testing/demos):

cd backend
node seedHistorical.js

This creates ~2,880 readings for the ESP32 sensor with realistic temperature/humidity patterns.


๐ŸŒ API Endpoints

Method Endpoint Description
GET /api/health Health check
POST /api/readings Receive sensor data (from ESP32)
GET /api/dashboard Dashboard data (indoor, outdoor, recommendations, savings, etc.)
GET /api/carbon Carbon impact data
GET /api/savings?period=today Savings breakdown
GET /api/notifications Smart suggestions & alerts
POST /api/chat Gemini AI chat
GET /api/settings User settings
PUT /api/settings Update settings
GET /api/humidity/timeline 24h humidity data

๐Ÿค Contributing

This is a QHacks 2026 hackathon project. Feel free to fork, experiment, and submit PRs!


๐Ÿ“„ License

MIT License โ€” see LICENSE file for details.


๐Ÿ™ Acknowledgments

  • Ontario Energy Board โ€” Electricity rate data
  • OpenWeatherMap โ€” Weather API
  • Google Gemini AI โ€” Conversational intelligence
  • City of Kingston โ€” Community Energy Plan data
  • QHacks 2026 โ€” Inspiration and deadline motivation ๐Ÿš€

๐Ÿ“ง Contact

Built by [Your Name/Team]
QHacks 2026 | Kingston, Ontario

GitHub: yourusername/goldilocks-kingston

About

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors