SmartSpace Systems
A Raspberry Pi Pico W doorway counter that switches lights on only when a room is occupied and dark. Built and tested for UVic Facilities Management.

The problem
Lights stay on in rooms nobody is using. UVic Facilities Management wanted to know whether a low-cost sensor node could switch lighting by occupancy and daylight, and whether that is reliable and affordable enough to deploy across campus. The brief had two parts: build a working prototype, then make the case in a feasibility report covering the technology, the cost and how people would react to it.
How it works
Two IR break-beam sensors sit across the doorway. Which beam breaks first tells the controller whether someone is coming in or going out, so it keeps a running count. A PIR motion sensor backs that up: if the count says the room is empty but the PIR sees movement, the lights stay on. A light sensor keeps the lights off in a bright room. The lights come on only when the room is occupied and dark enough.
The Pico W also serves a small web page over Wi-Fi showing the count, the motion and light state, and a manual override. Neither sensor type records images or identifies anyone; the controller holds only a count and a motion flag.
What I did
I chose, mounted and calibrated the three sensor types, and led the testing on a mock doorway. I wrote the report’s introduction, solution description and the technological, economic and social feasibility sections, plus the appendices, and put the full report together. It was graded 95%, and the final demo scored 30/30. The firmware and dashboard were partly AI-assisted; I tested every behaviour described here on the bench.
Key decisions
One beamvsTwo beams
Chose Two beams because the order the beams break in is the only way to tell an entry from an exit. The count only changes when the sequence completes, and a half-finished sequence times out after five seconds.
Trust the counter alonevsAdd a PIR override
Chose Add a PIR override because the counter can miss groups. Side by side, it counted correctly in only 3 of 10 trials, so the PIR keeps the lights on whenever it sees movement.
A richer dashboardvsOne small page
Chose One small page because the Pico W ran out of memory on heavier pages. The dashboard is a single page of minimal HTML and CSS that refreshes every two seconds.
Testing and what went wrong
All tests used a mock doorway made from a cardboard box about 30 cm wide, with cardboard cutouts as people. They show the logic works, not how it behaves with real people at speed.
| Test | Trials | Passed | Notes |
|---|---|---|---|
| Single entry or exit at walking pace | 60 | 56 | Missed when moving too fast or hesitating in the beam |
| Two figures side by side | 10 | 3 | Counted one person in 7 of 10; a known limit the PIR covers |
| PIR, stationary occupant | 30 | 28 | Missed only when completely motionless |
| PIR, occupant writing or shifting | 30 | 30 | Detected every time |
| PIR override (count 0, motion seen) | 28 | 28 | Lights stayed on every time |
| Light sensor, three light levels | 60 | 60 | About 60, 400 and 550 lux |
| Full cycle: enter, sit five minutes, exit | 20 | 18 | Both failures left the lights on |
| Dashboard refresh | 15 | 15 | Page loads in about 1.5 s |
Side-by-side entry was the weak spot, and it is the reason the PIR backup exists. The PIR has its own blind spot, a person sitting completely still, which the break-beams cover because they counted that person in.
The light sensor is wired as a flipped voltage divider, so its reading rises as the room gets darker: about 7,000 in a lit room and about 24,000 when covered. I set the switching threshold at 15,000, between the two.
In the two full-cycle failures a beam miscounted an exit and the lights stayed on. That is the safe direction to fail in, but it wastes energy, which is why the counting accuracy matters.
Result
- Single passages
- 56 of 60
- All trials
- 235 of 243
- Prototype cost
- $44 CAD
- Estimated at 200+ units
- $25 CAD
- Report grade
- 95%
- Final demo
- 30 / 30
Of 243 trials, 235 passed (96.7%), not counting the side-by-side test and the page-load timing. My sections of the report concluded the approach is technically, economically and socially feasible. A rough payback for a 200-room rollout comes out at about 2.8 years, using the conservative 30% saving from occupancy sensing alone and BC Hydro’s published rate. The report states the assumptions, including that UVic’s actual tariff differs. The main technical risk it names is counting accuracy when several people enter together.
Gallery
02Wiring diagram Dashboard served by the Pico W
Downloads
| File | Format | Size | Licence |
|---|---|---|---|
| Controller firmware (MicroPython, Wi-Fi details removed)Opens in: Thonny or any text editor | Python (MicroPython) | 14 KB | View only |