Hi there.
It's me again with my PT100 problem XD
In my last version, I used a voltage divider to calculate the resistance of the PT100 sensor, which worked just "OK" but, I'm not satisfied with it, I think that it still has room to upgrade a bit.
So I decided to use a Wheatstone Bridge instead of a voltage divider and this is my circuit:
As you can see, I'm using an ADS1015 (it's ADS1115 in the circuit but I have ADS1015) to measure the voltage in differential mode. In A0 and A1 I connect the output voltage of the Wheatstone bridge and to the A2 and A3, I connect the GND and VCC so I can measure the very exact VCC of the circuit for future calculations.
The resistors in the circuit are 100 Ohms but in the actual circuit on a breadboard, I measured each resistor's actual value and used that in the sketch, not just 100 Ohms.
Heres my sketch:
#include <Wire.h>
#include <Adafruit_ADS1015.h>
Adafruit_ADS1015 ads; //Initialize ADS1015 12-bit ADC module
float WBVoltage = 0.0; //Voltage measured from wheatstone bridge
float R1 = 96.7; //resistance of 1st known resistors in wheatstone bridge
float R2 = 97.5; //resistance of 2nd known resistors in wheatstone bridge
float R3 = 97; //resistance of 3rd known resistors in wheatstone bridge
float Resistance = 0; //resistance of unknown resistor AKA PT100 sensor
float Vin = 5; //VCC Voltage of the circuit / wheatstone bridge
float Temperature; //The calculated temperature
void setup() {
// initialize serial:
Serial.begin(9600);
// ADS1015 ADS1115
// ------- -------
ads.setGain(GAIN_TWOTHIRDS); // 2/3x gain +/- 6.144V 1 bit = 3mV 0.1875mV (default)
// ads.setGain(GAIN_ONE); // 1x gain +/- 4.096V 1 bit = 2mV 0.125mV
// ads.setGain(GAIN_TWO); // 2x gain +/- 2.048V 1 bit = 1mV 0.0625mV
// ads.setGain(GAIN_FOUR); // 4x gain +/- 1.024V 1 bit = 0.5mV 0.03125mV
// ads.setGain(GAIN_EIGHT); // 8x gain +/- 0.512V 1 bit = 0.25mV 0.015625mV
// ads.setGain(GAIN_SIXTEEN); // 16x gain +/- 0.256V 1 bit = 0.125mV 0.0078125mV
ads.begin();
}
void loop() {
int16_t WB; //This will contain the diffrential value of Wheatstone Bridge output
/* Be sure to update this value based on the IC and the gain settings! */
float multiplier = 3.0F; /* ADS1015 @ +/- 6.144V gain (12-bit results) */
//float multiplier = 0.1875F; /* ADS1115 @ +/- 6.144V gain (16-bit results) */
WB = ads.readADC_Differential_0_1();
WBVoltage = WB * multiplier / 1000;
int16_t VCC; //This will contain the diffrential value of VCC voltage
// Be sure to update this value based on the IC and the gain settings!
float multiplier2 = 3.0F; // ADS1015 @ +/- 6.144V gain (12-bit results)
//float multiplier = 0.1875F; // ADS1115 @ +/- 6.144V gain (16-bit results)
VCC = ads.readADC_Differential_2_3();
Vin = VCC * multiplier2 / 1000;
Resistance = ((R2 * R3) + (R3 * (R1 + R2) * WBVoltage / Vin)) / (R1 - (R1 + R2) * WBVoltage / Vin); //WB equation for calculating the unknown resistor AKA PT100
Temperature = (Resistance * 2.6) - 260; //Calculate the temperture
Serial.println("--------------------");
Serial.println(" ");
Serial.print("Voltage: ");
Serial.println(WBVoltage, 5); //Print the measured voltage from WB
Serial.println(" ");
Serial.print("VCC: ");
Serial.println(Vin); //Print the VCC voltage
Serial.println(" ");
Serial.print("Resistance: ");
Serial.println(Resistance, 5); //Print the calculated resistance of unknown resistor AKA PT100
Serial.println(" ");
Serial.println("--------------------");
Serial.println(" ");
Serial.print("Temp: ");
Serial.println(Temperature);
Serial.println(" ");
Serial.println("--------------------");
Serial.println(" ");
delay(750);
}
Now let's get to my problem,
In action, everything works fine, calculations are correct the measured value is correct and relatively stable, the only thing that makes everything useless is that the calculated resistance I get is wrong.
For example, when the serial shows the resistance of 123 Ohms, the actual resistance is about 111 or so.
The equation I'm using for converting the measured voltage into resistance is this:
Resistance = ((R2 * R3) + (R3 * (R1 + R2) * WBVoltage / Vin)) / (R1 - (R1 + R2) * WBVoltage / Vin);
I got this equation from this website. you can see it at the very end of this page.
And if I insert my measured voltage in the website, It gives the same value that I already calculated.
I thought that it may be because of the current that is going through the PT100, I measured the current, and its 20mA.
It's relatively small, but even if this is the problem, the resistance of the PT100 should stay high after I disconnected it from the circuit to measure the resistance with my multi-meter, and then drop slowly in few seconds. but it's not like that, it's just that same 111 Ohms or something near that which means 25°C.
So I don't know what else can be the problem, I'd appreciate any help and advice.