Measuring Temperature using PT100 and Arduino

In this article, you will learn how to Measuring Temperature using PT100 and Arduino. PT100 is a platinum resistance thermometer, which changes its internal resistance according to temperature. In the name PT100, 100 represents ohm i.e. it offers 100-ohm at 00C. Similarly, PT1000 offers 1000-ohms at 00C. PT100 is widely used in industries because of its temperature range.

From the nature of the resistance thermometer, we conclude that tolerance depends upon the range we are using it. When we used to measure temperature nearer to 00C (in both positive and negative), tolerance is minimum. As the difference with 00C increases tolerance also increases. Tolerance is lower at 500C in comparison to 1000C.

Circuit Arrangement and Description of Measuring Temperature using PT100 and Arduino

The circuit for Measuring Temperature using PT100 and Arduino is designed around quad op-amp LM324, Arduino board, display, and a few other electronic components like resistors, capacitors, etc. For a proper description of the circuit, we divided the entire circuit into small sections.

author prototype of Measuring Temperature using PT100 and Arduino

Voltage divider network for PT100:

PT100 is a resistance thermometer i.e. its internal resistor changes according to temperature. A simple voltage divider with a constant voltage source (say 5v), constant resistor, and PT100 is connected as shown in figure 1.

The resistance is changing according to temperature as a result Vout (voltage across PT100) also changes. This changing voltage is depending upon changing resistance.

Note: PT100 is available in different wire connections i.e. 2 wire, 3-wire, and 4-wire. They have only single input and a single output. Let’s say, in this project, we are using 3 wire PT100, one wire is of red color and two-wire are of white color. If you check the continuity between these wires then, two white wires are connected together so just connect both the wire to the ground. If you have PT100 in the 4-wire version then two white wire is shorted together and two red wire is shorted together.

By using the voltage divider formula, we can calculate output voltage. The mathematical formula for voltage divider network

V_{out} = \dfrac{V_{cc} \times R_{TD}}{R_{TD} + R}

While choosing a fixed resistor (R) we have to consider a few things:

  1. The value of the resistor (R) must be great enough order to avoid the self-heating problem. If we use low-value resistance more voltage drops across PT100, and as a result, more self-healing. This increases errors.
  2. The value of R must be low enough in order to avoid the problem of a lower signal-to-noise ratio. If we increase the value of R, the change in magnitude per degree decreases as a result lower signal-to-noise ratio. A large value of R also increases noise which is also responsible for the lower signal-to-noise ratio.

For selecting proper R, we have to do a trade-off between self-heating problems and a better signal-to-noise ratio. Let’s see the consideration for choosing between the value of R.

pt100 voltage divider network

Figure 1: PT100 voltage divider network

Range Selection of Thermometer

Now, let’s suppose we design a thermometer for the 00C to 1500 range. If we consider fixed resistance R = 1K and RTD at 00C = 100-ohm, then output voltage Vout can be calculated as:

V_{out} = \dfrac{5 \times 100}{100 + 1000} = \dfrac{500}{1100} = 0.4545V

Similarly, Vout at 1500C:

According to datasheet of PT100 resistance at 1500C RTD = 157.33

V_{out} = \dfrac{5 \times 157.33}{157.33 + 1000} = 0.6797V

From the above calculation, we have to measure the voltage between 0.4545V to 0.6757V.

Low Pass Filter:

The length of the RTD sensor and its leads is long and might act as an antenna, as a result, it starts to pick up the noise and mixes with temperature voltage. In order to avoid this problem, a capacitor of high value (say 100uF) is connected parallel across the RTD sensor. This capacitor here acts as a low-pass filter and removes almost all noise.

pt100 voltage divider network with low pass filter

Figure 2: pt100 voltage divider with low pass filter

Voltage follower circuit:

There is two reasons for using a voltage follower circuit:

  1. To avoid the loading effect.
  2. Higher input resistance.

The output of PT100 (VOUT) is given to the voltage follower circuit. A voltage follower circuit is basically a unity gain noninverting amplifier. This amplifier circuit is called a voltage follower because the output voltage is equal and in phase with the input. The output of PT100 (VOUT) is connected to the non-inverting terminal where the inverting terminal is connected directly to the output (for unity gain). Check out other applications of operational amplifiers.

