Temperature logging and regulation in a central heating system

Continuing my series of articles about a central heating system mentioned here, the next step was to find a way to remotely monitor temperatures throughout the system, without having to run down into the basement boiler room to see what’s going on. Since I began tinkering with Arduino at the time, I opted for Atmel’s Atmega micro-controllers, mostly because they’re very cheap, popular and you can easily find help for anything you need. I will briefly describe the whole system and let you work out the schematics for yourself, not just because I’m too lazy to draw them.

1. Temperature monitoring and logging

Since I needed more than 6 temperature sensors in the system, the right choice for the job was Dallas DS18B20 digital One-wire sensor, which makes it possible to hook up “a large number” of sensors using just one I/O pin on the Atmega. The sensors also support temperatures of up to +125 degrees Celsius, which suits my needs perfectly. OneWire sensors also have excellent Arduino support. I’ve installed 8 sensors in total, 4 at different heights on the accumulation tank, one on the hot feed, two on the cold return (one before and one after the mixing valve), and the last one was installed in the boiler itself, because it already came with a temperature sensor slot. Thermal grease and thermal-conductive glue worked wonders. For the purposes of logging, I chose remote logging via the local network, so the project also required an Ethernet module. During the first year, while the whole setup was connected using an Arduino board, I used the expensive, Wiznet 5100 based Arduino Ethernet Shield, but once I made the “final product” on a custom circuit board, I switched to the cheaper Microchip ENC28J60 based modules (at the moment, the entire module costs under USD 4.00). These modules have excellent support through the EtherCard library. I’ve written a sketch which would poll the sensors and read the temperatures from al eight sensors every 10 seconds, and log the data to a server as a HTTP GET request, which looks something like:

 http://192.168.1.10/tlog/post.php?t0=57.56&t1=43.13&t2=34.31&t3=30.69&t4=56.13&t5=26.31&t6=60.13&t7=34.31

PHP script post.php stores the data into a MySQL database. I use Google Charts to draw temperature line charts: glinechart

2. Controlling the circulator pump

Now that I know all of the temperatures in the system at any given moment, I figured it would be neat to switch on the circulator pump automatically when the heat storage tank is sufficiently full (e.g. to one quarter) and switch it off as soon as the boiler is not able to maintain the temperature going into the heat storage tank. Although this requires just one relay, I got a 4-relay shield with opto-isolators. The opto-isolators will later prove extremely important because the relays have to switch AC motors, so once I made a printed circuit board for my circuit without them, the whole thing mysteriously started freezing up whenever one of the motors was switched on/off, and no amount of TVS’s, filters and other stuff was able to fully eliminate all the bugs.

relay-shield-4

But let’s go back to my relay shield. The circulator pump required one, I reserved two for regulation, and one was left unused. When the pump was switched on, it would start running only if the temperature at the top of the heat storage tank was above 60 degrees (heat charger maintains that temperature), and would automatically stop if the temperature were to drop below 60 (in order to maintain layering of hot water in the heat storage tank and slow down the discharge which is much more stable when the circulator is not running).

3. Regulation

This bit was much more complicated, both electrically, electronically and in terms of programming. I wanted to control the mixing valve in order to maintain constant hot feed temperature, which would also ensure constant cold return temperature. Truth be told, I had no idea at this point what I was supposed to do and how, but I was willing to experiment. I got a “dumb” actuator suitable for my mixing valve.

actuator_label actuator

As it says on the label, the actuator cannot be controlled automatically using steps and you can’t instruct it to go to a certain position – it’s powered by 230VAC and has only three leads, two phase leads controlling the direction and one neutral lead. The only thing I knew is that it takes the actuator 140 seconds to get from 0 to 90 degrees. .

I made precise measurements to see how long it took the actuator to full open or close, divided this by 10 and got ten steps I can use to control the actuator. Of course, without a way to get feedback as to whether the actuator has actually reached a position, this was extremely imprecise, but usable if you rely on limit switches in the actuator. I stored the assumed position of the actuator into the EEPROM so that my system knew where the actuator was even after a reset.

The regulation system kicked in every few minutes, comparing temperatures and opening/closing the mixing valve.

4. Circulator pump pulse drive

First of all, I must explain that my circulator pump was bought in 1986, and it was left in its original packaging until 2010 when it was installed, meaning that it doesn’t work that well. It’s also “dumb”, because it only offers three speeds which are selected using a switch, so there is no other way of regulating its speed. And I so needed a way to regulate its speed because most of the problems I had could be solved if only I could reduce the flow. The problem grew even more acute when the circulator simply stopped working at the lowest speed, so I had to switch it to run faster.

That’s when I decided to try a sort of pulse width modulation, only a really, really slow version of it – the circulator would run for 30 seconds, which is enough to supply hot water to the radiators, and then the pump would stop for 60 seconds, allowing the radiators to radiate some heat and cool down the water before sending it back to the storage tank. The line chart in this case looks like this:

pulse2

The mixing valve is open to 80%, which explains the variance between the cold return feed (dark blue) and heat storage tank return (light blue). The hot feed to the radiators is some 60 degrees, and the return temperature is much lower. I have been using this system for two years and not once did I have the need to let the circulator run constantly.

5. Source code and schematics

Like I said, the “end product” on a printed circuit board with power, relays, OneWire Bus, serial LCD, Ethernet module, even a RTC chip (DS1307) proved to be much more unreliable than a prototype made using an Arduino board, so I can’t give you the schematic. Just don’t make the same mistake as I did – use opto-isolators to separate the relays from the MCU, and if you have four AC motors in the vicinity like I have (boiler ventilator, main circulator pump, heat charger circulator pump, mixing valve actuator), you can be sure that everything will go to shit if you forget them.

Arduino source code with comments in English can be found on my Github. The author makes no responsibility that the code will work or that it will be appropriate for any use. It’s quite likely that it won’t even compile, but it might give you a few pointers to help you along in whatever you’re doing.

One thought on “Temperature logging and regulation in a central heating system”

  1. Poštovani Ivane,

    želim da Vam čestitiam na odlično obavljenom poslu. Ja takođe se srećem sa sličnim problemimam poput Vas, prikupljam polako komponenete za sistem grejanja kako bi za sledeću grejnu sezonu sve pustio u funkciju. Takođe sam pribavio i rezervoar za vazduh od 1500L koju planiram pretvoriti u spremnik tople vode. Zanima me da li imate za ponuditi na prodaju gotovo rešenje sa arduino kontrolerom ili možda nešto tome slično poput šeme, PCB-a takođe na prodaju? Čitajući ovaj Vaš tekst prepoznao sam sve probleme koje bih i ja trebao rešiti sa regulacijom 3 ili 4ro krakog mešnog ventila. Poručio sam sve komponente pomenute u vašem tekstu, moje poznavanje lektronike je osnovno kkao i programiranja, ali sam spreman da učim i da se mučim :).
    Svaka pomoć bi mi puno značila.

    Unapred zahvalan
    Voislav

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.