I am logging temp to a csv file using a python script.
Occasionally I will have extra values, or strange values like this:
normal:
11/05/2012 08:40:31, 72.89,
error:
11/05/2012 08:41:17, 72.8972.2972.2973.48,
(as you can see, there are extra temp readings coming out on the same line as the previous reading.
I am certain the problem lies somewhere in the arduino code:
/* Sensor test sketch
for more information see http://www.ladyada.net/make/logshield/lighttemp.html
*/
#define aref_voltage 3.4 // we tie 3.3V to ARef and measure it with a multimeter!
//TMP36 Pin Variables
int tempPin = 1; //the analog pin the TMP36's Vout (sense) pin is connected to
//the resolution is 10 mV / degree centigrade with a
//500 mV offset to allow for negative temperatures
int tempReading; // the analog reading from the sensor
int led_state;
void setup(void) {
// We'll send debugging information via the Serial monitor
Serial.begin(9600);
pinMode(13, OUTPUT);
Serial.println("Ready");
// If you want to set the aref to something other than 5v
analogReference(EXTERNAL);
}
void loop(void) {
tempReading = analogRead(tempPin);
//Serial.print("Temp reading = ");
//Serial.print(tempReading); // the raw analog reading
// converting that reading to voltage, which is based off the reference voltage
float voltage = tempReading * aref_voltage;
voltage /= 1024.0;
// print out the voltage
//Serial.print(" - ");
//Serial.print(voltage); Serial.println(" volts");
//Serial.print(temperatureC); Serial.println(" degrees C");
// now print out the temperature
float temperatureC = (voltage - 0.5) * 100 ; //converting from 10 mv per degree wit 500 mV offset
//to degrees ((volatge - 500mV) times 100)
// now convert to Fahrenheight
float temperatureF = (temperatureC * 9.0 / 5.0) + 32.0;
Serial.print(temperatureF);
digitalWrite(13,led_state);
led_state=!led_state;
//Serial.println(" degrees F");
delay(2000);
}
Any ideas for how to filter the output, making sure I only get one temp reading per line?