Skip to content

About

AI-assisted adaptive desk lighting - Embedded System (CEDT) Final Project 2026

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

38 Commits

Folders and files

Repository files navigation

💡 SmartDeskLight

Light that adapts to how you work

An AI-assisted desk lamp that shapes light with servo-driven filters
and closes the loop on the lux that actually reaches your desk.

โคมไฟโต๊ะอัจฉริยะ ปรับสภาพแสงอัตโนมัติด้วย AI เพื่อความสบายตา


Firmware build ESP32 NETPIE2020 License: MIT

Architecture · Control flow · How it works · Quick start · Docs · Team


Architecture

%%{init: {"theme": "base", "themeVariables": {"background": "#0D1117", "primaryTextColor": "#E6EDF3", "textColor": "#C9D1D9", "lineColor": "#8B949E", "edgeLabelBackground": "#0D1117", "clusterBkg": "#161B22", "clusterBorder": "#30363D", "titleColor": "#E6EDF3"}, "flowchart": {"curve": "basis", "padding": 18, "nodeSpacing": 45, "rankSpacing": 55}}}%%
flowchart TB
  subgraph SYS["SmartDeskLight · System Architecture"]
    direction TB

    subgraph NODE["SENSOR NODE · ESP32 A"]
      S["BH1750 + TCS34725<br/>lux · colour temp"]
    end

    subgraph GW["GATEWAY · ESP32 B · FreeRTOS"]
      G1["VL53L0X · PIR · INA219"]
      G2["Control loop"]
      G3["Cloud task<br/>offline buffer"]
    end

    subgraph LAMP["LAMP"]
      L["3 servo filters<br/>+ LED PWM"]
    end

    subgraph CLOUD["CLOUD & SERVICES"]
      N[("NETPIE2020<br/>Feed · Dashboard")]
      A{{"LLM API"}}
      D["Discord"]
    end
  end

  S -->|"ESP-NOW · ACK"| G2
  G1 --> G2
  G2 -->|"servo · PWM"| L
  L -.->|"measured light"| S
  G2 <--> G3
  G3 <-->|"MQTTS"| N
  G3 <-->|"HTTPS"| A
  G3 -->|"webhook"| D

  classDef sense fill:#0F2747,stroke:#58A6FF,stroke-width:2px,color:#E6EDF3
  classDef edge fill:#3A2A0B,stroke:#F0A93B,stroke-width:2px,color:#E6EDF3
  classDef act fill:#3B1414,stroke:#FF6B6B,stroke-width:2px,color:#E6EDF3
  classDef cloud fill:#0E2E1C,stroke:#3FB950,stroke-width:2px,color:#E6EDF3
  classDef ai fill:#2A1A4A,stroke:#BC8CFF,stroke-width:2px,color:#E6EDF3
  class S sense
  class G1,G2,G3 edge
  class L act
  class N,D cloud
  class A ai

  style SYS fill:#0D1117,stroke:#30363D,stroke-width:1px,color:#E6EDF3
  style NODE fill:#161B22,stroke:#1F6FEB,stroke-width:1.5px,color:#79C0FF
  style GW fill:#161B22,stroke:#9E6A03,stroke-width:1.5px,color:#F0A93B
  style LAMP fill:#161B22,stroke:#B62324,stroke-width:1.5px,color:#FF7B72
  style CLOUD fill:#161B22,stroke:#238636,stroke-width:1.5px,color:#56D364

  linkStyle default stroke:#8B949E,stroke-width:1.5px,color:#C9D1D9
  linkStyle 3 stroke:#FF6B6B,stroke-width:2px
Loading

Detailed diagram with FreeRTOS tasks and E-items: docs/architecture.png

Control flow

One cycle of the system, from measurement to verified light on the desk:

