
Inspiration
A good night sleep is getting rare day by day, the noisy halls, constant tossing and turning, stale room air, fluctuating temperatures just adds up to that long sleepless night and even longer drainy day. It’s not just about insomnia or being tired; irregular sleep is tied with worsening mood swings, loose focus, poor immunity, and harmful in long-term health. The often missed upon part on itself, the bedroom: ventilation, air quality, and temperature can nudge your night in the right or wrong direction before you even close your eyes. “kozi.REST” was born from that simple truth, analyzing the two things that actually decide your goodnight’s sleep: your movement in bed and the conditions of your room, turning them into a clear, simple one-tap morning report with small, with few suggestions for tonight.
What does it do?
kozi.REST runs a small edge service on a Raspberry Pi 4 that reads a CCS811 gas sensor over I²C for TVOC(Total Volatile Organic Compounds) and eCO₂(equivalent carbon dioxide), and an ultrasonic sensor to estimate in-bed movement (no camera or wearable). A front-panel button sends a “sleep report,” pushing the last few minutes of features to the server for analysis.
On the server, a Node.js backend pulls live temperature and weather from an external API and fuses it with the Pi’s indoor features. Gemini generates a short morning summary and a few concrete suggestive steps for tonight; that text is then sent to ElevenLabs to produce an MP3, which the Pi plays on a Bluetooth speaker and then deletes. A Socket.IO stream keeps the HTML + Tailwind CSS web app in-sync in real time, with charts rendered by Chart.JS, and Auth0 provides secure login plus an optional guardian view to see a dependent’s reports. Data lands in MongoDB Atlas for time-series trends.
How we built it
Hardware (Raspberry Pi 4, ARM)
Sensors: CCS811 (TVOC/eCO₂ via I²C), ultrasonic range sensor.
I/O: Momentary button (sleep report), Bluetooth speaker for audio.
Edge service: Python 3.11 daemon (I²C/GPIO).
Software
Frontend: HTML, Tailwind CSS, Chart.js.
Realtime: Socket.IO (sensor updates + report state).
Auth: Auth0.
Backend: Node.js (Express), MongoDB Atlas (time-series), server-side weather API.
Voice: ElevenLabs TTS → MP3 (short-lived; Pi deletes after playback).
Deploy: Vultr (web), Server: Linux (Ubuntu), GitHub Actions; domain via GoDaddy
Challenges we ran into
We initially planned for a complex, richer sensor stack (true NDIR CO₂, PM2.5, light, haptics), but simply finding Pi-compatible modules on short notice ate hours. A last-minute parts run forced us to trim scope and stabilize the essentials (CCS811 + ultrasonic + button + speaker).
We hit pin collisions, I²C address confusion, and timing quirks (bus resets, pull-ups, CCS811 baseline warm-up). Fixes included remapping pins, adding retries/debouncing, and deferring non-essential peripherals.
Pairing and reconnect behavior was finicky; we added backoff and a post-play file delete to keep the loop predictable and writing clean, fault-tolerant edge code and a realtime dashboard in parallel was intense.
Accomplishments that we're proud of
We built a functioning hardware-software system from scratch in less than 24 hours. The whole system updates live in the browser without a single refresh.
What we learned
This project taught us the value of simplicity and focus under pressure. It’s easy to chase extravagant features, but the real challenge is keeping things stable with limited time. We learned how to work with real sensors, not libraries or simulators. We learned how fragile I²C and Bluetooth can be on the Pi when timing isn’t handled carefully.
What's next for kozi.REST
The next version will include more sensors. We also want to add an LED display to show status on the bedside unit. Another big step is adding a microphone to measure noise levels at night, and also to support voice interaction.


Log in or sign up for Devpost to join the conversation.