Daily Archives: May 20, 2015

Use a K-Type Thermocouple with the Raspberry Pi

Whether you are working in a lab, at home, in the office or in the field, occasionally one needs to have the capability to measure the temperature of different sorts of materials such as solids, liquids and chemicals. The temperature range involved may be small or large – its measurement usually requires the use of a thermocouple. This is not very easy to interface, as you need a sensor amplifier that has to measure a very small voltage generated by the thermocouple.

In general, type-K thermocouples are useful in most applications. Extension grade K-type thermocouples are made of Nickel and Aluminum alloy conductors good for measuring a temperature range of 0-200°C. However, other constructions are available that can measure a temperature range of -270 to 1260°C. Thermocouple conductors, when subjected to a temperature gradient, generate a minute amount of voltage – this is called the Seebeck effect. Type-K thermocouples have a nearly linear voltage output versus a temperature gradient. This simplifies interfacing to an electronic circuitry.

The ADS1118 development board from Texas Instruments (TI) is a ready-made platform for using the K-type thermocouple with the Raspberry Pi or RBPi, the tiny credit card sized single board computer. The development board comes with a k-type thermocouple and a high-resolution LCD module. Using eight jumper wires, you can connect this board to the RBPi via the SPI pins on its GPIO. Alternately, use an adapter board to plug in the ADS1118 development board directly to the GPIO pins on the RBPi. Follow the diagram on the left.

The advantage in using an RBPi for interfacing a thermocouple is you can check up on the temperature of your experiment remotely via your smartphone or your PC. The basic idea is to use the RBPi as a web server and to project the temperature measured as a figure on the website that comes up. The following diagram sums up the entire scheme –

The RBPi interfaces with the ADS1118 development board to collect the temperature data via the Serial Peripheral Interface or SPI. It passes this information to the Webserver and application logic. The RBPi also runs a JavaScript in the background for the Webpage content and browser side.

On receiving a request, the web server delivers the webpage containing the temperature data, updating it frequently. This allows remote monitoring of the temperature data from your smartphone or PC. You only have to point your browser to the correct IP address of the webpage.

TI provides a wealth of code for the MSP430 micro-controller on the ADS1118 board. Usually, temperature measurement is a little more than the simple read the ADC value and convert to temperature. It usually involves compensation for the cold junction. For the ADS1118, this means reading another temperature sensor reference on the board. The code does the job of interleaving the readings of the internal sensor and the external thermocouple.

Additionally, the readings need to be corrected for the non-linearity of the thermocouple for accurate interpretation of the thermocouple voltage into temperature. The TI code includes the non-linearity of the thermocouple and translates the ADC value accordingly to actual temperature.