first commit
This commit is contained in:
54
include/drivers/ThermistorController.h
Normal file
54
include/drivers/ThermistorController.h
Normal file
@@ -0,0 +1,54 @@
|
||||
#ifndef THERMISTOR_CONTROLLER_H
|
||||
#define THERMISTOR_CONTROLLER_H
|
||||
|
||||
#include <Arduino.h>
|
||||
|
||||
class ThermistorController {
|
||||
private:
|
||||
const int _thermistorPin;
|
||||
const float _seriesResistor;
|
||||
const float _bParameter;
|
||||
const float _nominalTemp;
|
||||
|
||||
static const int _bufferSize = 10;
|
||||
float _rawReadings[_bufferSize];
|
||||
int _bufferIndex;
|
||||
bool _bufferFilled;
|
||||
|
||||
float _filteredRaw;
|
||||
float _smoothedRaw;
|
||||
float _resistance;
|
||||
float _temperatureC;
|
||||
|
||||
const float _weights[_bufferSize] = {0.05, 0.05, 0.05, 0.05, 0.1, 0.1, 0.1, 0.15, 0.15, 0.2};
|
||||
|
||||
const float _minTemp;
|
||||
const float _maxTemp;
|
||||
|
||||
float applySaltPepperFilter();
|
||||
float applyWeightedMovingAverage();
|
||||
float calculateResistance(float adcValue);
|
||||
float calculateTemperature(float resistance);
|
||||
float applySaturation(float value, float min, float max);
|
||||
|
||||
public:
|
||||
ThermistorController(
|
||||
int thermistorPin,
|
||||
float seriesResistor = 10000.0,
|
||||
float bParameter = 3435.0,
|
||||
float nominalTemp = 25.0,
|
||||
float minTemp = -55.0,
|
||||
float maxTemp = 125.0
|
||||
);
|
||||
|
||||
void update();
|
||||
|
||||
float getRawValue() const;
|
||||
float getFilteredRaw() const;
|
||||
float getSmoothedRaw() const;
|
||||
float getResistance() const;
|
||||
float getTemperatureC() const;
|
||||
float getTemperatureF() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user