Сбор информации о погодных условиях
Dependencies: RF24 USBDevice mbed
Sensors/Thermistor.cpp
- Committer:
- pro100kot14
- Date:
- 2015-10-28
- Revision:
- 4:7cd67d988145
- Parent:
- Thermistor.cpp@ 2:ad2653bcf93f
- Child:
- 6:db4538895ae7
File content as of revision 4:7cd67d988145:
#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 * 3.3) / 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; }