# How to Measure Temperature Very Accurately With an Arduino and a TSYS01 Temperature Sensor Board.

12,025

118

17

Published

## Introduction: How to Measure Temperature Very Accurately With an Arduino and a TSYS01 Temperature Sensor Board.

While studying in university we were challenged as part of a course work into designing a box with very accurate temperature control. If the project were to succeed, multiple boxes were to be built and used in a research project studying the effect of surface material on the perceived temperature of flooring and other building materials.

The project was deemed as very challenging by the university staff because the temperature inside the boxes should stay within ± 0.1°C of the desired value.

Therefore we would require the most accurate temperature sensor we could find. On one hand, the sensor should be factory calibrated to the desired temperature, because calibrating to within 0.1°C of the national temperature standard is next to impossible on a simple setup of boiling and freezing water. On the other hand, an analog temperature sensor with a proclaimed accuracy of ± 0.1°C might still produce inaccurate results after the value is converted to a digital value by an ADC (https://en.wikipedia.org/wiki/Analog-to-digital_converter).

The only solution we could find was to use the TSYS01 digital output single chip temperature sensor by Measurement Specialties and communicate with it using a Arduino microcontroller.

In this instructable I will explain how to use the TSYS01 Temperature Sensor Board with an Arduino microcontroller for very accurate temperature measurements. If you have never used an Arduino microcontroller you can get started by using this instructable: https://www.instructables.com/id/Intro-to-Arduino/ I will not go into detail on how to use the Arduino platform on this instructable, but will only focus on the usage of the TSYS01 temperature sensor board with an Arduino.

## Step 1: Introduction of the TSYS01 and the Temperature Sensor Board.

With the correct peripheral circuit TSYS01 can give provide ±0.1°C accuracy between -5°C and +50 °C. It's 24 bit ADC conversion result is factory calibrated separately for each chip with a 4th degree polynomial. It has low self heating and a small time constant for a single chip sensor. The 24 bit ADC can provide enough resolution for any application(more than 0.0001°C), but some noise can be seen in the output if using more than 0.01°C of the resolution. The very low measurement noise of the sensor can for example enable you to use time constant compensation based on the current rate of temperature change without unbearable measurement noise. The sensor output and a value with software compensation of 4 s time constant during a transition from room temperature to finger temperature can be seen in the graph above. The full measurement range of the sensor is from -40°C to 125°C, but the accuracy of the sensor is only ±0.5°C outside the -5°C to +50°C temperature range.

The downside of the TSYS01 is that it is remarkably difficult to use without a nicely designed temperature sensor board. The 4mm by 4mm QFN16 package is a surface mount device, an therefore needs a soldering oven. Additionally the part needs a very stable 3.3V voltage source, a 100 nF capacitor very close to the chip and can only tolerate 3.3V logic level signals. Additionally programming your micro controller to interface with the device using SPI or I2C can be difficult, if you are not very familiar with neither of them(these are the interfaces supported by the sensor).

In the university project we had to design our own temperature sensor board, get the PCBs professionally manufactured, solder the components our selves and implement the SPI communication code, because no temperature sensor board for the sensor was available in the market at that time.

Now it is possible to buy a temperature sensor board that solves these difficulties for hobbyists and use it with an opensource Arduino driver! The board has a 3.3V linear regulator providing low noise power for the sensor, includes the required capacitor, is 2.54mm bread board compatible(!!) requiring no soldering oven, protects the sensor from over voltage, reverse voltage and electrostatic discharge. Therefore, it is now much easier to use for hobbyists, researchers and people doing prototype work for a company.

## Step 2: Sourcing the Parts

To follow this instructable you need an Arduino compatible micro controller, the TSYS01 Temperature Sensor Board, a programming cable/device for your micro controller and the jumper wires to connect the temperature sensor board to the microcontroller.

Additionally, if your Arduino is a 5V logic level device, you should consider using a 5V to 3.3V logic level converter. This project will most likely also work without a logic level converter on a 5V Arduino, because the over voltage protection should protect the 3.3V temperature sensor, but using the over voltage protection for level shifting is a bad decision in terms of long term reliability. The safest option is to buy a 3.3V Arduino device. I am using the 3.3V 8MHz Pro Mini. That being said, I have tested the TSYS01 temperature sensor board with a 5V Arduino Nano without any issues. I have also accidentally connected 12V to the logic level pins of the device and it has been fine. My experience is that the over voltage protection relying on resistors and schottky diodes works fine.

I am suggesting to buy most of the stuff you need from the Elecrow webshop (http://www.elecrow.com/), because it is currently the only place to buy the TSYS01 Temperature Sensor Board and you can get most of the stuff you need with only one order and at the same time. If you are using the Arduino Pro Mini, you will also need some tin and access to a soldering iron to solder in the pins.

Bill of Materials for My Setup:

* TSYS01 Temperature Sensor Board, 25\$ from http://www.elecrow.com/tsys01-temperature-sensor-b...

* 3.3V 8 MHz Arduino Pro Mini + USB Serial Converter, ~7\$: (Search ebay for: Pro Mini atmega328 3.3V 8M Arduino Compatible+CP2102 USB 2.0 to UART TTL module). Make sure the description says that it is the 3.3V version.

* Male-Female Jumper Wires x 7, 2.80\$: http://www.elecrow.com/254mm-femalemale-jumper-wi...

* Female-Female Jumper Wires x 5, 2.80\$: http://www.elecrow.com/40-pin-dual-female-splittab...

For 5V Arduino owners:

* You should by logic level converter for high reliability and make your own setup regarding that.

* If you only want to test the TSYS01 Temperature Sensor Board without a logic level converter, it will most likely work, but I won't be responsible if it doesn't.

* You can buy a 3.3V Pro Mini clones really cheap from eBay, why not buy one and be safe? (Search ebay for: "Pro Mini atmega328 3.3V 8M Arduino Compatible+CP2102 USB 2.0 to UART TTL module") Make sure the description says that it is the 3.3V version.

## Step 3: Choose Between I2C and SPI

The TSYS01 Temperature Sensor Board supports SPI and I2C communication. You will have to decide for one of them and connect the sensor board for one of them. The connection you are using should similarly reflect the settings you are using in your sketch.

I2C

The I2C connection requires only two data lines to be connected to the temperature sensor board. It also allows multiple devices to share the same two data lines: SDA(data signal goes here) and SCL(clock signal for timing). Selecting the preferred device to communicate with is done by sending a unique I2C address before sending the data packets. At the default Arduino transmission speeds, however I2C is much slower than SPI. Additionally I2C can only pull signal lines down to ground level. The signal level high is acchieved by using two resistors: One between 3.3V and SDA, and the other between 3.3V and SCL. This makes the signal levels to go to 3.3V if the I2C device is not actively pulling the lines down. Atleast most Arduinos should have internal pull-up resistors for the I2C data lines. However, in some cases these internal pull-up resistors may not be enough and external resistors with lower resistance values should be added.

SPI

The SPI connection requires more data lines than I2C, but is also faster, simpler and able to pull signal levels up without additional resistors. The signal lines required are: MOSI(data from master to slave), MISO

(data from slave to master), SCLK(clock signal) and CS(chip select). Because SPI has seperate data lines for different transmission directions, the data can simultaneously be transferred in both direction(not possible on I2C). The MOSI, MISO and SCLK data lines can be shared between multiple SPI devices, but the CS pin has to be used seperately for each device, because it is used to select the preferred device to communicate with. If you have enough available pins on your microcontroller, this is probably the better communication method to choose.

## Step 4: Connecting the TSYS01 Temperature Sensor Board to Arduino

You should connect the TSYS01 for the communication method you chose in the previous step. The pin numbers for Arduino Pro mini are given in the brackets. If you are using another arduino, you should check the correct pin numbers yourself.

For I2C:

Board connection:
Arduino <-> TSYS01 Sensor Board

------------------------

3.3V - 12V (VCC) <-> Vin

GND <-> GND

SCL(A5) <-> SCLK/SCL

SDA(A4) <-> MOSI/SDA

Optionally you can also use:

A0 <-> Shutdown (If you want to use the shutdown feature of the board for reduced power consumption)

GND <-> CS/ADDR (If you want to use the alternative I2C address for the board. This is required to get two different sensor working on the same I2C bus.)

For SPI:
Board connection:

Arduino <-> TSYS01 Sensor Board

------------------------

3.3V - 12V(VCC) <-> Vin

GND <-> GND

SCLK(13) <-> SCLK/SCL

MOSI(11) <-> MOSI/SDA

MISO(12) <-> MISO

GND <-> MODE (To select SPI mode from temperature sensor board)

Optionally you can also use:

A0 <-> Shutdown (If you want to use the shutdown feature of the board for reduced power consumption)

The Arduino driver and some design files for the sensor board can be found from a Github repository: https://github.com/Ell-i/ELL-i-KiCAD-Boards After creating a sketch for you project in the Arduino IDE the easiest way to get the code is to download a zip file from the repository, extract it, navigate to

ELL-i-KiCAD-Boards/TSYS01/Arduino/ and copy the Tsys01.h and Tsys01.cpp files to the directory of your sketch. Now the library should be ready to use.

Next you can test the sensor with the following simple sketch if you chose SPI. If you want to use I2C instead, you only need to comment the SPI sensor object creation line and uncomment the I2C replacement.

Example sketch:

#include "Tsys01.h"

#define slaveSelectPin 10

#define powerPin A0

Tsys01* sensor;

void setup() {

Serial.begin(9600);

//Create SPI sensor object

sensor = new Tsys01(TSYS01_SPI, powerPin,slaveSelectPin);

//Create I2C sensor object

//sensor = new Tsys01(TSYS01_I2C, powerPin);

}

void loop() {

//Delay to wait ADC conversion to finish.

//9ms should be enough but let's wait 10 ms to be safe.

delay(10);

Serial.print("The temperature is: ");

Serial.println(temperature,6);

delay(500);

}

## Step 6: Use TSYS01 in Your Own Project!

Now you should be ready to use the TSYS01 temperature in your own sensor board. It is also easy to generate high resolution temperature graphs using the sensor. For example the temperature of the exhaust air of my cpu cooler before, during and after a stress test is shown in the picture above. The horisontal axle is seconds and the vertical axle is exhaus air temperature in celsius. Having an arduino attached to the TSYS01 makes for a really accurate DIY temperature probe for use with a computer whenever you may need it! The graph in this instructable were made by printing CSV from the Arduino to the serial port and writing the serial data to file with a Python script. The code for doing this can be found from: https://github.com/Apocalyt/spiTSYS01DataToCSV

## Recommendations

• ### Arduino Class

69,897 Enrolled

• ### Planter Challenge

We have a be nice policy.

## Questions

Hi, your post looks very interesting for my bachelor thesis. I have one or two questions.

The temperature sensor board the thing that actually measures the temperature? I mean, if you need a thermocouple, for example.

If not, are there temperature sensor boards that measure temperatures over 1000ºC? I would like to measure the temperature during a 3D laser printing process.

If yes, would it react fast enough?

And if all of this worked, would it be possible to conect a few of these sensors parallelly with the same bread board?

2 replies

Hello, the temperature sensor board used here doesn't use any external sensor(thermocouple etc.), so this sensor board doesn't propably work for you. The sensor used in this sensor board is the tsys01 integrated circuit:

http://www.te.com/commerce/DocumentDelivery/DDECon...

If you need fast reactions to temperature changes and temperatures in the class of 1000 ºC thermocouples of type K are propably your best bet. You can find thermocouple driver boards from adafruit, sparkfun or ebay, but they usually support only one thermocouple per board. Most of the thermocouples and boards give you something around ± 2 ºC accuracy.

I did some searching and it seems that the thermocouple wire has problems withstanding 1000 ºC so most thermocouples meant for temperatures that high have a metal tip. The metal tip may make the thermocouple slower to respond to temperature changes and it may be more difficult the utilize a metal tipped sensor in you thesis.

One option would also be to use an infrared based noncontact thermometer to measure the temperature, but the infrared sensors capable of 1000 ºC seem to be quite expensive.

Thank you for your reply. Yesterday I borrowed an infrared based noncontact thermometer in my uni, I just have to get it to wok.

I'd say thermocouples are completely discarded.

Thanks :D

Very interesting Instructable. FOr some reason, I love to measure temperature.

I used to use the analog LM35 (not able to read negative degrees C) but accuracy & calibration was always an issue.

Moved over to the Sensirion SHT21 I2C temp/humidity sensors, but was way too expensive.

Then I moved over to the Dallas DS18B20 one-wire temperature sensors to increase accuracy. No need for calibration (also internal factory calibrated). It is not as accurate as yours (0.0625 degrees steps) but works great as well.

3 replies

Thank you. I agree that the Dallas DS18B20 is a easy, cheap and quite accurate sensor to use even though it doesn't reach the specification of the more expensive tsys01. (±0.1°C vs ±0.5°C accuracy) ( 0.0001 vs 0.0625 resolution) (10 ms vs 750 interval between measurements)

Have you measured how much the temperature values vary between different measurements in the same temperature? I mean how much difference there is between successive measurements in constant temperature?

An interesting project/use for the tsys01 that comes to mind might be to calibrate cheaper temperature sensors for higher absolute accuracy. The low noise, high resolution and high accuracy should make this relatively easy with the tsys01. The calibrated sensor does ofcourse also need to be relatively low noise and high resolution and you would need to build a temperature controlled box of some kind. I think the process could be made quite automatic though.

Hi. Yes, I did quite a few tests using four DS18B20 sensors. Doing these tests, proved to be more difficult than I thought. Having the 4 sensors side by side on a breadboard, I noticed that the slightest airflow will create a difference between the 4 sensors. After placing the sensors in a plastic container, airflow changes were sorted out.

What I did find is that even in a plastic box, the sensor on the one side will read different from the sensor on the other side. By rotating the system, the readings changed accordingly. This differences in the readings was due to the radiated heat inside the room. I noticed almost a 5 degrees C difference in temp between the various walls.

Conclusion of tests - Readings are very close to each other between the 4 sensors. But left in air, they detect the slightest differences in temperatures.

To make the tests more reliable, I ended up mounting the 4 sensors between two aluminium plates. With this method, the temperature difference between the 4 sensors varied by most 2 bits up/down, or 0.125 degrees C.

I did some data logging over a 2 week period, taking a reading from each of the 4 sensors at 10 second intervals. The biggest deviation from the average of the 4 sensors were less than 0.5 degrees C.

The unit was later used for about 4 years as a weather station. It measured wet and dry bulb temperatures, system temperature, and inside temp. Each outdoor sensor was connected to the circuit via a 2.5m twin core microphone cable.

That was very interesting, thank you for sharing. From this I would deduce that the DS18B20 is quite a good sensor for the price.

I did some preliminary testing with two tsys01 sensors connected to one another through the copper pad in room temperature of about 20 degrees and I remember the difference being around 0.03 degrees C. However, I would need to design a longer experiment to get more reliable results. Very small differences in the room or the measurement setup could be affecting my result.

English isn't my native language, maybe I don't properly get your text but I understand that you write that using an analog sensor and convert with an ADC can produce errors. But tell me, what is your sensor if it's not an analog one with an ADC included ? I don't know any digital way to measure temperatures for now.

Then sensor itself is always going to be analog. In this sensor the analog circuit is confined inside the tsys01 QFN16 package of the temperature sensor. This means that the 24 bit ADC is inside the QFN16 package. The tsys01 chip communicates outside with digital signals.

The tsys01 doesn't contain a processing unit for converting the ADC values to actual temperature values. Instead the raw ADC values are sent to the Arduino which performs the conversion from ADC values to temperature. This is done because having the processing circuit next to the ADC like in the Arduino integrated ADCs will produce noise in the ADC result. Because the tsys01 sensor is far away from the processing unit of the Arduino, there is no noise caused by the operation of the processing unit affecting the ADC result. This also means that external ADCs have usually less noise than ones integrated into a microcontroller.

At the beginning of operation the Arduino has to retreive the calibration parameters specific to each tsys01 sensor from the sensor. By using these parameters it is possible to calculate the real temperature value usign a fourth degree polynomial in the Arduino. The driver provided in the github repository handles these things pretty automatically. You only need to initialize a sensor object, order the start of the ADC, wait for the conversion to finish and then read the temperature values(the driver converts the ADC results to temperature automatically).

Very nice project. I was wondering if you thought about Texas Instruments LM34 or LM35 sensors. The LM35 has an output linearity proportional to the Centigrade Temperature. And it will handle 4 to 30 supply voltage range as well and only three pins setup. It has a +/- accuracies of 1/4 degree C at room temperatures and a range of -55C to +150C. I've used them before and they are extremely easy to use and very accurate also. Of course I am not taking anything from your nicely thought our project by any means.

The LM35 seems like a nice sensor and much easier to use than the tsys01 used in the temperature sensor board. However, the project the sensor board was originally designed for required a temperature sensor capable of atleast +/- 0.1 absolute accuracy at temperatures from 10 to 40 degree C. The tsys01 promises to provide +/- 0.1 degree accuracy from -5 to 50 degrees celsius and is therefore 2.5x as accurate as the LM35 in the desired range. The sensor board and driver obviously makes using the tsys01 much easier.

There is also a very low amount of measurement noise while using the tsys01, I can get almost a hundred samples per second for a few seconds and have all of the values be within 0.01 degrees celsius of each other in my room. For longer times than that the room temperature is not stable enough. The LM35 seems to require usage of the ADC microcontroller to read the temperature values, which will introduce its own noise and error to the measurement. ADCs integrated to a microcontroller usually have much more noise than the ADC in the tsys01, because the operation of the processor causes some noise in to the ADC reading. In the case of the original project the high resolution with low noise was useful because it enabled a temperature control algorithm to react to rising or falling temperatures even before the temperature rose or fell 0.1 degrees C.

It also has very low self heating (0.02 degrees celsius at 10 samples/second in still air). The LM35 seems to have self heating of 0.1 degrees celsius according to the datasheet.

There is currently a research project ongoing at my university using an earlier version of the temperature sensor board that deals with the human perceived temperature sensation in which on some materials(mainly metal) some humans have been able to differentiate between temperature difference of 0.1 to 0.2 degrees celsius.

If you want you can check the project documentation of the original project usign a prototype sensor here:

https://wiki.aalto.fi/display/MEX/Constant+tempera...

You can expand the bar on the left to show you more details about different parts.
There is also some Matlab code for controlling temperature that was converted to Arduino code in here, it will get very difficult very soon though if you have no experience with optimal control theory:

https://wiki.aalto.fi/display/MEX/Temperature+box+...

Very nice project. I was wondering if you thought about Texas Instruments LM34 or LM35 sensors. The LM35 has an output linearity proportional to the Centigrade Temperature. And it will handle 4 to 30 supply voltage range as well and only three pins setup. It has a +/- accuracies of 1/4 degree C at room temperatures and a range of -55C to +150C. I've used them before and they are extremely easy to use and very accurate also. Of course I am not taking anything from your nicely thought our project by any means.

THAT is a very nicely designed board! I presume the cutouts in the PCB help to reduce the mechanical stress on the sensor as well as providing lower thermal mass, right? What purpose serve the small pieces of PCB on either side of the sensor?

Also thumbs up for the LDO you've chosen. So few regulators are reverse protected and so often I accidently swap the power pins. Good to know that won't fry the expensive chip!

Thanks for sharing this with us!

3 replies

The two pieces of PCB were designed for optionally mounting the sensor with M2.5 screws on a surface or on some other mounting point. The PCB was also designed to be easily cuttable, one can cut away the mounting pieces or the whole sensor island if small size is the most important parameter.

The sensor island has small pads for soldering your own pin header or wires. Cutting of the sensor island will ofcourse remove the regulator, input protection and force you to use the I2C interface, but you can get a very small breakout board.

The cutouts and lack of ground plane at the sensor island should help to prevent any possibility of heat conduction from the regulator or any other component on board. The high resolution can show very small differencess and heat conduction from wrong sources should be prevented.

Hey, thanks for the reply Apocalyt, I didn't realized that the borad alyo doubles as a tiny breakout. Thanks for this engeneering inside, I'm sure it'll come handy someday!

I don't really recommend cutting of the sensor island though unless you really know what you are doing.

Very useful!