Skip to content

ESP32 read PT1000 temperature sensor values

In this article, it will introduce how to read the temperature values from PT1000 with ESP32.

The principle of PT1000 measure temperature

PT1000 sensors are temperature sensors that use the principle of resistance to measure temperature. These sensors have a resistor with a resistance that changes with temperature. The resistance of the PT1000 sensor increases as the temperature increases, and decreases as the temperature decreases.

To use a PT1000 sensor to measure temperature, you can connect it to a circuit that measures the resistance of the sensor and converts this value to a temperature reading. This can be done using a microcontroller, such as an ESP32, or using a separate temperature measurement instrument, such as a multimeter or data logger.

To measure the resistance of the PT1000 sensor, you can use a voltage divider circuit or a Wheatstone bridge circuit. In a voltage divider circuit, the PT1000 sensor is connected in series with a reference resistor, and the voltage across the PT1000 sensor is measured. The resistance of the PT1000 sensor can then be calculated from the measured voltage and the known resistance of the reference resistor. In a Wheatstone bridge circuit, the PT1000 sensor is connected in a balanced bridge configuration with other resistors, and the voltage across the bridge is measured. The resistance of the PT1000 sensor can then be calculated from the measured voltage and the known resistance values of the other resistors in the bridge.

Once the resistance of the PT1000 sensor has been measured, it can be converted to a temperature reading using a lookup table or a mathematical formula based on the resistance-temperature relationship of the PT1000 sensor. PT1000 sensors are generally calibrated to the International Temperature Scale of 1990 (ITS-90), which is a temperature scale that is based on fixed points of physical and chemical substances. The resistance-temperature relationship of PT1000 sensors is typically specified in terms of the temperature coefficients of resistance (TCR) and temperature offset (TOFF). The TCR is a measure of how the resistance of the PT1000 sensor changes with temperature, and the TOFF is a measure of the resistance of the PT1000 sensor at a reference temperature (usually 0°C). By using these parameters, you can convert the measured resistance of the PT1000 sensor to a temperature reading using a mathematical formula.

Hardware connection

To read PT1000 analog values and convert them to temperature with an ESP32, you can follow these steps:

Connect the PT1000 sensor two terminals to the ESP32:

  • one end to an analog input pin (e.g. A0).
  • the other end to the GND.

Use the analogRead() function to read the analog value from the PT1000 sensor. This function returns a value between 0 and 4095, corresponding to the voltage on the analog input pin.

Use a lookup table or a mathematical formula to convert the analog value to temperature. PT1000 sensors have a resistance that changes with temperature, and the analog value is directly proportional to this resistance. Therefore, you can use a lookup table or a mathematical formula to convert the analog value to temperature based on the resistance-temperature relationship of the PT1000 sensor.

Display the temperature on the ESP32's display or send it over a network connection (e.g. Wi-Fi or Bluetooth) for remote monitoring or control.

It's also worth noting that PT1000 sensors are not as accurate as some other temperature sensors (e.g. thermocouples or RTDs), so you may want to consider using a different type of sensor if high accuracy is critical for your application.

The sample code:

#define PT1000_ANALOG_PIN A0   // Analog input pin for PT1000 sensor
#define PT1000_R_REF 1000.0     // Reference resistance for PT1000 sensor at 0°C (in ohms)

// Lookup table for resistance-to-temperature conversion
float temperatureTable[] = {-40.0, -20.0, 0.0, 20.0, 40.0, 60.0, 80.0, 100.0, 120}; // Corresponding temperature values
float resistanceTable[] = {842.7, 921.6, 1000, 1077.9, 1155.4, 1232.4, 1309, 1385.1, 1460.7}; // Add more values as needed


// Linear interpolation function
float interpolate(float x, float xTable[], float yTable[], int size) {
  for (int i = 1; i < size; i++) {
    if (x <= xTable[i]) {
      // Linear interpolation
      float x0 = xTable[i - 1];
      float x1 = xTable[i];
      float y0 = yTable[i - 1];
      float y1 = yTable[i];
      return y0 + (y1 - y0) * (x - x0) / (x1 - x0);
    }
  }
  // Extrapolation if x is outside the range of the table
  return yTable[size - 1];
}

void setup() {
  Serial.begin(115200);  // Initialize serial communication
}

void loop() {
  // Read analog value from PT1000 sensor
  int analogValue = analogRead(PT1000_ANALOG_PIN);

  // Convert analog value to resistance
  float resistance = (float)PT1000_R_REF * ((float)analogValue / 4095.0);

  // Convert resistance to temperature using linear interpolation
  float temperature = interpolate(resistance, resistanceTable, temperatureTable, sizeof(resistanceTable) / sizeof(resistanceTable[0]));

  // Print temperature to serial monitor
  Serial.print("Temperature: ");
  Serial.print(temperature);
  Serial.println("°C");

  // Wait for 1 second before taking another reading
  delay(1000);
}
Share:

Comments