   // 331.3 m/s plus .606 * current temp in C
   return 331.3 + (0.606 * current_temperature);
 }
+
+float read_thermistor(int RawADC) {
+  long Resistance;  
+  float Temp;  // Dual-Purpose variable to save space.
+
+  Resistance=((1024 * pad / RawADC) - pad); 
+  Temp = log(Resistance); // Saving the Log(resistance) so not to calculate  it 4 times later
+  Temp = 1 / (0.001129148 + (0.000234125 * Temp) + (0.0000000876741 * Temp * Temp * Temp));
+  Temp = Temp - 273.15;  // Convert Kelvin to Celsius                      
+
+  // BEGIN- Remove these lines for the function not to display anything
+  Serial.print("ADC: "); 
+  Serial.print(RawADC); 
+  Serial.print("/1024");                           // Print out RAW ADC Number
+  Serial.print(", vcc: ");
+  Serial.print(vcc,2);
+  Serial.print(", pad: ");
+  Serial.print(pad/1000,3);
+  Serial.print(" Kohms, Volts: "); 
+  Serial.print(((RawADC*vcc)/1024.0),3);   
+  Serial.print(", Resistance: "); 
+  Serial.print(Resistance);
+  Serial.println(" ohms");
+  // END- Remove these lines for the function not to display anything
+
+  // Uncomment this line for the function to return Fahrenheit instead.
+  //temp = (Temp * 9.0)/ 5.0 + 32.0;                  // Convert to Fahrenheit
+  return Temp;
+}

#include <stdio.h>
#include <softwareserial.h>

const int ping_sensor_pin = 7;
const int serial_speed = 9600;
const int poll_interval = 10000;
SoftwareSerial impSerial(8, 9); // RX on 8, TX on 9 for imp

float current_temperature = 22.2222; // in C

  // establish variables for duration of the ping, 
  // and the distance result in inches and centimeters:
  float duration, inches, cm;

  current_temperature = read_thermistor(analogRead(thermistor_pin));
  Serial.print("Current Temp: ");
  Serial.print(current_temperature);
  Serial.println("C");

  // The PING))) is triggered by a HIGH pulse of 2 or more microseconds.
  // Give a short LOW pulse beforehand to ensure a clean HIGH pulse:
