back to index

USB Room Light

Why

Because getting out of bed or out of a computer chair to get to the light switch and back is annoying, especially when half of the route has to be done in darkness.

What

A triac switch with a button for manual control, a three-way switch for selecting manual-on, manual-off, and auto-control, and an USB port for monitoring and external control. The "brain" of the device is the famous ATmega8, whose role is monitoring the keypress events and handling the USB port, using the V-USB software-emulation library. The "muscle" is a standard cheap triac, with an optotriac with a zero-cross detector.

The unit was designed to be easily detachable. All the electronics is mounted on the lid. The bottom side has part of its center cut off, so it can be mounted on top of the existing light switch, allowing quick revert to the original system if it would not work.

The unit has four connectors; one for the USB (which also supplies the power for the electronics), one for programming the chip, and one six-point terminal block for attaching of optional extensions, e.g. additional buttons or door opening sensors. The fourth connector, not shown on the photographs as it was added as an afterthought, is the one for connecting the triac parallel to the light switch. The terminal block pins are +5V from the USB, ground, and four signals from the PORTC; these can be software-assigned to digital inputs, digital outputs, or analog inputs.

There are two LEDs on the panel; one green, showing the unit is powered up, and one red, lit up when the unit's output is switched on.

The unit housing is slightly warped at the left top side; this is caused by overheating when applying hot glue for the electronics board.

The cable between the triac board and the switch has a short piece of solid copper wire soldered to its end and sealed with heat-shrink tube. The purpose is making the installation easier, as stranded wire can not be easily pushed under a screw, especially when the screw is shared with another wire. (Bad practice, but good enough for low currents like a 60W lightbulb.) The ease-of-installation was an important requirement, as due to the unwillingness to schedule power cutoffs in the light circuitry the installation had to be performed on live mains. (Not as bad when you know what you are doing and aren't in a hurry.)

The button has advanced functions for just walking across the room; when pressed for longer than about half-second, the light is switched on (if off), or NOT switched off (if on), and then switched off about 25 seconds afterwards. The timing of these intervals can be adjusted in firmware, or in real-time in software. Also, as a safety against forgetfulness and wasting electricity, the light power-on time is limited to about 3 hours.

The firmware stores data in a memory array of registers. These are accessible from both the code and the USB. By overwriting the stored data the functionality can be altered; timers can be adjusted at will, and the change count, current state of light, and the time the light is on for (and more) can be queried by the computer.

Door switch

For increased user comfort, a button switch was attached to the door frame, within thumb reach from the door handle. To affix it in place, and to hold the wires in position, hot-melt adhesive was chosen as an ad-hoc option. The light can be controlled at the moment of entering or exiting the room. The button is attached to the C0 (1) general-purpose input on the terminals of the switch, against the ground, and is set in software to mirror the functionality of the main control button.

The location of the button was chosen as a compromise between the best one (on the door, just above the handle, on the handle panel) and the length of the wiring (which was judged excessive for the optimal confuguration).

Software

TODO

Images


Unit, front-top

Unit, front-bottom

Unit, top cover

Inside, without hot glue insulation

Triac board, top side

Triac board, bottom side

Unit inside, from bottom

Unit inside, from top

Unit inside, from side

Original light switch, with built-in relay

Original light switch, relay visible on the bottom

Switch baseplate in place

Switch wired in position

Switch in place

Switch in place, from top

Door switch connection to the main unit

Door switch, detail of mounting on door frame

Door switch, position related to the door handle

Door switch within reach of thumb

Door switch, wiring

If you have any comments or questions about the topic, please let me know here:
Your name:
Your email:
Spambait
Leave this empty!
Only spambots enter stuff here.
Feedback: