SensESP 3.0.1
Universal Signal K sensor toolkit ESP32
Loading...
Searching...
No Matches
voltagedivider.h
Go to the documentation of this file.
1#ifndef SENSESP_TRANSFORMS_VOLTAGE_DIVIDER_H_
2#define SENSESP_TRANSFORMS_VOLTAGE_DIVIDER_H_
3
4#include "transform.h"
6
7namespace sensesp {
8
34class VoltageDividerR1 : public SymmetricTransform<float> {
35 public:
36 VoltageDividerR1(float R2, float Vin = 3.3, const String& config_path = "");
37
38 virtual void set(const float& Vout) override;
39
40 virtual bool to_json(JsonObject& root) override;
41 virtual bool from_json(const JsonObject& config) override;
42
43 protected:
44 float R2_;
45 float Vin_;
46};
47
48const String ConfigSchema(const VoltageDividerR1& obj);
49
75class VoltageDividerR2 : public SymmetricTransform<float> {
76 public:
77 VoltageDividerR2(float R1, float Vin = 3.3, const String& config_path = "");
78
79 virtual void set(const float& Vout) override;
80
81 // For reading and writing the configuration of this transformation
82 virtual bool to_json(JsonObject& root) override;
83 virtual bool from_json(const JsonObject& config) override;
84
85 protected:
86 float R1_;
87 float Vin_;
88};
89
90const String ConfigSchema(const VoltageDividerR2& obj);
91
92} // namespace sensesp
93#endif
A common type of transform that consumes, transforms, then outputs values of the same data type.
Definition transform.h:94
Uses the voltage divider formula to calculate (and output) the resistance of R1 in the circuit.
virtual bool from_json(const JsonObject &config) override
virtual void set(const float &Vout) override
virtual bool to_json(JsonObject &root) override
VoltageDividerR1(float R2, float Vin=3.3, const String &config_path="")
Uses the voltage divider formula to calculate (and output) the resistance of R2 in the circuit.
virtual bool from_json(const JsonObject &config) override
virtual bool to_json(JsonObject &root) override
VoltageDividerR2(float R1, float Vin=3.3, const String &config_path="")
virtual void set(const float &Vout) override
const String ConfigSchema(const SmartSwitchController &obj)