You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
zbElectricalMeasurement.addACMeasurement(ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY, ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC); // frequency is not phase specific (shared)
// Optional: Add reporting for AC measurements (this is overriden by HomeAssistant ZHA if used as a Zigbee coordinator)
103
-
zbElectricalMeasurement.setACReporting(ZIGBEE_AC_MEASUREMENT_TYPE_VOLTAGE, ZIGBEE_AC_PHASE_TYPE_A, 0, 30, 10); // report every 30 seconds if value changes by 10 (0.1V)
104
-
zbElectricalMeasurement.setACReporting(ZIGBEE_AC_MEASUREMENT_TYPE_CURRENT, ZIGBEE_AC_PHASE_TYPE_A, 0, 30, 100); // report every 30 seconds if value changes by 10 (0.1A)
105
-
zbElectricalMeasurement.setACReporting(ZIGBEE_AC_MEASUREMENT_TYPE_POWER, ZIGBEE_AC_PHASE_TYPE_A, 0, 30, 10); // report every 30 seconds if value changes by 10 (1W)
106
-
zbElectricalMeasurement.setACReporting(ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY, ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC, 0, 30, 100); // report every 30 seconds if value changes by 100 (0.1Hz)
); // report every 30 seconds if value changes by 100 (0.1Hz)
107
117
}
108
118
109
119
voidloop() {
110
120
staticuint32_t timeCounter = 0;
111
121
112
122
staticuint8_t randomizer = 0;
113
123
// Read ADC value as current to demonstrate the measurements and update the electrical measurement values every 2s
114
-
if (!(timeCounter++ % 20)) { // delaying for 100ms x 20 = 2s
115
-
uint16_t voltage = 23000 + randomizer; // 230.00 V
116
-
uint16_t current = analogReadMilliVolts(analogPin); // demonstrates 0-3.3A
117
-
int16_t power = ((voltage/100) * (current/1000) * 10); //calculate power in W
118
-
uint16_t frequency = 50135; // 50.000 Hz
124
+
if (!(timeCounter++ % 20)) { // delaying for 100ms x 20 = 2s
125
+
uint16_t voltage = 23000 + randomizer; // 230.00 V
126
+
uint16_t current = analogReadMilliVolts(analogPin); // demonstrates 0-3.3A
127
+
int16_t power = ((voltage / 100) * (current / 1000) * 10);//calculate power in W
128
+
uint16_t frequency = 50135; // 50.000 Hz
119
129
Serial.printf("Updating AC voltage to %d (0.01V), current to %d (mA), power to %d (0.1W), frequency to %d (mHz)\r\n", voltage, current, power, frequency);
Copy file name to clipboardExpand all lines: libraries/Zigbee/examples/Zigbee_Electrical_AC_Sensor_MultiPhase/Zigbee_Electrical_AC_Sensor_MultiPhase.ino
zbElectricalMeasurement.addACMeasurement(ZIGBEE_AC_MEASUREMENT_TYPE_FREQUENCY, ZIGBEE_AC_PHASE_TYPE_NON_SPECIFIC); // frequency is not phase specific (shared)
// Read ADC value and update the analog value every 2s
127
-
if (!(timeCounter++ % 20)) { // delaying for 100ms x 20 = 2s
128
-
uint16_t voltage = 23000 + randomizer; // 230.00 V
129
-
uint16_t current = analogReadMilliVolts(analogPin); // demonstrates approx 0-3.3A
130
-
int16_t power = ((voltage/100) * (current/1000) * 10); //calculate power in W
131
-
uint16_t frequency = 50135; // 50.000 Hz
129
+
if (!(timeCounter++ % 20)) { // delaying for 100ms x 20 = 2s
130
+
uint16_t voltage = 23000 + randomizer; // 230.00 V
131
+
uint16_t current = analogReadMilliVolts(analogPin); // demonstrates approx 0-3.3A
132
+
int16_t power = ((voltage / 100) * (current / 1000) * 10);//calculate power in W
133
+
uint16_t frequency = 50135; // 50.000 Hz
132
134
Serial.printf("Updating AC voltage to %d (0.01V), current to %d (mA), power to %d (0.1W), frequency to %d (mHz)\r\n", voltage, current, power, frequency);
0 commit comments