Introduction
Build a comprehensive building energy monitoring system with CT sensors, power quality analysis, dashboard, and anomaly alerts. This comprehensive guide covers everything from design through implementation, testing, and deployment.
Build a comprehensive building energy monitoring system with CT sensors, power quality analysis, dashboard, and anomaly alerts.
Build a comprehensive building energy monitoring system with CT sensors, power quality analysis, dashboard, and anomaly alerts. This comprehensive guide covers everything from design through implementation, testing, and deployment.
CT (Current Transformer) clamps around a live wire — measures current via electromagnetic induction (no electrical connection to live circuit). SCT-013-030: 30A input → 1V output (through 33Ω burden resistor). Calibrate: compare CT reading with a reference clamp meter on a known load (1kW heater). Calibration factor = reference_current / CT_raw_reading. AC current waveform is sampled at 10kHz by ADC, RMS calculated: I_rms = sqrt(mean(i²)). Sample at least 2 complete cycles (40ms at 50Hz) for accurate RMS.
10 components required for this project.
| # | Component | Purpose | Qty |
|---|---|---|---|
| 1 | Current Transformer (SCT-013-030, 30A) | Non-invasive current measurement | x6 |
| 2 | ZMPT101B Voltage Transformer Module | AC voltage measurement | x2 |
| 3 | Arduino Mega + ADS1115 ADC | High-resolution energy measurement | x1 |
| 4 | Raspberry Pi 4 | Data processing and IoT gateway | x1 |
| 5 | InfluxDB (time-series database) | Energy data storage | x1 |
| 6 | Grafana | Energy dashboard visualization | x1 |
| 7 | Telegram Bot API | Anomaly alerts on phone | x1 |
| 8 | RS-485 + Modbus (for digital meters) | Professional energy meter interfacing | x1 |
| 9 | DIN Rail enclosure | Panel-mounted professional installation | x1 |
| 10 | Circuit breakers (MCB) × 6 | Circuit protection | x6 |
Follow these 4 steps carefully.
CT (Current Transformer) clamps around a live wire — measures current via electromagnetic induction (no electrical connection to live circuit). SCT-013-030: 30A input → 1V output (through 33Ω burden resistor). Calibrate: compare CT reading with a reference clamp meter on a known load (1kW heater). Calibration factor = reference_current / CT_raw_reading. AC current waveform is sampled at 10kHz by ADC, RMS calculated: I_rms = sqrt(mean(i²)). Sample at least 2 complete cycles (40ms at 50Hz) for accurate RMS.
True power (W) = V_rms × I_rms × cos(φ) (power factor). Apparent power (VA) = V_rms × I_rms. Reactive power (VAr) = V_rms × I_rms × sin(φ). Power factor cos(φ): 1.0 = purely resistive (heater), < 1.0 = inductive (motors) or capacitive. Measure instantaneous power: p(t) = v(t) × i(t), integrate over cycle: P = mean(v×i). Compare P with |S| = V_rms × I_rms to get power factor directly without phase measurement. Poor power factor (< 0.8) incurs penalty charges from utilities.
Grafana panels: real-time power per circuit (W), energy today (kWh), power factor, total building power vs time. Derived analytics: load profile (power vs time of day), load duration curve (how long above various power levels), peak demand (maximum 15-minute average power — utility billing basis), standby power (overnight consumption when building unoccupied — target < 2% of peak). Cost calculation: kWh × tariff rate → daily/monthly cost estimate.
Rule-based alerts: circuit load > historical average by 30% → inspect. Overnight consumption > 500W (suspicious — HVAC leak, equipment left on) → alert. Power factor < 0.75 → notify for capacitor bank installation recommendation. Motor startup anomaly: normal startup current = 6× running current for < 3 seconds. If high current persists > 10 seconds → motor stuck or bearing failure. Machine learning anomaly detection: train isolation forest on 30 days of baseline data, alert when new day deviates significantly.
Core code for energy_monitor.ino:
#include <Wire.h> #include <Adafruit_ADS1X15.h> Adafruit_ADS1115 ads; const float CAL_FACTOR = 30.0 / 1.0; // SCT-013-030: 30A per 1V const float VREF = 2.5; // Midpoint voltage (voltage divider) float measureRMS(int channel, int samples = 500) { float sum_sq = 0; for(int i = 0; i < samples; i++) { int16_t raw = ads.readADC_SingleEnded(channel); float voltage = (raw * 0.0001875) - VREF; // ADS1115 resolution: 187.5µV/bit at ±6.144V float current = voltage * CAL_FACTOR; sum_sq += current * current; delayMicroseconds(100); // 10kHz sampling } return sqrt(sum_sq / samples); } float measurePower(int v_channel, int i_channel, int samples = 500) { float sum_p = 0; for(int i = 0; i < samples; i++) { float v = (ads.readADC_SingleEnded(v_channel) * 0.0001875 - VREF) * 230; // Scale to 230V float cur = (ads.readADC_SingleEnded(i_channel) * 0.0001875 - VREF) * CAL_FACTOR; sum_p += v * cur; delayMicroseconds(100); } return sum_p / samples; // True power in Watts } void setup() { Serial.begin(115200); ads.setGain(GAIN_TWOTHIRDS); // ±6.144V range for ADS1115 ads.begin(); } void loop() { float I1 = measureRMS(0); // Circuit 1 current float I2 = measureRMS(1); // Circuit 2 current float P = measurePower(2, 0); // True power (circuit 1) float S = 230 * I1; // Apparent power float PF = abs(P) / S; // Power factor // Transmit as JSON to Raspberry Pi Serial.print("{\"I1\":"); Serial.print(I1, 2); Serial.print(",\"I2\":"); Serial.print(I2, 2); Serial.print(",\"P\":"); Serial.print(P, 1); Serial.print(",\"PF\":"); Serial.print(PF, 3); Serial.println("}"); delay(1000); }
Test Building Energy Monitoring System by verifying each subsystem individually before full integration.
Verify power voltages, check ground connections, use serial monitor for debug.
An interactive simulator will be available here — simulate circuits and run code in-browser without hardware.