From Events to Enclosures: Building a Presence Sensor

I want my home automation to handle an ordinary situation well: walk into a room, sit down, and have the lights stay on without periodically waving at a sensor. When I leave, they should turn off. When I disable automation, that decision should take effect immediately.

That sounds straightforward until the system has to decide whether a quiet room is empty or someone is simply sitting still.

In my earlier event-hub project, I explored how sensor events could feed a Go application that controls the response. The Go dashboard work extended that idea to another event consumer. This project further develops the sensing side, bringing embedded firmware, occupancy logic, and enclosure design together in a dedicated presence sensor.

The hardware combines an ESP32, a millimeter-wave radar sensor, a PIR sensor, and a physical switch. I use the two sensing methods as complementary inputs to an occupancy decision. The interesting work is deciding how that evidence should affect the room over time.

The firmware interprets sensor observations and reports state changes. My automation, written in Go, handles the lighting response. That includes allowing a period of uncertainty before switching lights off, responding to renewed activity, and respecting the physical override. Repeated readings should not produce a stream of redundant commands to my IoT lights.

This division gives the project room to evolve. I can adjust the lighting policy without treating every change as a firmware release. Logs around state transitions help explain why the system made a decision, which matters when the behavior differs from what someone in the room expected.

The enclosure has become one of my favorite parts of the work.

I enjoy CAD because it lets me turn a spatial idea into explicit geometry. A mounting post has a defined center and height. A sensor opening has a position relative to the board behind it. Component placements share a coordinate system, so I can track how an adjustment affects the rest of the assembly.

Moving a sensor to improve separation also changes its relationship with the face opening and supports. The switch needs an accessible actuator and a mounting surface. The USB opening needs to accommodate an actual cable being inserted. The enclosure has to leave room for wiring and come apart when something needs servicing.

Those relationships make the mechanical model useful long before printing. I can inspect alignment, revise clearances, and check whether the parts have a plausible assembly path. Small placement decisions become much easier to reason about when they are recorded as dimensions.

0:00
/0:25

This is still a prototype, but the workflow I am using for this project allows me to follow a decision across the whole system. For example, a sensor's placement affects what it observes. Firmware interprets those observations. Go applies the automation policy. The person in the room experiences the result, which can be as simple as whether the lights behave sensibly.

If anyone is interested in my design/approach, I may follow up with a build-focused post once the final material list, design, and behavior have had more time in production use.


AI-Assisted CAD Development

While I didn't want to use token quotas for this specific CAD Build, there are quite a few MCP plugins for CAD software that help automate much of the cognitive work, like auto-aligning parts into an assembly and doing the math to ensure correct geometry.

A better way to turn 2D designs into 3D models for rapid prototyping
“GIFT” is a new system that teaches vision-language generative AI models to produce accurate, computer-aided design (CAD) programs that can be used to simulate and test 3D objects. The method is more accurate than competing techniques, using a fraction of the computation.
AI-guided optimization tool makes product design faster and more accessible | MIT Department of Mechanical Engineering
MIT’s Department of Mechanical Engineering (MechE) offers a world-class education that combines thorough analysis with hands-on discovery. One of the original six courses offered when MIT was founded, MechE faculty and students conduct research that pushes boundaries and provides creative solutions for the world’s problems.
You've successfully subscribed to Amitk.io
Great! Next, complete checkout for full access to Amitk.io
Welcome back! You've successfully signed in.
Unable to sign you in. Please try again.
Success! Your account is fully activated, you now have access to all content.
Error! Stripe checkout failed.
Success! Your billing info is updated.
Error! Billing info update failed.