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!
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:
- ATmega168PA µC in TQFP32
- Bluetooth Bee Module
- N Channel MOSFET in SOT23
- LP2985 5v Linear Voltage Regulator in SOT23-5
- SIL pins (see schematics for more details)
- 4.7µF Ceramic Capacitors in 0805
and the components on the relay board:
- G5LA-1A 250v 10Amp Relays
- Hole through power diodes
- SIL pins
Other misc. stuff:
- Small Switching Mode PSU rated 12v 400mA (to run the boards)
- 16AWG wires with silicon shield for carrying 250v
- More wires for hooking up other things
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.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.
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:
- turn on/off or toggle both/individual sockets;
- set the default state of each socket on startup;
- set a timeout to turn on/off or toggle both/individual sockets at a
- later time;
- set time intervals to turn on/off or toggle both/individual sockets
- as well as allowing to pick a starting time for the first interval;
- nine slots for both timeouts and intervals combined;
- typing ? on BT terminal will show a tiny man page.
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: