We will use two Digital Temperature Sensor Breakout - TMP102s, found here,
to detect the temperature of the payload during its flight. The TMP102
sends a digital signal representing temperature to the Arduino, and
must be supplied by regulated voltage between 1.4V and 3.6V.
We
used the setup pictured below to initially test our TMP102. After
determining the correct serial port to use under Tools > Serial Port,
we uploaded code to the Arduino. We opened the Serial Moniter to view
the temperature data from the TMP102, and verified its responsiveness to
a change in temperature by touching the Temperature Sensor.
After finding that the TMP102 was sensitive to temperature
changes, we set out to test the accuracy of the TMP102’s data. To test the accuracy, we set up the test with
the following steps:
\ 1. Connect the Arduino and TMP102 as pictured
above.
2. Connect the Arduino to a computer to provide the
TMP102 and Arduino with power, as well as allow direct viewing of data stream
via serial monitor.
3. Upload TMP102 code to the Arduino.
4. Open Serial Monitor to confirm receipt of data.
At this point, we compared our TMP102’s data to the
temperature measured of the surface of the TMP102 by an infrared thermometer. By moving our setup to a variety of settings
at a variety of temperatures, we were able to compare the temperature of the
TMP102 measured by the infrared thermometer to the temperature it
detected. As with any procedure
involving an infrared thermometer, we made sure to stand back from the TMP102
to avoid reflected infrared radiation affecting the reported temperature.
Our first test taking the TMP102 outside showed that it didn’t
cool as quickly as we expected. Though
we placed the setup outside in temperatures below freezing, and the infrared
thermometer reported a temperature below freezing, the TMP102 reported a
temperature of approximately 50 degrees Fahrenheit at its minimum, after
several minutes of cooling. This 20
degree disparity fell well outside of the accuracy reported in the TMP102’s
data sheet of .5 degrees Celsius.
At this point, we decided an alternate temperature sensor
might be more appropriate to use. A
previous year of Capstone used TMP36 temperature sensors, which put out an
analog voltage corresponding to temperature.
The TMP36’s data sheet shows it to be accurate within 2 degrees Celsius. We used the following setup to test both the
temperature sensors in parallel:
1. Connect the Arduino and TMP102 as picoted.
2. Connect the TMP36, according to its pin out
below (NOTE: the picture is a bottom view), connecting Pin 1 to 3.3V on the Arduino,
Pin 2 to A6, and Pin 3 to Ground.
3. Connect the Computer to the Arduino, to provide
power and allow viewing of the data.
4. Upload code to the Arduino, shown here:
#include <Wire.h>
int tmp102Address = 0x48;
void setup() {
// put your setup code here, to
run once:
Serial.begin(9600);
Wire.begin();
#define address 0x1E //0011110b, I2C 7bit address of HMC5883
}
void loop() {
// put your main code here, to
run repeatedly:
int tmp36 = analogRead(A6);
float tempc =
map(tmp36,20,358,-40,125);
float tempf = tempc*1.8+32;
Serial.println(tempf);
delay(1000);
float celsius = getTemperature();
//Serial.print("Celsius:
");
//Serial.println(celsius);
float fahrenheit = (1.8 *
celsius) + 32;
Serial.print("Fahrenheit:
");
Serial.println(fahrenheit);
}
float getTemperature(){
Wire.requestFrom(tmp102Address,2);
byte MSB = Wire.read();
byte LSB = Wire.read();
//it's a 12bit int, using two's
compliment for negative
int TemperatureSum = ((MSB
<< 8) | LSB) >> 4;
float celsius =
TemperatureSum*0.0625;
return celsius;
}
Open Serial monitor to view temperature data from
both the TMP36 and the TMP102.
With the setup complete, we proceeded to test the accuracy
of both sensors, once again using the infrared thermometer. Our procedure to test the sensors was as
follows:
1. Determine the temperature of the TMP102 using
the infrared thermometer, and record it.
2. Record the temperature reported by the TMP36 and
TMP102.
3. Move to a place with a different temperature,
such as outside, without removing power from the setup or resetting the Arduino.
4. After moving to several places, we found the following data:
TMP36
|
||||||
Temperature
|
TMP36 reading
|
Error
|
Adjusted reading
|
New error
|
avg error
|
6.3
|
49.1
|
53.6
|
4.5
|
47.3
|
-1.8
|
var
|
3.24
|
54.5
|
62.6
|
8.1
|
56.3
|
1.8
|
s^2
|
1.8
|
63.5
|
71.6
|
8.1
|
65.3
|
1.8
|
||
52.7
|
57.2
|
4.5
|
50.9
|
-1.8
|
||
63.5
|
69.8
|
6.3
|
63.5
|
0
|
TMP102
|
||||||
Temperature
|
TMP36 reading
|
Error
|
Adjusted reading
|
New error
|
avg error
|
1.618
|
49.1
|
48.09
|
-1.01
|
46.472
|
-2.628
|
var
|
6.54647
|
54.5
|
56.07
|
1.57
|
54.452
|
-0.048
|
s^2
|
2.558607
|
63.5
|
64.62
|
1.12
|
63.002
|
-0.498
|
||
52.7
|
58.55
|
5.85
|
56.932
|
4.232
|
||
63.5
|
64.06
|
0.56
|
62.442
|
-1.058
|
As shown above, after accounting for offset error in our
initial calibration, the TMP36 showed a more accurate standard deviation of 1.8
degrees Fahrenheit compared to the TMP102’s standard deviation of 2.56 degrees
Fahrenheit. Additionally, while the
TMP102 failed to meet its specifications as listed in its data sheet, the TMP36
showed itself to be more accurate than expected. Unfortunately, this test occurred on a
relatively warm day, so testing this setup at lower temperatures was impossible
for the moment.
Written by: David Juenemann
No comments:
Post a Comment