|
@@ -28,6 +28,8 @@
|
28
|
28
|
#include <mraa/aio.h>
|
29
|
29
|
#include <mraa/gpio.h>
|
30
|
30
|
|
|
31
|
+namespace upm {
|
|
32
|
+
|
31
|
33
|
#define NUMBER_OF_SAMPLES 500
|
32
|
34
|
#define ADC_RESOLUTION 1024
|
33
|
35
|
#define SUPPLYVOLTAGE 5100
|
|
@@ -39,59 +41,64 @@
|
39
|
41
|
#define TRUE HIGH
|
40
|
42
|
#define FALSE LOW
|
41
|
43
|
|
42
|
|
-namespace upm {
|
43
|
|
- class ECS1030 {
|
44
|
|
- public:
|
45
|
|
- static const uint8_t DELAY_MS = 20000 / NUMBER_OF_SAMPLES; /* 1/50Hz is 20ms period */
|
46
|
|
- static const uint8_t VOLT_M = 5.1 / 1023;
|
47
|
|
- static const uint8_t R_LOAD = 2000.0 / CURRENT_RATIO;
|
|
44
|
+/**
|
|
45
|
+ * @brief C++ API for ECS1030 (electricity sensor)
|
|
46
|
+ *
|
|
47
|
+ * @snippet ecs1030.cxx Interesting
|
|
48
|
+ */
|
|
49
|
+
|
|
50
|
+class ECS1030 {
|
|
51
|
+ public:
|
|
52
|
+ static const uint8_t DELAY_MS = 20000 / NUMBER_OF_SAMPLES; /* 1/50Hz is 20ms period */
|
|
53
|
+ static const uint8_t VOLT_M = 5.1 / 1023;
|
|
54
|
+ static const uint8_t R_LOAD = 2000.0 / CURRENT_RATIO;
|
48
|
55
|
|
49
|
|
- /**
|
50
|
|
- * Instanciates a ECS1030 (current sensor) object
|
51
|
|
- *
|
52
|
|
- * @param pinNumber number of the data pin
|
53
|
|
- */
|
54
|
|
- ECS1030 (uint8_t pinNumber);
|
|
56
|
+ /**
|
|
57
|
+ * Instanciates a ECS1030 (current sensor) object
|
|
58
|
+ *
|
|
59
|
+ * @param pinNumber number of the data pin
|
|
60
|
+ */
|
|
61
|
+ ECS1030 (uint8_t pinNumber);
|
55
|
62
|
|
56
|
|
- /**
|
57
|
|
- * ECS1030 object destructor, basicaly it close the GPIO.
|
58
|
|
- */
|
59
|
|
- ~ECS1030 ();
|
|
63
|
+ /**
|
|
64
|
+ * ECS1030 object destructor, basicaly it close the GPIO.
|
|
65
|
+ */
|
|
66
|
+ ~ECS1030 ();
|
60
|
67
|
|
61
|
|
- /**
|
62
|
|
- * Return currency data for the sampled period
|
63
|
|
- */
|
64
|
|
- double getCurrency_A ();
|
|
68
|
+ /**
|
|
69
|
+ * Return currency data for the sampled period
|
|
70
|
+ */
|
|
71
|
+ double getCurrency_A ();
|
65
|
72
|
|
66
|
|
- /**
|
67
|
|
- * Return power data for the sampled period
|
68
|
|
- */
|
69
|
|
- double getPower_A ();
|
|
73
|
+ /**
|
|
74
|
+ * Return power data for the sampled period
|
|
75
|
+ */
|
|
76
|
+ double getPower_A ();
|
70
|
77
|
|
71
|
|
- /**
|
72
|
|
- * Return currency data for the sampled period
|
73
|
|
- */
|
74
|
|
- double getCurrency_B ();
|
|
78
|
+ /**
|
|
79
|
+ * Return currency data for the sampled period
|
|
80
|
+ */
|
|
81
|
+ double getCurrency_B ();
|
75
|
82
|
|
76
|
|
- /**
|
77
|
|
- * Return power data for the sampled period
|
78
|
|
- */
|
79
|
|
- double getPower_B ();
|
|
83
|
+ /**
|
|
84
|
+ * Return power data for the sampled period
|
|
85
|
+ */
|
|
86
|
+ double getPower_B ();
|
80
|
87
|
|
81
|
|
- /**
|
82
|
|
- * Return name of the component
|
83
|
|
- */
|
84
|
|
- std::string name() {
|
85
|
|
- return m_name;
|
86
|
|
- }
|
87
|
|
- private:
|
88
|
|
- std::string m_name;
|
89
|
|
- mraa_aio_context m_dataPinCtx;
|
|
88
|
+ /**
|
|
89
|
+ * Return name of the component
|
|
90
|
+ */
|
|
91
|
+ std::string name() {
|
|
92
|
+ return m_name;
|
|
93
|
+ }
|
|
94
|
+ private:
|
|
95
|
+ std::string m_name;
|
|
96
|
+ mraa_aio_context m_dataPinCtx;
|
90
|
97
|
|
91
|
|
- double m_calibration;
|
92
|
|
- int m_lastSample;
|
93
|
|
- double m_lastFilter;
|
94
|
|
- int m_sample;
|
95
|
|
- double m_filteredSample;
|
96
|
|
- };
|
|
98
|
+ double m_calibration;
|
|
99
|
+ int m_lastSample;
|
|
100
|
+ double m_lastFilter;
|
|
101
|
+ int m_sample;
|
|
102
|
+ double m_filteredSample;
|
|
103
|
+};
|
97
|
104
|
}
|