Introduction: $15 Personal IOT Smart Heater Controller

During the last winter, I had started preferring using Infra-red (IR) heaters (see picture). They can heat-up a person or a specific area in a room having to heat up the whole room like an A/C. Heating up just a part of the room saves a lot of power, and it's also much faster than waiting for the whole room to warm up.

Problem is, both IR heaters I have at home have only 2 power levels. Without any control, it's easy to get to either a too hot or a not hot enough situation.

Here I explain how I added smart temperature control which also communicates data to Thingspeak.com, because why not?

Step 1: Materials

The LCD display shows the following: room temperature of 24.56°C, an error of -1.43°C which means the room is colder than the set-point (rounded to show 25°C). To equalize the temperature, a heating power of 100% is applied.

I'm assuming you already have a heating element. If that's not the case, check out This 9-Inch Dish Heater.

Parts list:

  1. Cactus Micro Rev. 2 - Arduino compatible board w/ built in ESP8266 WiFi module - $10 (you can use a much cheaper Arduino Nano compatible board - $2.5 if you don't plan on using the Thingspeak.com feature)
  2. SSR-10 DA - 220V 5V Relay - $3
  3. TMP36 - Analog Temperature Sensor - $0.67 - I used this together with an LM35 to get a more robust measurement, but it's optional.
  4. 10k Ohm Rotary Potentiometer - $0.95
  5. Breadboard - $0.38

    So far, this sums up to ~$15. We just need some other small components (each for a couple of cents):
  6. 220 Ohm Resistor + Red LED (Optional - WiFi error LED)
  7. 47k Ohm Resistor + 2N2222 NPN Transistor
  8. Jumper wires, Hookup wires
  9. Totally optional: 16X2 LCD Display with I2C Serial interface adapter - $1.88

Project Options:

  1. WiFi functionality: it's really cool to monitor stuff in the Interner of Things (IOT) era, but not a must if you just want steady temperature. You can use the cheaper Nano compatible board, which has no WiFi built in, but will save the need for items No. 7 as it runs on 5V which are needed to switch on the relay.
  2. LCD screen: While all the data is uploaded to Thingspeak.com, if you want a second debug screen or if you want to see the temperature set-point, then keep the LCD. Otherwise, you can always mark temperature values on your rotary Potentiometer.
  3. Power Source: As this is my computer desk heater, I power the board from a USB port which turns on together with the computer. The circuit with WiFi and LCD (backlight off) runs on a 1600 mAh battery for ~36 hrs. So other than a USB port I'd recommend one of these 220V to 5V step-down power supply or a simpler Wall charger with a micro-USB cable to power the board.

Step 2: Wiring

Connect the Cactus micro board and all the other parts as sketched here.

WARNING: If you're unfamiliar with high-voltage safety, DO NOT ATTEMPT connecting the relay and the heater. In that case, I'd recommend something like this Remote Controlled Socket for switching the heater.

For the first couple of times I'd suggest powering the board from the computer so you could use the DEBUG mode where the sketch is fully verbose. Later you could power the board from a wall-plug 5V charger.

Step 3: Cactus Micro Rev2 Sketch

A few notes about the sketch:

  • The sketch is written so it could be as readable as I could. It is not particularly efficient or short.
  • The project options (WiFi, LCD) are sectioned, so you could delete them easily.
  • The 16X2 LCD reference can be found here.
  • The WiFi commands used here are taken from here.

Step 4: (Optional) Setting Up a Thingspeak Channel

One of the cool features of the IOT concept is that every sensor could now upload data over the internet. You can either present data, or wirelessly control your device, or both actually...

I used thingspeak.com for helping me understand how the heater ramps up, and how it reacts to set-point changes.

  1. Head over to www.Thingspeak.com, sign up for an account.
  2. Setup a channel, and copy the Write API Key into the appropriate place in the sketch.
  3. Decide which data you want to upload and change the fields[] array in the sketch respectively (about line 132)
  4. Back in your Thingspeak channel, go to "Channel Settings", set the name of the channel and name the fields which you will be uploading.
  5. Make either private or public plots of the data. The Output Power and the PID Error are important for the next step, which is tuning your temperature feedback parameters.

Step 5: Tuning Your Feedback Loop

The feedback loop's purpose is to keep the temperature stable at some set-point. Many thermostats use a Proportional-Integral-Derivative (PID) routine for that purpose. The idea behind it is explained in this Youtube video.

Although a non-tuned thermostat might be unstable (temperature oscillations), if you're not into tuning the thing, my default settings (Kp, Ki and Kd in the sketch) might work for you, and all you have to do is to choose the "WindowSize" parameter, which is the amount of time between the arduino "decisions" for changing the heating power. The WindowSize should reflect the typical time it takes for the temperature to change due to a change in the heating power. Choose a large WindowSize if the temperature sensors are far away from the heater, or a small value otherwise.

I have the heater and the sensors placed on the same table ~30 cm apart, so I chose a 4 second WindowSize.

If you do feel the need to tune the PID parameters for higher stability/ faster ramp-up time, you might find this link useful.

The right figure shows an example of a 9°C heating sequence, where the heating power (orange line) is 100% for about 9 minutes, then temperature error, which is the offset from the set-point nicely stabilizes (blue line) in the ±0.3°C range around the set-point. The main cause for instability is the cactus A2D, which can read the temperature sensors with a (3.3 V / 10 mV/°C )/1024 = 0.3 °C resolution, which is just fine for home use.

The left plot shows the differences between the LM35 and the TMP36 sensors. I found the TMP36 sensor somewhat more stable, and I recommend having more than one sensor as it adds some robustness to the device.

Step 6: Enjoy Winter

Please add your comments and suggestions ;)