pt100 voltage divider network with voltage follower

Figure 3: PT100 Voltage Divider Network with Voltage Follower Amplifier

The minimum temperature we are going to measure is 00C. The voltage at this temperature (00C) is 0.45450C. So, we need to subtract this voltage in order to get 0V at 00C. For this purpose, we need a differential amplifier. But before that, we need another constant 0.4545-volt source. For the constant 0.4545 V source, we have designed another voltage follower circuit.

Constant Voltage Source:

constant voltage divider network

Figure 4: Constant Voltage Divider Network

The constant voltage source is designed using a voltage divider network made from a resistor (R2) and a variable resistor (VR1), adjust the variable resistor so that the output voltage must equal the voltage at the minimum temperature you are going to measure (say 00C, at 00C voltage from PT100 = 0.4545V). Same as above we are using a voltage follower circuit in order to avoid the loading effect. The output from the voltage divider network is connected to the non-inverted terminal where the inverting terminal is connected directly to the output pin.

constant voltage divider network with voltage follower amplifier

Figure 5: Constant Voltage Divider Network with Voltage Follower Amplifier

Differential amplifier:

A differential amplifier has two input terminals that are both isolated from the ground by the same impedance. The differential amplifier amplifies only the difference in voltage at two input terminals (inverting and non-inverting pins).

The output of PT100 (from the voltage follower amplifier) is given to the non-inverting terminal whereas the output of the fixed voltage source (from the voltage follower amplifier) is given inverting terminal. While designing the differential amplifier we have to calculate gain i.e. up to what input voltage must be amplified.

From the derivation of the differential amplifier, the voltage output is given by,

V_{out} = \dfrac{R_B}{R_A}(V_2-V_1)    …..(1)

Where, RB = Feedback Resistor

RA = Input Resistor

V1 = voltage at the inverting terminal

V2 = voltage at the non-inverting terminal

Checkout the derivation and key parameter of the Differential amplifier

Case 1: When the temperature is set to 00C, the output of PT100 is 0.4545V, and the output of the fixed voltage divider is also 0.4545V. The differential amplifier output also becomes zero.

V_{out} = \dfrac{R_B}{R_A}\times(0.4545-0.4545) V_{out} = \dfrac{R_B}{R_A}\times 0

Case 2: when the temperature is at maximum say 1500C voltage output from PT100 = 0.6797V

Differential output, V_{out} = \dfrac{R_B}{R_A}\times {0.6787-0.4545}

V_{out} = \dfrac{R_B}{R_A}\times 0.2252

Here, gain = RB/RA.

Before calculating the gain of the differential amplifier, let’s clear some doubts.

Selecting the Proper Reference value for Arduino

The default internal ADC reference voltage of Arduino is 5V with 10-bit ADC i.e. it divides input voltage by 210 (1024) division. The resolution of Arduino at 5V = 5/1024 = 4.88mV.

From the above calculation, we found that for the 00C to 1500C temperature range, lower voltage = 0.4545V and higher voltage = 0.6797V.

The voltage difference between lower voltage and higher voltage = 0.6757V-0.4545V = 0.2252V.

Total number of divisions for 0.2252V = 0.2252V/4.88mV = 46.14 i.e. Approximately 47 divisions for 00C to 1500.

Arduino shows 150/47 = 3.250C per division change in voltage i.e. lowest temperature difference Arduino can measure is 3.250C which is not preferable. So, we need an amplifier.

We can use an amplifier at the full range but there are two problems:

  1. Higher gain: We have to amplify differential input voltage to a high extent (say 5V) as a result we have used the higher value of the feedback resistor.
  2. External power supply needed: It is difficult to amplify up to supply voltage. According to the datasheet of LM324, maximum amplifier output voltage = supply voltage -1.5V. If we are using 5V from Arduino as the supply voltage then maximum amplified voltage = 5V-1.5V = 3.5V. So, at 5V supply, 1.5V of ADC is wasted. In order to utilize the default 5V reference, we need the external power supply for LM324, which must be greater than 6.5V.

In order to solve the above problem, we are decided to utilize the 1.1V internal ADC of Arduino and this can be selected in the Arduino source code. The resolution of Arduino for 1.1V reference = 1.1/1024 = 1.074mV.

