Bluetooth Controlled Power Board

I used to have a remote controlled ceramic heater (Dimplex GDHCER20). I considered its lack of thermostat a feature! Yep, I hate thermostats largely because they never work properly. This heater instead had a shutoff timer that you could set in 30 minutes intervals (amusingly, it had four lights, 30, 1:00, 2:00, 4:00 and it would light em up in a binary sequence as you kept pressing the timer button).

I threw the heater out because it turned out to only heat up my ceiling (the fan didn’t have any power to push air through the grill). Did my research and found Infrared (aka Radiant) heaters to better suit my need. So I got myself an Omega Altise OR24C. I gotta say it is magic (well it caught on fire few months later, the smoke show was as magical — I now use a Dyson Hot+Cool). You point it at the wall and the whole room turns into an oven. But there is a catch: no timer function. The thermostat that comes with it doesn’t do Jack or Sally (no surprises here). I hear what you’re thinking, and that’s exactly what I did!

Bluetooth power board overview

Only the two sockets on the right are usable.
Sexy bluetooth logo, ha!

Initially, I was going to add the timer to the heater but as the project progressed, I decided to generalize it so I modified a power board and added the desired functionality into that. I had Bluetooth in mind as the communication channel and so I digged around and found one that I had previously used for diagnosis of a quadcopter. That cost me about $20 but one can buy them for $7 on eBay. Below is the list of components I used for the main control board:

Control board and relay PCBs

Control board and relay PCBs

and the components on the relay board:

Power supply unit

12v 400mA Switch Mode PSU

Other misc. stuff:

Initially I assumed I could make use of four sockets but the boards and PSU ended leaving only two sockets free. I also realized that for safety reasons I needed to put relays on both live and neutral leads.

Wiring diagram

Top view wiring diagram. Inkscape makes making diagrams so much fun!

I used the good ol’ method of toner transfer to do both PCBs and they turned out OK. I should probably get myself a cheap laminator and pimp it up. Clothing irons are just not up for it, in the consistency department.

Control and relay board schematics

Control (right and top) and relay (bottom left) board schematics

There are couple of things to mention about the boards. First of all, the connection between the Bluetooth module and the µC is through three pair of pins (P2, P3, P4, P5) which in the final board would be connected together with jumper heads. The pins allow easy debugging of USART on both µC and the BT module. Have a look at the schematic and PCB for the control board to understand it better. Also, how you connect the control board to the relay board is up to you. Having a look at the source code, it will be clear which pairs port outputs on the µC control a single socket (OK, I just tell you, PD2 and PD5 are together as are PD3 and PD6).

The source code is put together in a hurry and it’s not the prettiest around. In fact, it lacks comments entirely. I’m biased but I think it’s easy to read. I used avr-gcc tool chains to compile and seeing how avrdude didn’t have this particular µC in its DB, I used the Atmel’s official IDE in windows to program the HEX files and set various fuses. If anyone managed to make it work with avrdude, I’d appreciate if you share it with the developers. The Makefile will compile and HEXify the code for you.

As for the fuses, I just set the main frequency to 8Mhz with 0ms startup delay. I also switched off the 1/8 divisor. All the timings in the code are based on an 8Mhz clock speed and mind you the internal RC oscillator is awful in terms of accuracy! Also, you need to setup your BT Bee directly using something like Bus Pirate or any other USART with TTL levels. Things like name, PIN and also making sure it’s in slave mode. The code only puts the Bee in its inquiry mode at the start. You are of course more than welcome to hack the code and make it do more magic.

Now the fun part: what can it do? It can:

Unfortunately due to the inaccurate internal oscillator of the µC, timeouts and intervals far into the future will be off significantly. The obvious fix is to put an external crystal on the board. That might be hard to do considering I’m using one of the relevant pins as input. Other than this, it works heavenly, far better than anything I’ve ever had. I love it.

The code including the diagrams are licensed under GPLv3 and is available at my github repository. And for the finale, some more photos and a demo video:

Opened case

Close up of the control board