Temperature controlling with Raspberry PI over a webserver on nodejs and angular

I have been tinkering around from time to time with heat regulation. In the past, I decided it might be a good idea to go with a RDT (Pt100) as a sensor. Mainly because my father had one lying around and it can be used in various environments. These platin sensors also work in very hot ovens as well as very humid places. In opposite to K-type sensors these cannot be as easily read out and need some electronic. So I took the device my father build back when he studied for his diploma thesis, it has an oldschool red LED displaying the temperature and I managed to “hack” it, so that it could be read out with an Arduino.

The old Arduino with breakout board

It was used outdoor sometimes and of course this thing broke after some time. Fair enough. So I looked up in the internet, what need to be bought to make it work again. Unfortunately I found out, that devices providing such functionality cost about 100€ and I was like “What the fuck? 100€ for mostly shifting some currents around with op-amps?” Then I decided to solder my own measuring transducer. For those interested in more than my olde stories and also want to learn something: Measuring with a Pt100 works, because you measure the current that flows through the platin wire. The name comes from the 100
Ω this item has at 0°C, as it has a positive temperature coefficient (PTC), which is normal for metals, the resistance rises as temperature rises. So at 20°C room temperature it has a resistance of roughly 107 Ω. All you need to do is apply a voltage at the pt100 and a current will flow through it. As temperature rises, the resistance goes up, so your current goes down. All you need to do is measure the current. Easy. I thought. But the troll of nature strikes back. Not only the curve is nonlinear, also the proportion of change is very small. If you go up from 0°C to 20°C, the resistance only rises by 7%. So if you want to use the built-in ADC of an Arduino, which has 10 bit resolution and goes from 0 to 5V, you can apply a source of constant current to your Pt100 and measure the voltage drop. If you want to measure up to 250°C, you would chose 25 mA, which yields a voltage drop of 5V at 250°C. At the freezing point of water, you will end up with a drop of 2.5V. As your ADC has 10 bit and goes from 0 to 5V, the temperature resolution will be in 0.5°C steps. Also we have to account for nonlinearity, which can be calculated out by the software.

At this point I somehow realized why it might be fair to sell the hardware for about 100€. Still I didn’t want to give up and started to think about soldering a circuit, which transforms the currents to a range, which uses the range of the ADC suitably. But then I found this shiny IC, the SMT UTI-18SOIC. It does everything already, you only need to solder a reference resistor and some other resistors as well as some connections to the sensor and the ADC, plus it costs less than 10€.


So I soldered everything together, it run smoothly and I plugged a relay to my Arduino to control a source of heat. The solution worked universally, so heating up a room was no problem, brewing beer at the right temperature or cooking roast meat slowly over several hours. One could also think of other uses, like regulating the temperature of an aquarium or use in a distillation apparatus. But the good times could not last forever and so the electronics broke again. Well, as a consequence of my soldering skills and not providing a casing for the electronics, this was no surprise.

Also some time has passed and very cheap PID Controllers showed up on Ebay, for 20€ or even less it was possible to have it all in one device. All in one device? No, connection to a computer needs hacking of this controller again and for many heating devices another SSR or relay was necessary, since upper power limits were about 1000W or the like.

So far about the whole history of my odyssey through the ocean of controlling the temperature. Now I have come to a new solution, which might be useful for some people and also easy to rebuild. The aim of the new design was to provide a website from which the whole controlling could be done. Also the device which runs the webserver should be the same as the device controlling the actual temperature. An Arduino, serving as the controller, that was connected to a computer and the computer being the webserver is no longer a suitable solution. So I decided that a Raspberry Pi might be ideal, since it can be connected to WLAN, is cheap and Linux runs on it. For the software I decided to go with Node.js for the Webserver and AngularJS for the Website itself. At this point there is only one thing missing, which is the electronics that connects the Pt100 sensor to the Raspberry Pi. After some searching around, thinking about various I2C solutions or again using an ADC and some transducing, I decided in favor of TinkerForge. I was also thinking about Tessel, another tiny computer like Raspberry Pi, designed to run Javascript directly and also with a lot of modules, you can attach to your system. After I read the documentations and compared the specs, I had the impression that Tessel is a bit overpriced and not as straight engineered as the TinkerForge stuff. Tinkerforge also works with Javascript, is nicely documented, handles errors very well and the modules available look more industrial and reliable to me. For Tessel I also could not find a module that reads out a Pt100 or Pt1000, which is available for Tinkerforge.

Raspberry Pi with connected modules for reading out temperature from Pt100 sensor.

You can find an overview of the bricklets here: https://www.tinkerforge.com/de/shop/bricklets.html

What is necessary for this project are these 3 elements:


The first one connects via USB to the Raspberry Pi, the second one controls the heater and the latter reads out the Pt100. I have to say, this is very easy. It comes with debugging software, so you can plug in your master brick to your laptop and read out what is connected and what it is sensing. All you have to do is set the jumpers on the PTC bricklet to your type of sensor (pt100 in my case). In this case I control a cheap heating plate from Chinese mass production (http://www.ebay.de/itm/INDUKTIONSKOCHER-INDUKTIONSPLATTE-INDUKTIONSKOCHFELD-INDUKTIONSKOCHPLATTE-/181107942542?pt=LH_DefaultDomain_77&hash=item2a2adfe48e)

But I have to say that induction plates are insanely awesome for such purposes. If your controller changes the power, the delay until the system reacts goes down from minutes to seconds. Of course this always depends on the heat capacity of your system and its dynamical behavior. So I opened the case and attached the buttons to the relays of my TinkerForge system. By flipflopping the relays it is possible to control the induction plate just like a human would do it. Well it would be much cooler (or say hotter) to control the induction coil directly with a thyristor or whatever is necessary, so if someone has found a way to control a coil directly, inform me. Then it is possible to take out any induction coil from a broken heater and have stepless regulation. But it might be complicated, since semiconductors are not too happy with high amplitude HF, still there might be some mosfet/thyristor from china that would do the job and is produced in tons.

Also I bought a display for the Raspberry Pi to show and control the temperature right on the device, but it turned out to be useless, since there is always a smartphone around or a laptop to login to the website via WLAN. Furthermore there might be cheaper solutions, since Tinkerforge is expensive, but there is no soldering etc. necessary, is very flexible and can be increased by additional features and controls.

You also need a Pt100, which can be found here http://www.aliexpress.com/item/Two-wire-PT100-temperature-sensor-platinum-resistance-temperature-sensor-PT100/1171520400.html?spm=2114.031010208.3.74.zG27Cg&ws_ab_test=searchweb201556_6_71_72_73_74_75,searchweb201527_4,searchweb201560_9, of course you can also exchange the ptc bricklet and pt100 with a K-type thermistor, which will be some € cheaper and the only drawback is that pt100 operates at much higher temperatures (above 300°C) also.

And last but not least, the source code can be found here https://github.com/gfnork/Tempberry-PID

This is how the webserver looks like, the x-axis is the time in seconds, the y-axis is the temperature in °C (left) and power in watts (right). The system being controlled here is the gulasch pot from the very first picture. It can been seen, that it is able to to keep the temperature between 88 and 92°C, if the desired temperature is 90°C and no stirring is done.

Leave a Reply

Your email address will not be published. Required fields are marked *