Gain Calculation for differential amplifier

Here, we are using a 1.1V internal reference voltage thus maximum voltage that Arduino can read is 1.1V. So, we have to amplify the maximum differential voltage (say 0.2252V) to 1.1V

Vout = 1.1V

2-V1 = 0.2252V

Now putting the above value in equation (1)

1.1V = \dfrac{R_B}{R_A}\times 0.2252V \dfrac{R_B}{R_A} = \dfrac{1.1}{0.2252} = 4.680

Therefore, gain = 4.680.

In order to achieve a gain of 4.680, the value of resistor RB must be 4.680 times the value of resistor RA. While choosing the value of resistor RA and RB we have to consider a few things.

  1. The ratio of resistor RB and RA need to be as close to 4.68 as possible.
  2. The higher value of the resistor increases noise and decreases power consumption

Here also we have to trade off between noise and power consumption.

S.N. Input Resistor (RA) Feedback Resistor (RB) Noise Power Consumption
1 1K 4.68K Low High
2 10K 46.8K Medium Medium
3 100K 468K High Low

You can use any combination according to your requirement. If we choose 2nd combination (RA = 10K and RB­ = 46.8K), noise is considerably lower than 3rd combination (RA = 100K and RB­ = 468K) and power consumption is lower than 1st combination (RA = 1K and RB­ = 4.68K). So, here we are using 2nd combination.

differential amplifier for pt100

Figure 6: Differential Amplifier for PT100

Arduino Circuit:

The output of the differential amplifier is given to the analog input pin of Arduino. Arduino reads the voltage division, converts it into temperature using the equation, and displays it over LCD. The LCD is connected to Arduino in higher-order data mode i.e. only a higher data bit of LCD (D4 to D7) is connected to Arduino. The output of the differential amplifier is given to analog pin A0. Check out the Tutorial video on how to interface Arduino and 16×2 LCD.

arduino nano and display interfacing

Figure 7: Arduino NANO and Display Interfacing

Now, combining all these 7 subsections. Figure 8 shows the complete circuit diagram of  Measuring Temperature using PT100 and Arduino.

Component list of Measuring Temperature using PT100 and Arduino

Resistor (all ¼-watt, ± 5% Carbon)
R1 = 1 KΩ

R2, R5, R6 = 47 KΩ

R3, R4 = 10 KΩ

R7 = 220 KΩ

R8 = 330 Ω

VR1, VR2 = 10 KΩ

Capacitors
C1 = 100 µF/16V (Electrolytic Capacitor)

C2 = 100 nF (Ceramic Disc)

Semiconductors
U1 = LM324 (Quad Op-Amp)
Miscellaneous
PT100 Temperature sensor

Arduino Nano or equivalent

16×2 Alphanumeric LCD

Measuring Temperature using PT100 and Arduino

 

Conversion of Voltage to Resistance

Arduino read the voltage from the differential amplifier in division form. The voltage read by Arduino is first converted into resistance using the equation of a straight line i.e. Y = mX + C. Here we have to calculate the value of m (slope) and C (constant). For slope we have to measure voltage and resistance at two different temperatures let’s say at 300C and 1500C.

At temperature T1 (300C)

VT1 = 0.09V

RT1 = 111.2-ohm (According to Datasheet)

At temperature T2 (1500C)

VT2 = 1.1V (As we are using 1.1V internal ADC.)

RT2 = 160-ohm (According to Datasheet)

Formula for slope m = \dfrac{y_2-y_1}{x_2-x_1}    ….(2)

Let, X1 = 0.09, X2 = 1.1V, Y1 = 160 and Y2 = 111.2. Putting these values in equation (2) we will the value of the slope

Therefore, m = \dfrac{160-111.2}{1.1-0.09} = 48.31

Now, put the value of m (slope) in equation Y = mx+c, in order to find the value of c (constant). At 1500C, RTH = 160-ohm, and Vout = 1.1V.

Now, putting the value Y = 160, x = 1.1 and m = 48.31

C = Y – mx = 160 – 48.31 x 1.1 = 106.852

Also, from datasheet of PT100, value of \alpha = 0.00385

