Konstantin Chayka / Mbed 2 deprecated WeatherStation

Dependencies:   RF24 USBDevice mbed

Revision:
1:8766173d267f
Child:
2:ad2653bcf93f
diff -r 1e03d2cd238f -r 8766173d267f Thermistor.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Thermistor.cpp	Mon Oct 19 22:03:12 2015 +0000
@@ -0,0 +1,56 @@
+#include "Thermistor.h"
+
+Thermistor::Thermistor(AnalogIn inputChanel, double a, double b, double c):input(inputChanel), error(0){
+    this->a = a;    
+    this->b = b;
+    this->c = c;
+}
+
+double Thermistor::getTemperature(){
+    double temp;
+    double realV;
+    double resistance;
+        //3.3 - ADC maximum
+    realV = input.read()*3.3;
+    resistance = (10000 * 5.0) / realV - 10000;
+        //Considering the error
+    resistance -= error;
+        //Calculations using Steinhart–Hart equation
+    temp = log(resistance);
+    temp = 1/(a+b*temp+c*temp*temp*temp);
+        //Convert from Fahrenheit to Celsius
+    temp -= 273.15;
+    return temp;
+}
+    
+    void Thermistor::setError(double error){
+        this->error = error;
+    }
+    
+    double Thermistor::getError(){
+        return error;
+    }
+    
+    void Thermistor::setCoefficientA(double a){
+        this->a = a;
+    }
+    
+    void Thermistor::setCoefficientB(double b){
+        this->b = b;
+    }
+
+    void Thermistor::setCoefficientC(double c){
+        this->c = c;
+    }
+    
+    double Thermistor::getCoefficientA(){
+        return a;
+    }
+    
+    double Thermistor::getCoefficientB(){
+        return b;
+    }
+    
+    double Thermistor::getCoefficientC(){
+        return c;
+    }
\ No newline at end of file