Humidistat
Arduino firmware for a humidistat (humidity controller)
Loading...
Searching...
No Matches
FlowSensor.h
Go to the documentation of this file.
1#ifndef HUMIDISTAT_FLOWSENSOR_H
2#define HUMIDISTAT_FLOWSENSOR_H
3
4#include <stdint.h>
5
6#include "imath.h"
7
9class FlowSensor {
10private:
11 const uint8_t pin;
13 static constexpr double coeffs[] = {
14 0.094003 * ipow(3.3 / 1023, 5),
15 -0.564312 * ipow(3.3 / 1023, 4),
16 1.374705 * ipow(3.3 / 1023, 3),
17 -1.601495 * ipow(3.3 / 1023, 2),
18 1.060657 / 1023 * 3.3,
19 -0.269996,
20 };
21
22public:
25 explicit FlowSensor(uint8_t pin);
26
29 double readFlowrate() const;
30};
31
32
33#endif //HUMIDISTAT_FLOWSENSOR_H
Read flow rate using a Omron D6F-P0010 MEMS flow sensor.
Definition FlowSensor.h:9
static constexpr double coeffs[]
Coefficients of the polynomial approximation to the sensor response (and voltage mapping)
Definition FlowSensor.h:13
const uint8_t pin
Definition FlowSensor.h:11
FlowSensor(uint8_t pin)
Constructor.
Definition FlowSensor.cpp:6
double readFlowrate() const
Read the flow rate.
Definition FlowSensor.cpp:8
constexpr T ipow(T base, unsigned int pow)
Constexpr function for computing integer power.
Definition imath.h:10