I'm trying to use a two wire RTD (Safety and Productivity Solutions | Honeywell) with an arduino uno to measure temperature. The rtd has a nominal resistance of 1000 ohms at 0 degrees, and 1100 ohms at 26 degrees.
I've developed some code for it and have a wheatstone bridge type setup (similar to the one shown here: Resistance thermometer - Wikipedia).
I'm using the uno's 5V output and GND pins as the source for the bridge, and 3 1k ohm resistors. My code should be attached (I've commented out some of the end). When I upload the code to the uno and it starts running, on the serial monitor it only shows 2.42V / 191.7 degrees. It should show approx 26 degrees instead. . .
int sensorPin = 0; // The analog pin the LM35's Vout is connected to
/*
Initialize serial connection with the computer
*/
void setup()
{
Serial.begin(9600); //Begin serial connection with computer
pinMode(sensorPin, INPUT);
}
void loop()
{
int reading = analogRead(sensorPin); //read data from LM35 using A0 pin
float voltage = reading *5.0; //convert sensor data to voltage
voltage /= 1024.0;
Serial.print(voltage);
Serial.println("volts"); //print voltage on serial monitor
float temperatureC=(voltage-0.5)*100; // convert voltage to temp
Serial.print(temperatureC);Serial.println("degrees C"); //print temp to serial monitor
// if(temperatureC >XXXX){
// digitalWrite(ledPin, HIGH);
// delay(1000);
// digitalWrite(ledpin, LOW);
// delay(1000);
// }
// else{
// digitalWrite(ledPin, Low);
// }
delay(1000); // print every second
}
I'm wondering is my issue with the physical circuit I'm using or with my code?
Any help is much appreciated!
Have you tried a lower resistor for R1 in the bridge? The article which you referenced seems to indicate something along the lines of R1 being around half of what R2 and R3 are.
Due_unto - I've tried a variety of different resistors in place of R1 and still get temperatures that are not accurate
jremington - Honestly I'm using a code I found in a book, I've tried changing the equation around, such as changing the 100 to 10, and getting results around 5-6 degrees lower. However I do not know if there is a proper equation relating to the relationship between voltage and temperature for this RTD, I've checked the data sheet and cannot find anything. I have an infrared thermometer that I'm using to verify if my results are accurate or not.
surbyte - Unfortunately I have to use this particular component. From searching through the forums those components would definitely have been easier to use!
You can completely ignore the bridge arm connected to GND -- it doesn't do anything but waste power.
The circuit is exactly equivalent to a voltage divider, with the RTD "on top" and 1K on the bottom, so you can work out what the expected voltage values are at different temperatures.
Or, just calibrate the circuit by measuring voltages at various sample temperatures. See this tutorial.
I was thinking that, does that mean I can remove the other two resistors and just keep the A0 wire connected inbetween the RTD and 1K resistor?
The data sheet for the RTD itself doesn't contain much info, so I'm not sure about the code to change from voltage to temperature. I know that the above code was definitely wrong, but I don't know what approach to take now?