Slope (m) = 48.31

Constant (c) = 106.852

R0 (resistance at 00C) = 100-ohm

\alpha = 0.00385

These are the value we need in software code.

Software Code for Measuring Temperature using PT100 and Arduino

Software is written in Arduino programming language and compiled using Arduino IDE. While writing software code you have to consider a few things like selecting an internal 1.1V internal ADC. In order to select internal 1.1V internal ADC you have to add syntax in the setup() function.

analogReference(INTERNAL);

Syntax to convert bits into voltage

Volts = (analogRead(Vin)/1023.0)*5.0;

Syntax to convert voltage into resistance

Rx = Volts*slope+C;

Syntax to convert resistance into temperature

temp1= (Rx/R0-1.0)/alpha;

Syntax for calibration

calibration=0.3+(0.005*temp1);

Now let’s see the complete code for Measuring Temperature using PT100 and Arduino

Download the library used in this project.

Timer. h

LiquidCrystal.h

Making Video of Measuring Temperature using PT100 and Arduino

 

 

Check out  other top popular Articles :

What is underpinning

Clock Signal Generator Circuit

33 Thoughts to “Measuring Temperature using PT100 and Arduino”

  1. BIBUTHI PAL

    I have completed the circuit part exactly as it is . But facing problem in interfacing

    Below are the issues

    Error 1: INTERNAL was not disclosed in this scope
    Solved : float INTERNAL; I added this and issue is solved
    Error 2: SERIAL PORT not connected
    Solved : by installing driver from http://www.wch.cn/download/CH341SER_EXE.html
    Error 3: error compiling for Arduino Nano

    Solution please , the board is

    Arduino Nano V3.0 ATMEGA 328P

    Please help me to compile and upload this to work … URGENT

    1. INTERNAL is used here for reference voltage, you do not gave to define it as float.
      Code is clean and checked, and no need to edit.
      Please install latest Arduino IDE form arduino.cc, and then check for driver in device management (Window).

  2. Biputhi pal

    Tried . But unable to download . Showing error : error compiling for Arduino NANO . some times communication timed out .

    1. Might be issue of IDE, please check with example program. and if still show error then please download the new IDE and add arduino nano board manually. There are lots of tutorial over internet.

  3. could you attach the .hex file

    1. Sorry, you can compile and get your own from compiled folder.

  4. BIBUTHI PAL

    Im trying to replace NANO with UNO.
    1) Do i need to change anything in code or I can directly use UNO for this project ?
    2) the circuit shows 14 pins for 16X2 ALPHANUMERIC display, whereas standard display has 16 pins ( How should it need to be connected)?
    3) Terminals of NANO and UNO are slightly different and marked differently . How should be the connection if i replace NANO with UNO? Say A0 will remain same for both, what about Digital out for Display ?
    4) How can i turn on a 5vdc computer fan when the measured temperature reaches 50 degree and off when below 40 degree using only arduino output pins and a fan ?

    Please help .

    1. Hi Bibuthi, there will be no change in connection and code if you interchange nano with uno. Because it have share same microcontroller i.e.Atmega328.
      If you are new to arduino and lcd interfacing then i will recommend you to watch tutorial video on How to interface LCD with arduino
      Link: https://youtu.be/NhybrfIrVgE
      IF you wish to control the load according to temperature then i will recommend you to go through these article
      Arduino Based Temperature Control Fan.
      This device can control speed of fan according to temperature.
      Thankyou.

  5. BIBUTHI PAL

    Can i use this code and circuit for UNO ? Any changes required in code or hardware circuit and connections ?

  6. BIBUTHI PAL

    How do i connect a 16 pin display ( circuit shows 14 pin) ?
    How to turn on a 5vdc fan with this circuit when temp reach 50 degree and off when temp reach 40 deg ? Using code and fan alone ?
    New to Arduino and IDE. Please explain

  7. Biputhi pal

    Thank for the fast replay . No I don’t need control of fan. Just turn on fan when display read 50 degree and off fan when temperature below 40 degree . Can I do this with only a 5vdc fan and code ? Please help

    1. For fan you need switching circuit, because maximum current you can withdraw from arduino I/O pin 40mA.

  8. BIBUTHI PAL

    Dear Best Engineering projects,
    I managed to successfully do this project . Could you assist to modify this project with below requirements
    1. Serial Port monitor is just showing Temperature without any units (Only degrees, no volt, resistance or Fahrenheit. How do you modify the code to show identical to LCD display.
    2. What should be added to the code to energies pin 13 of Arduino uno so that the pin13 LED (Inbuilt LED) will glow when temperature is greater than 50 degrees.
    I really appreciate your prompt support .
    Once again thanks for your project . Would really recommend .

    1. Hi, i had modified the code according to your requirement in point 1.
      For point 2.
      in void setup() function add this line of code
      pinMode(LED_BUILTIN, OUTPUT);

      and in void takeReading()function just above add these line

      if(tempC > 50)
      {
      digitalWrite(LED_BUILTIN, HIGH);
      }
      else {
      digitalWrite(LED_BUILTIN, LOW);
      }

      Thankyou

  9. Biputhi pal

    Could you assist to modify this project with below requirements,

    1. Serial Port monitor is just showing Temperature without any units (Only degrees, no volt, resistance or Fahrenheit. How do you modify the code to make serial monitor also show identical to LCD display.
    2. What should be added to the code to energies pin 13 of Arduino uno so that the pin13 LED (Inbuilt LED) will glow when temperature is greater than 50 degrees.
    I really appreciate your prompt support .
    Once again thanks for your project . Would really recommend you.

  10. shubhanker tiwari

    I am trying to develop the same system but my requirement is to get value from 0 to 300 deg C can i use the same feedback resistance and slop, constant. To get this much range.

    1. Feedback resistor is same but slope and constant is changed because voltage and resistance at 300 degree is different from voltage and resistance at 150 degree (Refer to “Conversion of Voltage to Resistance” heading). For this value please prefer datasheet of PT100.

  11. Gaurav

    can i use the same logic, circuit and code with 8051 which has a internal ADC of 12 Bit.

  12. Gaurav

    Hi,
    Can i use the same logic, circuit and code for interfacing PT100 with 8051 which has internal 12 Bit ADC

    1. Circuit and logic will be almost same but code and pin connection of 8051 and amplifier section will be different.

  13. Gaurav

    can you please provide me circuit or any details of how can i use it with 8051.
    what changes have to be done on code and amplifier section.

    1. Hi gaurav,
      Sorry, we cannot provide you complete project buy surely help you to build your own.
      Thanks

  14. Gaurav

    Hi,
    Thanks, how can we proceed.
    My Mail Address is: [email protected]
    Please send me a test message.

  15. Saad Mazumder

    At temperature 0 degree Celsius,
    what will be the value of VT1 ??

    1. At 0 degree Celsius, resistance of PT100 is zero. Thus voltage also become zero.
      @ 0 degree Celsius VT1 = 0V.

  16. Aires

    Hi.
    What is the lowest temperature difference that this circuit reads!?

    What happens if you use a 16bit or 32bit Adc arduino?

    1. Hi, the lowest temperature difference of this circuit is 0.146 degree Celsius.
      If you use higher bit ADC then temperature difference will be further decreases.
      in case of 16bit ADC and 1.1V reference the temperature difference that circuit can read = 0.002 degree celsius.

  17. Gertrud H

    Thanks for a well built and explained project. I have been able to use this base to create a thermally actuated relay for temperature control on a smoker.

    One thing bothers me, though. There’s no explanation on why the output from the last opamp is passed through R7 (220kohm) and in parallel with the capacitor.

    I guess the resistor is to reduce current and the capacitor is to reduce noise, but are they necessary and what affects the resistance and capacitance?

  18. Gertrud H

    There’s no explanation in the article, but I found in the video that it was mentioned that they are passed through the resistor and capacitor. Additionally there was mention of the capacitor acting as a low pass filter.

    There was, however, no details on why the value of the resistor is 220kohm or why it has been added in the first place.

    Please help me understand this.

  19. lolo

    library for timer.h cannot used

  20. Louis

    Would it be possible to program Callendar-Van-Dusen values into this?

    1. Yes, you can program by assigning all the required value.

  21. kumari

    plz, i have problem with Timer t. it doesn’t accept it

Leave a Comment