%%{init: {"theme": "base", "themeVariables": {"background": "#0D1117", "actorBkg": "#161B22", "actorBorder": "#58A6FF", "actorTextColor": "#E6EDF3", "actorLineColor": "#30363D", "signalColor": "#8B949E", "signalTextColor": "#E6EDF3", "labelBoxBkgColor": "#161B22", "labelBoxBorderColor": "#30363D", "labelTextColor": "#E6EDF3", "loopTextColor": "#C9D1D9", "noteBkgColor": "#1F2A37", "noteBorderColor": "#30363D", "noteTextColor": "#C9D1D9", "activationBkgColor": "#3A2A0B", "activationBorderColor": "#F0A93B", "sequenceNumberColor": "#0D1117"}, "sequence": {"mirrorActors": false, "boxMargin": 8, "messageMargin": 38, "noteMargin": 10}}}%%
sequenceDiagram
  autonumber
  actor U as User
  participant N as Sensor Node
  participant G as Gateway
  participant L as Lamp
  participant A as LLM API
  participant P as NETPIE2020

  rect rgb(18, 23, 30)
    Note over N,G: Sense — every second
    N->>G: Telemetry { node_id, seq, lux, cct }
    G-->>N: ACK { seq }
    opt no ACK within 100 ms
      N->>G: Retry (max 3)
    end
    G->>P: MQTTS publish (raw + shadow)
  end

  rect rgb(22, 27, 34)
    Note over U,P: Decide — on activity change, feedback or every 5 min
    U->>P: Activity / "too bright"
    P->>G: @msg/sdl/cmd
    activate G
    G->>A: HTTPS context (lux, cct, presence, feedback)
    A-->>G: { target_lux, target_cct, filters[3] }
    G->>G: Clamp range, rate-limit servos
    deactivate G
  end

  rect rgb(18, 23, 30)
    Note over N,L: Act and verify — closed loop
    G->>L: Servo angles + PWM
    L-->>N: Light on desk
    N->>G: New lux reading
    alt error within tolerance
      G->>G: Hold position
    else still off target
      G->>L: Fine-tune PWM
    end
  end

  rect rgb(22, 27, 34)
    Note over G,P: Resilience
    alt cloud unreachable
      G->>G: Buffer readings, flush on reconnect
    else stop button or sensor fault
      G->>L: Safe state (filters folded, LED medium)
      G->>P: Alert event → Discord
    end
  end
Loading

Highlights

  • Shapes light, not just brightness — diffuser, ND and warm/CTO filters flip in and out on three servos
  • Closed loop — every change is re-measured on the desk (BH1750 lux, TCS34725 colour)
  • Learns your preference — an LLM suggests a profile per activity and adapts to too bright / too dim feedback
  • Built to keep working — ESP-NOW with ACK/retry, store-and-forward offline, rule-based fallback

How it works

Step What happens
1 Sense The sensor node measures desk lux and colour; the gateway reads presence, distance and lamp power
2 Decide The gateway sends context to the AI and receives a target lux, colour temperature and filter set
3 Act FreeRTOS control task moves the filter servos and trims the LED with PWM
4 Verify The new light is measured again and the loop corrects any error

Quick start

git clone https://github.com/E3-Embed/SmartDeskLight.git && cd SmartDeskLight
cp firmware/gateway/include/secrets.example.h firmware/gateway/include/secrets.h   # add your keys
pio run -d firmware/gateway -t upload
pio run -d firmware/sensor_node -t upload

Requires PlatformIO, two ESP32 boards and a NETPIE2020 device — see the docs below.

Documentation

Hardware Bill of materials, pin map, power and safety
Protocols ESP-NOW packet, NETPIE topics, AI request / response
Firmware FreeRTOS tasks and Embedded Engineering Depth items
Testing Metrics, method and results
Dashboard NETPIE2020 device, dashboard and alerts setup
Contributing Branches, commit style, secrets policy

Team

Member Role
รชาทัช บุญพัฒน์ · 6833230421 System Architect & Integration
ฐากูร นันตสุวรรณ · 6833060021 Embedded Developer — Sensor Node
นรินธร ยางงาม · 6833136121 Embedded Developer — Gateway & Cloud
ปุณยวีร์ พัฒนประดิษฐ์ · 6833170421 UI/UX & Dashboard Developer
กษิดิศ ประจงการ · 6833008521 Project Manager & Test Lead

Status

  • Proposal, architecture and CI — 30 Oct 2026
  • End-to-end data flow: node → gateway → cloud → dashboard — 20 Nov 2026
  • Final demo, report and video — 8 Dec 2026

Embedded System (CEDT) Final Project 2026 · Chulalongkorn University
AI tools used: Claude (proposal editing, repo scaffold, docs, diagram), GitHub Copilot (commit messages) · MIT License

About

AI-assisted adaptive desk lighting - Embedded System (CEDT) Final Project 2026

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages