Smart Electricity Consumption Monitor with ESP32: Track Daily Energy Usage Automatically
Contents list
- Introduction
- What Is a Smart Daily Electricity Consumption Monitor?
- How the System Works?
- Aggregate Consumption vs. Appliance-Level Monitoring
- Main Components of the System
- Choosing the Electricity Sensor
- Measuring Current with a Current Transformer
- Measuring Power and Energy Consumption
- ESP32 Data Acquisition and Processing
- Wiring Diagram and Circuit Connections
- Programming the ESP32
- Displaying Daily Electricity Consumption
- Daily Energy Calculation and Data Storage
- Detecting Abnormal Electricity Consumption
- Calibration and Measurement Accuracy
- Electrical Safety and Installation Considerations
- Possible Improvements and Future Expansion
- Frequently Asked Questions
- Conclusion
Time reading is 20min.
1. Introduction
Electricity consumption is often difficult to evaluate because the electricity meter normally provides a cumulative reading rather than showing how much energy is being used during different periods of the day.
A simple monitoring system can make this information easier to understand by continuously measuring the electricity consumption of a selected group of appliances and presenting the results on a display.

The Smart Daily Electricity Consumption Monitor with ESP32 is designed for this purpose.
The system measures the combined electrical consumption of the appliances connected to a particular circuit or area, processes the measurements using an ESP32, and displays useful information such as current power and accumulated daily energy consumption.
The important point is that this project is intended for aggregate consumption monitoring.
It does not attempt to determine exactly how much electricity each individual appliance consumes. Instead, it answers a simpler and often more useful question:
How much electricity did this group of appliances consume today, and is that consumption within the expected range?
For example, if a group of appliances normally consumes approximately 8 kWh during a typical day but the monitor records 13 kWh, the user has an indication that something unusual happened. The user can then review which appliances were operating during that day and investigate the reason for the higher consumption.
This approach makes the project suitable for hobbyists and beginners while still providing an interesting practical application for engineers interested in embedded systems, electrical measurement, data processing, and energy monitoring.
2. What Is a Smart Daily Electricity Consumption Monitor?
A smart daily electricity consumption monitor is an electronic system that measures the electrical energy used by a particular circuit or group of appliances over time.
The system typically contains four basic stages: Sensor → ESP32 → Data Processing → Display

The sensor detects an electrical parameter associated with the load, such as current.
The ESP32 receives the sensor signal, converts it into digital data, performs the required calculations, and keeps track of the accumulated energy consumption.
The display can then show information such as:
- Instantaneous power
- Current consumption
- Energy consumed today
- Energy consumed during previous days
- Daily consumption history
- High-consumption warnings
The ESP32 is particularly useful for this type of project because it combines a microcontroller with communication capabilities and analog interfaces. The ESP32 family includes ADC peripherals that can be used to digitize analog sensor signals.
The project can therefore be expanded beyond a simple display into a small energy-monitoring platform capable of recording and analyzing consumption patterns.
3. How the System Works?
The basic operating principle is straightforward.
A sensor is installed on the electrical conductor supplying the appliances that need to be monitored.
The sensor produces a signal related to the electrical current flowing through that conductor.
The ESP32 samples this signal and processes the measurements.
The software can then calculate or estimate electrical power and accumulate the energy consumed over time.

A simplified signal path looks like this:
Electrical Load → Current Sensor → Signal Conditioning → ESP32 ADC → Calculations → Display
For a more advanced system, the measurement path can include both voltage and current:
AC Supply → Voltage Sensor + Current Sensor → ESP32 → Real Power Calculation → Energy Accumulation → Display
The energy value is normally expressed in kilowatt-hours (kWh).
For example, if a load consumes approximately 1 kW continuously for two hours, its energy consumption is approximately:
Energy = Power × Time
Energy = 1 kW × 2 h = 2 kWh
In a real household or workshop, power changes continuously because appliances switch on and off. The ESP32 therefore needs to repeatedly sample the electrical signal and accumulate the energy over time rather than simply taking one measurement.
4. Aggregate Consumption vs. Appliance-Level Monitoring
This distinction is fundamental to the project.
The proposed system measures the combined consumption of the appliances connected to the monitored circuit.

- Refrigerator
- Television
- Computer
- Lighting
- Fans
If all of these loads are supplied through the monitored conductor, the sensor sees their combined current.
The system therefore measures: Total Consumption = Refrigerator + Television + Computer + Lighting + Fans
- It does not automatically know which portion belongs to each appliance.
- This is not a limitation of the project design; it is actually the intended operating principle.
- The objective is to establish a daily baseline and determine whether total consumption is normal.
For example:
| Day | Energy Consumption |
|---|---|
| Monday | 7.8 kWh |
| Tuesday | 8.2 kWh |
| Wednesday | 8.0 kWh |
| Thursday | 8.4 kWh |
| Friday | 13.1 kWh |
The significantly higher value on Friday would provide a reason to investigate what happened that day.
The user could then consider questions such as:
- Was an air conditioner used for a longer period?
- Was a high-power appliance operating?
- Was additional equipment connected?
- Did an appliance remain switched on accidentally?
- Was the increase caused by normal activity?
This makes the monitor a daily energy-awareness and abnormal-consumption detection tool, rather than a device-level energy analyzer.
5. Main Components of the System
A practical implementation can be built from several main components.

ESP32 Development Board
- The ESP32 is the central controller.
- It receives measurement data, performs calculations, stores daily totals, and controls the display.
- The original ESP32 includes ADC hardware capable of digitizing analog signals, with two 12-bit SAR ADCs and multiple analog-capable channels.
- However, the exact ADC characteristics and available pins depend on the particular ESP32 family and board being used, so the appropriate datasheet should always be checked before designing the measurement circuit.
Current Sensor
- A current transformer (CT) is one practical option for measuring AC current without making a direct electrical connection between the sensor and the mains conductor.
- CT sensors are commonly used for whole-building and circuit-level electricity monitoring.
Signal-Conditioning Circuit
The raw sensor signal may not be suitable for direct connection to an ESP32 ADC.
Depending on the sensor type, the circuit may require components such as:
- Burden resistor
- Voltage bias
- Filtering
- Protection
- Signal scaling
The purpose is to produce an analog signal within the safe input range of the ESP32 ADC.
Display
The display provides the user interface.
Possible options include:
- OLED display
- LCD
- TFT display
- Touchscreen display
A small OLED is sufficient for a basic project, while a larger TFT display can present graphs and historical consumption data.
Real-Time Clock or Time Source
If the project needs accurate daily records, it needs a reliable way to determine the current time.
Possible approaches include:
- RTC module
- Network time synchronization using Wi-Fi
- Internal ESP32 timekeeping combined with periodic synchronization
Data Storage
For storing historical daily consumption, the project can use:
- ESP32 flash memory
- EEPROM-style storage
- microSD card
- External database
- Cloud platform
The simplest version can display today’s consumption without permanently storing historical data.
6. Choosing the Electricity Sensor
Sensor selection is one of the most important design decisions.
For AC electricity monitoring, a current transformer (CT) is a practical choice because it can measure current without requiring a direct electrical connection to the conductor being measured.
Open Energy Monitor specifically describes CT sensors as useful for monitoring whole-building electricity consumption and explains that a split-core CT can be placed around a single live or neutral conductor.

When selecting a sensor, consider:
Current Rating
The sensor should be appropriate for the maximum current expected in the monitored circuit.
Using a sensor with a suitable measurement range helps avoid excessive saturation and improves measurement resolution.
Output Type
CT sensors can have different output configurations.
Some produce a current output and require an external burden resistor, while others provide a voltage output with the burden resistor already incorporated.
The interface circuit must therefore be designed specifically for the selected sensor.
Measurement Accuracy
Sensor accuracy matters particularly when the system is expected to detect relatively small changes in daily energy consumption.
Isolation
A properly designed CT provides galvanic isolation between the primary conductor and the secondary measurement circuit.
This is an important advantage for experimental energy-monitoring systems, although isolation does not eliminate the hazards associated with working around mains wiring.
7. Measuring Current with a Current Transformer
A current transformer works according to the transformer principle.
When alternating current flows through the primary conductor, it creates a changing magnetic field.
The CT’s secondary winding produces a smaller current proportional to the primary current.
Conceptually: I (secondary) ∝ I (primary)
The current transformer therefore converts a potentially large mains current into a much smaller measurement signal suitable for an electronic measurement circuit.
However, the CT must be installed correctly.
The sensor should normally be placed around one current-carrying conductor only.

If the CT is placed around both the live and neutral conductors of a single-phase circuit, the magnetic fields produced by the two conductors largely cancel because the currents flow in opposite directions.
Open Energy Monitor specifically warns that the CT should be installed around a single conductor rather than the complete multi-core cable.
A current-output CT also requires appropriate secondary-side circuitry.
In particular, a burden resistor is used to convert the CT secondary current into a measurable voltage.
The burden value must be selected according to the CT characteristics and measurement requirements.
8. Measuring Power and Energy Consumption
Measuring current alone is not exactly the same as measuring real electrical power.
For AC loads, real power depends on both voltage and current as well as their phase relationship.

A simplified relationship is: P = V × I × PF
where:
- P = real power in watts
- V = RMS voltage
- I = RMS current
- PF = power factor
For purely resistive loads, the power factor can be close to 1. However, many modern appliances use electronic power supplies, motors, compressors, or other circuits that can cause the relationship between current and real power to differ.
Open Energy Monitor’s more complete energy-monitoring approach measures both voltage and current and can calculate real power, apparent power, RMS voltage, RMS current, and power factor.
Current-Only Approach
A simpler project can measure current and assume a nominal supply voltage and an estimated power factor.
This reduces hardware complexity but makes the result an approximation.
Open Energy Monitor documents this type of current-only approach and notes that it is simpler but less accurate than measuring voltage as well as current.
Voltage-and-Current Approach
For better measurement accuracy, the system can measure:
- AC voltage
- AC current
- Phase relationship
The ESP32 can then calculate real power continuously.
This is the preferable approach when the objective is to obtain measurements that can be compared more closely with an electricity meter.
From Power to Energy
Once power is known, energy can be accumulated over time.
If the measured power is represented in watts: Energy (Wh) = Power (W) × Time (h)
For continuously changing loads, the software effectively performs repeated accumulation: Energy ≈ Σ Power × Δt
The result can then be converted into kilowatt-hours: Energy (kWh) = Energy (Wh) ÷ 1000
This accumulated value is the main parameter needed for the project’s daily monitoring objective.
9. ESP32 Data Acquisition and Processing
The ESP32 acts as the measurement and processing unit.
Its ADC converts the analog sensor signal into digital values that software can process. Espressif documents the ESP32 ADC as supporting both one-shot and continuous measurement modes, with calibration features available through the ESP-IDF ADC driver.

A simplified software process is:
- Read the sensor signal.
- Remove the signal offset.
- Convert the ADC value into a physical measurement.
- Calculate RMS current or other required parameters.
- Calculate or estimate power.
- Accumulate energy.
- Update the display.
- Save the daily total when required.
- Repeat the process continuously.
The sensor signal should generally be sampled many times rather than relying on a single ADC reading.
This is particularly important for AC measurements because the current waveform changes continuously.
Filtering
Real electrical measurements contain noise.
Software can use techniques such as:
- Averaging
- Digital filtering
- RMS calculations
- Offset removal
- Calibration coefficients
The ESP32 documentation also notes the use of multiple samples and filtering or averaging to improve ADC measurement behavior.
For a beginner project, the important concept is simple:
More carefully processed samples generally provide a more stable measurement than individual raw ADC readings.
10. Wiring Diagram and Circuit Connections
The wiring of the project can be divided into two completely different sides:
Mains measurement side → Current Transformer → Low-voltage measurement circuit → ESP32
The ESP32 should never be connected directly to the AC mains. A current transformer provides an isolated way to sense the current flowing through the monitored conductor, while the low-voltage electronics process the resulting signal.

For the example circuit in this article, the following components are assumed:
| Component | Makers product |
| ESP32 Development Board | Development Board WIFI and Bluetooth 30-Pin with CP2102 Type-C USB |
| Current Transformer | SCT-013 100A/1V Split-Core Current Transformer |
| OLED Display | |
| Isolated 5V Supply | |
| 2 x 10kΩ Resistor | Resistor 10kΩ |
| 10µF Capacitor | Capacitor 10µF / 50V |
| 1µF Coupling Capacitor | Capacitor 1 µF / 50V |
| 18Ω Burden Resistor | Resistor 18Ω |
The exact burden resistor must always be selected according to the specific CT being used. Open Energy Monitor’s example for an SCT-013-000 with a 3.3 V measurement system uses an 18 Ω burden resistor.
Basic Wiring Diagram
AC MAINS
┌──────────────────────────┐
│ │
│ LIVE CONDUCTOR │
│───────────────┐ │
│ │ │
│ [ CT ] │
│ │ │
│───────────────┘ │
│ │ │
│ Monitored Load │
│ │
└──────────────────────────┘
│
│
CT SECONDARY
│
┌───────┴────────┐
│ │
[18 Ω] GND
Burden
│
└───────┬────────
│
1 µF
Coupling Cap
│
├────── GPIO34
│ ESP32 ADC
│
10 kΩ │
│
1.65 V Bias
┌────┴────┐
10 kΩ 10 µF
│ │
GND GND
The CT is installed around one current-carrying conductor, not around both live and neutral conductors together. If both conductors are passed through the same CT, their magnetic effects can largely cancel and the measurement may approach zero.
ESP32 Connections
| Component | Connection |
|---|---|
| CT signal | Through coupling capacitor to GPIO34 |
| CT burden | 18 Ω across CT secondary |
| Bias divider | 10 kΩ + 10 kΩ |
| Bias voltage | Approximately 1.65 V |
| Bias capacitor | 10 µF to GND |
| OLED SDA | GPIO21 |
| OLED SCL | GPIO22 |
| OLED VCC | 3.3 V |
| OLED GND | GND |
| ESP32 ADC | GPIO34 |
GPIO34 is used in this example because it is an ADC-capable input on the original ESP32. Pin availability varies between ESP32 variants, so the board’s documentation should be checked before changing the wiring. Espressif documents the ADC interfaces and notes that ADC channels and characteristics differ between ESP32-family devices.
Creating the ADC Bias
The CT produces an AC waveform that swings both positive and negative.
An ESP32 ADC cannot directly accept a negative voltage, so the AC signal is shifted to approximately the middle of the ADC input range.
A pair of 10 kΩ resistors can create approximately: 3.3 V ÷ 2 = 1.65 V
The AC measurement signal is then coupled to this bias voltage through a capacitor.
This produces a waveform approximately centered around 1.65 V:
ADC Voltage
3.3 V / \ / \
/ \ / \
1.65 V ---/-----\----/-----\---- DC bias
/ \ /
0 V ___/_________\/___________
This type of biased AC interface is a common approach for connecting CT signals to microcontroller ADC inputs. OpenEnergyMonitor describes the same general principle of converting the CT current to a voltage and positioning the resulting AC signal within the ADC input range.
Important CT Safety Connection
If the selected CT is a current-output CT, its secondary must have an appropriate burden connected. A current-output CT should not be left open-circuit while it is installed around a conductor carrying current because the secondary can develop a potentially dangerous voltage.
Voltage-output CTs with an integrated burden are different and should be connected according to their manufacturer’s specifications.
12. Displaying Daily Electricity Consumption
The display should focus on information that is useful to the user rather than presenting unnecessary technical data.

A practical main screen could show:
- Today’s Energy: 8.42 kWh
- Current Power: 620 W
- Current: 2.7 A
- Status: Normal
The display can also provide additional screens for:
- Today’s consumption
- Yesterday’s consumption
- Current power
- Maximum power
- Daily average
- Consumption history
Graphical Display
A TFT display can provide a simple graph showing how consumption changed during the day.
For example:
- 00:00 → Low consumption
- 08:00 → Increased activity
- 13:00 → Moderate consumption
- 18:00 → High consumption
- 23:00 → Low consumption
This is particularly useful because the project is not simply intended to produce a final kWh number. The historical pattern can help the user understand when the consumption increased.
13. Daily Energy Calculation and Data Storage
The monitor should have a clear definition of when a “day” begins and ends.

For example:
- 00:00 → Start new daily record
- 23:59 → Complete daily record
At midnight, the previous day’s accumulated energy can be stored and the daily counter can be reset.
A historical record could contain:
| Date | Energy |
|---|---|
| Day 1 | 7.8 kWh |
| Day 2 | 8.1 kWh |
| Day 3 | 7.9 kWh |
| Day 4 | 8.4 kWh |
| Day 5 | 12.7 kWh |
- This makes it easy to identify unusual days.
- The ESP32’s built-in memory can be used for small amounts of historical data, while an SD card or network-based storage is more appropriate if many months of records are required.
- A Wi-Fi-enabled version can also transmit daily readings to a computer, smartphone interface, or online dashboard.
14. Detecting Abnormal Electricity Consumption
One of the most useful features of this project is the ability to identify unusually high daily consumption.
The simplest approach is to establish a normal baseline.

For example:
Suppose the system records the following typical values: Normal daily range: 7–9 kWh
If the monitor records: 12.5 kWh
The system can display: High Daily Consumption
- The monitor does not need to determine the exact appliance responsible.
- Instead, it tells the user that the total consumption was significantly different from the established pattern.
Possible Detection Methods
- A basic system can use a fixed threshold: If Daily Energy > Threshold → Warning
- A more advanced system can calculate an average from previous days: Average Daily Energy = Sum of Previous Days ÷ Number of Days
- The system can then compare today’s value with that historical baseline.
For example:
- if the typical consumption is around 8 kWh and today’s value is significantly higher, the display can flag the day for investigation.
- The threshold should be chosen carefully because electricity usage naturally changes from day to day. A higher value does not automatically mean there is a fault.
15. Calibration and Measurement Accuracy
- Calibration is essential if the monitor is expected to provide useful numerical measurements.
- The ESP32 ADC converts an analog voltage into a digital value, but the ADC reading alone does not tell the system how much electrical current is flowing.
- The software therefore needs a relationship between: ADC Reading → Sensor Signal → Current → Power → Energy
- Calibration can be performed by comparing the monitor’s measurement against a trusted reference measurement.

For example:
- Connect a known load.
- Measure the load using a trusted meter.
- Record the ESP32 measurement.
- Calculate the correction factor.
- Apply the calibration factor in software.
- Repeat the test with different loads.
Calibration should ideally be performed under several operating conditions rather than only one load.
Sources of Error
Measurement errors can come from several sources:
- CT accuracy
- CT saturation
- Burden resistor tolerance
- ADC limitations
- Electrical noise
- Incorrect signal scaling
- Voltage variation
- Power-factor assumptions
- Phase errors
- Temperature
- Calibration errors
Analog Devices discusses CT-based energy measurement in terms of burden-resistor selection, phase error, sensor selection, and calibration, illustrating why accurate energy measurement involves more than simply reading a current sensor.
For a hobby project, the system can be sufficiently useful without laboratory-grade accuracy, but its limitations should be clearly understood.
16. Electrical Safety and Installation Considerations
This section is extremely important because the project involves electrical mains.
A CT sensor can provide a non-invasive measurement method, but installing it around a mains conductor still involves working near potentially lethal voltages.
A CT should be installed only according to the sensor manufacturer’s instructions.

A current-output CT also presents an important safety consideration: it should not be left open-circuited while installed around a conductor carrying current, unless the particular CT is specifically designed and protected against this condition.
Open Energy Monitor warns that an unburdened current-output CT can generate a potentially dangerous voltage at its secondary terminals.
The measurement circuit connected to the ESP32 must also be designed so that the voltage presented to the ADC remains within the appropriate input limits.
For a hobbyist project, the safest approach is generally to use:
- A properly rated CT sensor
- A purpose-designed isolated measurement module where appropriate
- Proper enclosure and insulation
- Correctly rated components
- A low-voltage isolated power supply for the electronics
Any installation involving mains wiring should be performed or checked by a suitably qualified person. The ESP32 and its low-voltage electronics should never be treated as a substitute for proper mains protection and installation practices.
17. Possible Improvements and Future Expansion
Once the basic daily monitor is working, the project can be expanded considerably.

Wi-Fi Monitoring
- Because ESP32 provides Wi-Fi connectivity, measurements can be transmitted to a local network or online dashboard.
- This allows the user to view consumption without being physically next to the display.
Historical Graphs
The system can store several days or months of data and generate graphs showing:
- Daily energy
- Weekly energy
- Monthly energy
- Peak power
- Average power
Automatic Alerts
The ESP32 can generate an alert when consumption exceeds a predefined threshold.
For example: Today’s consumption has exceeded the expected daily limit.
Multiple Monitoring Channels
Several CT sensors can be used to monitor different circuits separately.
For example:
- Lighting circuit
- Office circuit
- Workshop circuit
- Air-conditioning circuit
This moves the project closer to circuit-level energy monitoring while still being different from true appliance-level identification.
More Accurate Energy Measurement
- A more advanced design can use dedicated energy-metering hardware instead of relying entirely on the ESP32 ADC.
- This can improve measurement accuracy and simplify some of the electrical measurement calculations.
Data Logging
Long-term data logging allows the user to identify patterns such as:
- Increasing monthly consumption
- Weekend versus weekday differences
- Seasonal changes
- Unusually high days
- Changes after replacing an appliance
This transforms the project from a simple display into a useful energy-monitoring and analysis system.
18. Frequently Asked Questions
Can this project measure the electricity used by each appliance?
- No. In its basic configuration, the system measures the combined consumption of all appliances connected to the monitored circuit.
- It can show that total consumption increased, but it cannot automatically determine that a particular refrigerator, television, or computer was responsible for the increase.
What is the main purpose of this project?
The primary purpose is to monitor total daily electricity consumption and determine whether the amount of energy used during the day is within the expected range.
Can I use a CT sensor with an ESP32?
Yes. A CT can provide an analog measurement signal that can be conditioned and read by the ESP32 ADC. The exact interface depends on the CT type and its output configuration.
Is measuring current enough to calculate electricity consumption?
- It can provide an estimate when a nominal voltage and appropriate assumptions are used, but it is less accurate than measuring voltage and current together.
- For accurate real-power measurement, voltage, current, and their phase relationship should be considered.
What does kWh mean?
A kilowatt-hour is a unit of energy. It represents the amount of energy consumed when a load with a power of 1 kilowatt operates for one hour.
Why should the sensor be installed around only one conductor?
- For a single-phase circuit, the current in the live and neutral conductors flows in opposite directions.
- If both conductors pass through the same CT, their magnetic effects can cancel, resulting in little or no useful measurement signal.
Can the ESP32 detect unusually high consumption?
Yes. The software can compare the accumulated daily energy with a predefined threshold or with historical daily averages and display a warning when consumption is unusually high.
Does a high daily consumption value prove that an appliance is faulty?
No. It only indicates that the total measured consumption was higher than expected. The user still needs to investigate which appliances were operating and determine the reason.
Can the project store previous days’ consumption?
Yes. Daily values can be stored in local memory, an SD card, or an external database, depending on how much historical data is required.
Can the system work without Wi-Fi?
Yes. Wi-Fi is not required for the basic measurement function. The ESP32 can measure, calculate, store, and display data locally.
Is this project suitable for beginners?
- Yes, if the project is divided into stages.
- Beginners can start with sensor reading and display functions before adding energy calculations, data logging, calibration, and abnormal-consumption detection.
19. Conclusion
The Smart Daily Electricity Consumption Monitor with ESP32 is a practical embedded-system project for monitoring the total electricity consumption of a selected group of appliances.
Its main objective is not to identify the energy consumption of every individual appliance. Instead, it continuously monitors the aggregate electrical consumption, calculates the accumulated energy used during the day, and presents the information in an understandable form.
This approach provides a simple way to establish a normal daily consumption pattern. If the measured energy is significantly higher than expected, the user can investigate which appliances were operating during that period and determine what caused the increase.
A basic implementation can use an ESP32, a suitable AC current sensor such as a CT, signal-conditioning circuitry, and a display. A more advanced implementation can add voltage measurement, real-power calculation, calibration, data logging, Wi-Fi connectivity, historical graphs, and automatic alerts.
For beginners, the project provides an accessible introduction to sensors, ADCs, embedded programming, electrical measurements, and data processing. For engineers and advanced hobbyists, it provides a foundation that can be extended into a more sophisticated energy-monitoring platform.
The most important design principle is to match the measurement method to the project’s objective: if the goal is to understand total daily electricity usage and identify unusual consumption, aggregate monitoring is sufficient; individual appliance measurement is not required.
نظام مراقبة استهلاك الكهرباء الذكي باستخدام ESP32: تتبع استهلاك الطاقة اليومي تلقائيًا
قائمة المحتويات
- مقدمة.
- ما هو نظام المراقبة الذكي لاستهلاك الكهرباء اليومي؟
- كيف يعمل النظام؟
- مقارنة الاستهلاك الإجمالي بمراقبة استهلاك الأجهزة بشكل منفصل.
- المكونات الرئيسية للنظام.
- اختيار مستشعر قياس الكهرباء.
- قياس التيار باستخدام محول التيار CT.
- قياس القدرة واستهلاك الطاقة.
- جمع البيانات ومعالجتها باستخدام ESP32.
- مخطط التوصيل والتوصيلات الكهربائية.
- برمجة ESP32.
- عرض استهلاك الكهرباء اليومي.
- حساب الطاقة اليومية وتخزين البيانات.
- اكتشاف الاستهلاك غير المعتاد للكهرباء.
- المعايرة ودقة القياس.
- اعتبارات السلامة الكهربائية والتركيب.
- التحسينات المحتملة والتوسعات المستقبلية.
- الأسئلة الشائعة.
- الخاتمة.
مدة القراءة: 20 دقيقة.
1. المقدمة
غالبًا ما يكون من الصعب تقييم استهلاك الكهرباء، لأن عداد الكهرباء يعرض عادةً قراءة تراكمية، بدلًا من توضيح كمية الطاقة التي يتم استخدامها خلال الفترات المختلفة من اليوم.
يمكن لنظام مراقبة بسيط أن يجعل هذه المعلومات أسهل في الفهم، وذلك من خلال قياس استهلاك الكهرباء بشكل مستمر لمجموعة محددة من الأجهزة وعرض النتائج على شاشة.

تم تصميم مراقب ذكي لاستهلاك الكهرباء اليومي باستخدام ESP32 لهذا الغرض.
يقيس النظام الاستهلاك الكهربائي المشترك للأجهزة المتصلة بدائرة كهربائية أو منطقة محددة، ثم يعالج القياسات باستخدام ESP32 ويعرض معلومات مفيدة مثل القدرة الحالية والطاقة المتراكمة المستهلكة خلال اليوم.
النقطة المهمة هي أن هذا المشروع مخصص لمراقبة الاستهلاك الإجمالي.
فهو لا يحاول تحديد كمية الكهرباء التي يستهلكها كل جهاز على حدة. بل يجيب عن سؤال أبسط وغالبًا ما يكون أكثر فائدة:
كمية الكهرباء التي استهلكتها هذه المجموعة من الأجهزة اليوم، وهل هذا الاستهلاك يقع ضمن النطاق المتوقع؟
على سبيل المثال، إذا كانت مجموعة من الأجهزة تستهلك عادةً نحو 8 كيلوواط ساعة خلال اليوم، بينما سجل جهاز المراقبة 13 كيلوواط ساعة، فهذا يعطي المستخدم مؤشرًا على حدوث شيء غير معتاد. ويمكن للمستخدم بعد ذلك مراجعة الأجهزة التي كانت تعمل خلال ذلك اليوم والتحقق من سبب ارتفاع الاستهلاك.
يجعل هذا الأسلوب المشروع مناسبًا للهواة والمبتدئين، مع توفير تطبيق عملي ومفيد للمهندسين المهتمين بالأنظمة المضمنة، والقياسات الكهربائية، ومعالجة البيانات، ومراقبة الطاقة.
2. ما هو مراقب ذكي لاستهلاك الكهرباء اليومي؟
مراقب استهلاك الكهرباء اليومي الذكي هو نظام إلكتروني يقيس الطاقة الكهربائية المستخدمة بواسطة دائرة كهربائية أو مجموعة من الأجهزة خلال فترة زمنية.
يتكون النظام عادةً من أربع مراحل أساسية: المستشعر ← ESP32 ← معالجة البيانات ← الشاشة

يكتشف المستشعر أحد المعلمات الكهربائية المرتبطة بالحمل، مثل التيار.
يستقبل ESP32 إشارة المستشعر، ويحولها إلى بيانات رقمية، وينفذ العمليات الحسابية المطلوبة، ويتابع الطاقة الكهربائية المتراكمة المستهلكة.
يمكن للشاشة بعد ذلك عرض معلومات مثل:
- القدرة اللحظية
- الاستهلاك الحالي
- الطاقة المستهلكة اليوم
- الطاقة المستهلكة خلال الأيام السابقة
- سجل الاستهلاك اليومي
- تنبيهات ارتفاع الاستهلاك
يعد ESP32 مناسبًا بشكل خاص لهذا النوع من المشاريع لأنه يجمع بين المتحكم الدقيق وإمكانات الاتصال والواجهات التناظرية. وتحتوي عائلة ESP32 على محولات ADC يمكن استخدامها لتحويل إشارات المستشعرات التناظرية إلى بيانات رقمية.
وبذلك يمكن توسيع المشروع من مجرد شاشة عرض بسيطة إلى منصة صغيرة لمراقبة الطاقة، قادرة على تسجيل أنماط الاستهلاك وتحليلها.
3. كيف يعمل النظام؟
مبدأ التشغيل الأساسي بسيط ومباشر.
يتم تركيب مستشعر على الموصل الكهربائي الذي يغذي الأجهزة المطلوب مراقبتها.
ينتج المستشعر إشارة مرتبطة بالتيار الكهربائي المار عبر ذلك الموصل.
يقوم ESP32 بأخذ عينات من هذه الإشارة ومعالجة القياسات.
يمكن للبرنامج بعد ذلك حساب أو تقدير القدرة الكهربائية وتجميع الطاقة المستهلكة مع مرور الوقت.

يمكن تمثيل مسار الإشارة بشكل مبسط كما يلي:
الحمل الكهربائي ← مستشعر التيار ← تهيئة الإشارة ← مدخل ADC في ESP32 ← الحسابات ← الشاشة
في نظام أكثر تقدمًا، يمكن أن يتضمن مسار القياس كلًا من الجهد والتيار:
مصدر التيار المتردد ← مستشعر الجهد + مستشعر التيار ← ESP32 ← حساب القدرة الفعلية ← تجميع الطاقة ← الشاشة
يتم التعبير عن قيمة الطاقة عادةً بوحدة كيلوواط ساعة (kWh).
على سبيل المثال، إذا كان الحمل يستهلك قدرة تقارب 1 كيلوواط بشكل مستمر لمدة ساعتين، فإن استهلاكه من الطاقة يكون تقريبًا:
الطاقة = القدرة × الزمن
الطاقة = 1 كيلوواط × 2 ساعة = 2 كيلوواط ساعة
في المنزل أو ورشة العمل الحقيقية، تتغير القدرة باستمرار لأن الأجهزة يتم تشغيلها وإيقافها. لذلك يحتاج ESP32 إلى أخذ عينات متكررة من الإشارة الكهربائية وتجميع الطاقة مع مرور الوقت، بدلًا من الاعتماد على قياس واحد فقط.
4. الاستهلاك الإجمالي مقابل مراقبة استهلاك كل جهاز
يعد هذا الفرق أساسيًا في هذا المشروع.
يقيس النظام المقترح الاستهلاك المشترك للأجهزة المتصلة بالدائرة الكهربائية التي تتم مراقبتها.

لنفترض أن الدائرة التي تتم مراقبتها تحتوي على:
- ثلاجة
- تلفزيون
- حاسوب
- إضاءة
- مراوح
إذا كانت جميع هذه الأحمال تحصل على الطاقة من خلال الموصل الذي تتم مراقبته، فإن المستشعر يكتشف التيار المشترك بينها.
وبالتالي يقيس النظام: الاستهلاك الإجمالي = الثلاجة + التلفزيون + الحاسوب + الإضاءة + المراوح
- لا يعرف النظام تلقائيًا الجزء الخاص بكل جهاز على حدة.
- هذا ليس قصورًا في تصميم المشروع، بل هو مبدأ التشغيل المقصود.
- الهدف هو إنشاء خط أساس يومي وتحديد ما إذا كان الاستهلاك الإجمالي طبيعيًا.
على سبيل المثال:
| اليوم | استهلاك الطاقة |
|---|---|
| الاثنين | 7.8 كيلوواط ساعة |
| الثلاثاء | 8.2 كيلوواط ساعة |
| الأربعاء | 8.0 كيلوواط ساعة |
| الخميس | 8.4 كيلوواط ساعة |
| الجمعة | 13.1 كيلوواط ساعة |
ستوفر القيمة المرتفعة بشكل ملحوظ يوم الجمعة سببًا للتحقق مما حدث في ذلك اليوم.
يمكن للمستخدم بعد ذلك التفكير في أسئلة مثل:
- هل تم استخدام مكيف الهواء لفترة أطول؟
- هل كان هناك جهاز عالي القدرة يعمل؟
- هل تمت إضافة معدات أخرى إلى الدائرة؟
- هل تُرك أحد الأجهزة قيد التشغيل عن طريق الخطأ؟
- هل حدثت الزيادة بسبب نشاط طبيعي في ذلك اليوم؟
وهذا يجعل جهاز المراقبة أداة لزيادة الوعي باستهلاك الطاقة واكتشاف الاستهلاك غير المعتاد، وليس محللًا لاستهلاك كل جهاز على حدة.
5. المكونات الرئيسية للنظام
يمكن تنفيذ نظام عملي باستخدام مجموعة من المكونات الرئيسية.

لوحة تطوير ESP32
- يُعد ESP32 وحدة التحكم الرئيسية في النظام.
- يستقبل بيانات القياس، ويجري الحسابات، ويخزن القيم اليومية، ويتحكم في الشاشة.
- تحتوي عائلة ESP32 الأصلية على وحدات ADC قادرة على تحويل الإشارات التناظرية إلى بيانات رقمية، مع وجود وحدتي SAR ADC بدقة 12 بت وعدة قنوات يمكن استخدامها للإشارات التناظرية.
- ومع ذلك، تعتمد خصائص ADC الدقيقة وعدد الأطراف المتاحة على عائلة ESP32 واللوحة المستخدمة تحديدًا، لذلك يجب دائمًا الرجوع إلى ورقة البيانات المناسبة قبل تصميم دائرة القياس.
مستشعر التيار
- يُعد محول التيار (CT) أحد الخيارات العملية لقياس تيار التيار المتردد دون إجراء توصيل كهربائي مباشر بين المستشعر وموصل التيار الكهربائي الرئيسي.
- تُستخدم مستشعرات CT بشكل شائع لمراقبة استهلاك الكهرباء على مستوى المبنى بالكامل أو على مستوى دائرة كهربائية محددة.
دائرة تهيئة الإشارة
قد لا تكون إشارة المستشعر الخام مناسبة للتوصيل مباشرةً بمدخل ADC في ESP32.
وبحسب نوع المستشعر، قد تتطلب الدائرة مكونات مثل:
- مقاومة الحمل (Burden Resistor)
- انحياز الجهد
- الترشيح
- الحماية
- تحجيم الإشارة
والهدف من ذلك هو إنتاج إشارة تناظرية تقع ضمن نطاق الإدخال الآمن لوحدة ADC في ESP32.
الشاشة
توفر الشاشة واجهة الاستخدام للمستخدم.
وتشمل الخيارات الممكنة:
- شاشة OLED
- شاشة LCD
- شاشة TFT
- شاشة تعمل باللمس
تكون شاشة OLED صغيرة كافية للمشروع الأساسي، بينما يمكن لشاشة TFT أكبر عرض الرسوم البيانية وبيانات الاستهلاك السابقة.
ساعة الوقت الحقيقي أو مصدر الوقت
إذا كان المشروع يحتاج إلى سجلات يومية دقيقة، فإنه يحتاج إلى طريقة موثوقة لتحديد الوقت الحالي.
وتشمل الطرق الممكنة:
- وحدة RTC
- مزامنة الوقت عبر الشبكة باستخدام Wi-Fi
- الاعتماد على حفظ الوقت داخليًا في ESP32 مع إجراء مزامنة دورية
تخزين البيانات
لتخزين بيانات الاستهلاك اليومية السابقة، يمكن للمشروع استخدام:
- ذاكرة Flash في ESP32
- تخزين من نوع EEPROM
- بطاقة microSD
- قاعدة بيانات خارجية
- منصة سحابية
يمكن للإصدار الأبسط من المشروع عرض استهلاك اليوم الحالي دون تخزين البيانات السابقة بشكل دائم.
6. اختيار مستشعر الكهرباء المناسب
يُعد اختيار المستشعر من أهم القرارات عند تصميم النظام.
بالنسبة إلى مراقبة الكهرباء ذات التيار المتردد، يُعد محول التيار (CT) خيارًا عمليًا، لأنه يستطيع قياس التيار دون الحاجة إلى إجراء توصيل كهربائي مباشر بالموصل الذي يتم قياس التيار من خلاله.
وتوضح Open Energy Monitor أن مستشعرات CT مناسبة لمراقبة استهلاك الكهرباء على مستوى المبنى بالكامل، كما توضح إمكانية وضع مستشعر CT ذي القلب المنفصل حول موصل حي واحد أو موصل محايد واحد.

تصنيف التيار
يجب أن يكون المستشعر مناسبًا لأقصى تيار متوقع في الدائرة التي تتم مراقبتها.
ويساعد استخدام مستشعر ذي نطاق قياس مناسب على تجنب التشبع الزائد وتحسين دقة القياس.
نوع الخرج
يمكن أن تكون لمستشعرات CT تكوينات مختلفة للخرج.
فبعضها ينتج خرجًا على شكل تيار ويحتاج إلى مقاومة حمل خارجية، بينما يوفر بعضها الآخر خرجًا على شكل جهد مع وجود مقاومة الحمل مدمجة بالفعل.
لذلك يجب تصميم دائرة الواجهة بما يتوافق تحديدًا مع نوع المستشعر المختار.
دقة القياس
تكون دقة المستشعر مهمة بشكل خاص عندما يُتوقع من النظام اكتشاف تغيرات صغيرة نسبيًا في استهلاك الطاقة اليومي.
العزل
يوفر CT المصمم بشكل صحيح عزلًا كهربائيًا بين الموصل الأساسي ودائرة القياس الثانوية.
وتُعد هذه ميزة مهمة في أنظمة مراقبة الطاقة التجريبية، إلا أن وجود العزل لا يلغي المخاطر المرتبطة بالعمل بالقرب من أسلاك التيار الكهربائي الرئيسي.
7. قياس التيار باستخدام محول التيار
يعمل محول التيار وفق مبدأ عمل المحول الكهربائي.
عندما يمر تيار متردد في الموصل الأساسي، فإنه يولد مجالًا مغناطيسيًا متغيرًا.
وينتج الملف الثانوي في CT تيارًا أصغر يتناسب مع تيار الموصل الأساسي.
ومن الناحية المفاهيمية: I (الثانوي) ∝ I (الأساسي)
لذلك يحول محول التيار تيارًا رئيسيًا قد تكون قيمته كبيرة إلى إشارة قياس أصغر، بحيث تصبح مناسبة لدائرة القياس الإلكترونية.
ومع ذلك، يجب تركيب CT بطريقة صحيحة.
يجب عادةً وضع المستشعر حول موصل واحد فقط يحمل التيار.

إذا تم وضع CT حول كل من موصلي الفاز والمحايد في دائرة أحادية الطور، فإن المجالات المغناطيسية الناتجة عن الموصلين تتلاشى إلى حد كبير لأن التيارات تسري في اتجاهين متعاكسين.
وتحذر Open Energy Monitor تحديدًا من تركيب CT حول موصل واحد فقط بدلًا من وضعه حول الكابل متعدد النوى بالكامل.
كما يحتاج CT ذو الخرج التياري إلى دائرة مناسبة في الجانب الثانوي.
وعلى وجه الخصوص، تُستخدم مقاومة الحمل لتحويل تيار الملف الثانوي في CT إلى جهد يمكن قياسه.
ويجب اختيار قيمة مقاومة الحمل وفقًا لخصائص CT ومتطلبات القياس.
8. قياس القدرة واستهلاك الطاقة
إن قياس التيار وحده لا يعادل تمامًا قياس القدرة الكهربائية الفعلية.
ففي أحمال التيار المتردد، تعتمد القدرة الفعلية على الجهد والتيار بالإضافة إلى العلاقة الطورية بينهما.

العلاقة المبسطة هي: P = V × I × PF
- P = القدرة الفعلية بالواط
- V = جهد RMS
- I = تيار RMS
- PF = معامل القدرة
بالنسبة إلى الأحمال المقاومة البحتة، يمكن أن يكون معامل القدرة قريبًا من 1. ولكن العديد من الأجهزة الحديثة تستخدم مصادر تغذية إلكترونية أو محركات أو ضواغط أو دوائر أخرى يمكن أن تجعل العلاقة بين التيار والقدرة الفعلية مختلفة.
وتوضح Open Energy Monitor أن منهجية أكثر اكتمالًا لمراقبة الطاقة تقيس كلًا من الجهد والتيار، ويمكنها حساب القدرة الفعلية، والقدرة الظاهرية، وجهد RMS، وتيار RMS، ومعامل القدرة.
طريقة القياس بالاعتماد على التيار فقط
يمكن لمشروع أبسط قياس التيار وافتراض جهد تغذية اسمي ومعامل قدرة تقديري.
يؤدي ذلك إلى تقليل تعقيد الأجهزة، لكنه يجعل النتيجة تقريبية.
وتوثق Open Energy Monitor هذا النوع من القياس المعتمد على التيار فقط، وتوضح أنه أبسط لكنه أقل دقة من قياس الجهد والتيار معًا.
طريقة القياس بالاعتماد على الجهد والتيار
للحصول على دقة قياس أفضل، يمكن للنظام قياس:
- جهد التيار المتردد
- تيار التيار المتردد
- العلاقة الطورية بين الجهد والتيار
وبعد ذلك يستطيع ESP32 حساب القدرة الفعلية بشكل مستمر.
وتُعد هذه الطريقة الأنسب عندما يكون الهدف هو الحصول على قياسات يمكن مقارنتها بدرجة أكبر مع قراءة عداد الكهرباء.
من القدرة إلى الطاقة
بمجرد معرفة القدرة، يمكن تجميع الطاقة مع مرور الوقت.
إذا تم التعبير عن القدرة المقاسة بالواط: الطاقة (Wh) = القدرة (W) × الزمن (h)
وبالنسبة إلى الأحمال التي تتغير قدرتها باستمرار، ينفذ البرنامج عمليًا عملية تجميع متكررة:
الطاقة ≈ Σ القدرة × Δt
ويمكن بعد ذلك تحويل القيمة إلى كيلوواط ساعة:
الطاقة (kWh) = الطاقة (Wh) ÷ 1000
وتُعد هذه القيمة المتراكمة هي المعامل الرئيسي المطلوب لتحقيق هدف المشروع في مراقبة الاستهلاك اليومي.
9. جمع البيانات ومعالجتها باستخدام ESP32
يعمل ESP32 كوحدة القياس والمعالجة في النظام.
تقوم وحدة ADC بتحويل إشارة المستشعر التناظرية إلى قيم رقمية يمكن للبرنامج معالجتها. وتوضح Espressif أن ADC في ESP32 يدعم كلاً من وضعي القياس لمرة واحدة والقياس المستمر، مع توفر إمكانات المعايرة من خلال مشغل ADC في بيئة ESP-IDF.

يمكن تبسيط عملية معالجة البيانات برمجيًا كما يلي:
- قراءة إشارة المستشعر.
- إزالة إزاحة الإشارة.
- تحويل قيمة ADC إلى قيمة فيزيائية قابلة للقياس.
- حساب تيار RMS أو المعاملات الأخرى المطلوبة.
- حساب القدرة أو تقديرها.
- تجميع الطاقة المستهلكة.
- تحديث بيانات الشاشة.
- حفظ الإجمالي اليومي عند الحاجة.
- تكرار العملية بشكل مستمر.
يجب عمومًا أخذ عدد كبير من عينات إشارة المستشعر بدلًا من الاعتماد على قراءة ADC واحدة فقط.
ويكتسب ذلك أهمية خاصة عند قياس إشارات التيار المتردد، لأن شكل موجة التيار يتغير باستمرار.
الترشيح
تحتوي القياسات الكهربائية الحقيقية على قدر من الضوضاء.
ويمكن للبرنامج استخدام تقنيات مثل:
- أخذ المتوسط
- الترشيح الرقمي
- حساب RMS
- إزالة الإزاحة
- معاملات المعايرة
كما تشير وثائق ESP32 إلى إمكانية استخدام عينات متعددة وتقنيات الترشيح أو أخذ المتوسط لتحسين سلوك قياسات ADC.
وبالنسبة إلى مشروع للمبتدئين، يمكن تبسيط الفكرة كالتالي:
بوجه عام، تؤدي معالجة عدد أكبر من العينات بعناية إلى قياس أكثر استقرارًا مقارنةً بالاعتماد على قراءات ADC الخام الفردية.
10. مخطط التوصيل وتوصيلات الدائرة
يمكن تقسيم توصيلات المشروع إلى جانبين مختلفين تمامًا:
جانب قياس التيار الرئيسي → محول التيار → دائرة قياس الجهد المنخفض → ESP32
يجب عدم توصيل ESP32 مباشرةً بشبكة التيار المتردد الرئيسية بأي حال من الأحوال. يوفر محول التيار طريقة معزولة لاستشعار التيار المار في الموصل الذي تتم مراقبته، بينما تقوم الدوائر الإلكترونية منخفضة الجهد بمعالجة الإشارة الناتجة.

في الدائرة التوضيحية المستخدمة في هذا المقال، تم افتراض استخدام المكونات التالية:
| المكون | منتج Makers Electronics |
|---|---|
| لوحة تطوير ESP32 | Development Board WIFI and Bluetooth 30-Pin with CP2102 Type-C USB |
| محول التيار | SCT-013 100A/1V Split-Core Current Transformer |
| شاشة OLED | OLED Display I2C 4 Pin 0.96″ – White Characters |
| مزود طاقة معزول 5V | AC/DC Step Down Transformer Power Supply Module 5V 700mA 3W |
| 2 × مقاومة 10kΩ | Resistor 10kΩ |
| مكثف 10µF | Capacitor 10µF / 50V |
| مكثف اقتران 1µF | Capacitor 1 µF / 50V |
| مقاومة حمل 18Ω | Resistor 18Ω |
يجب دائمًا اختيار قيمة مقاومة الحمل المناسبة وفقًا لنوع CT المستخدم تحديدًا. ويستخدم المثال الذي تقدمه Open Energy Monitor مع SCT-013-000 ونظام قياس بجهد 3.3V مقاومة حمل بقيمة 18Ω.
مخطط التوصيل الأساسي
AC MAINS
┌──────────────────────────┐
│ │
│ LIVE CONDUCTOR │
│───────────────┐ │
│ │ │
│ [ CT ] │
│ │ │
│───────────────┘ │
│ │ │
│ Monitored Load │
│ │
└──────────────────────────┘
│
│
CT SECONDARY
│
┌───────┴────────┐
│ │
[18 Ω] GND
Burden
│
└───────┬────────
│
1 µF
Coupling Cap
│
├────── GPIO34
│ ESP32 ADC
│
10 kΩ │
│
1.65 V Bias
┌────┴────┐
10 kΩ 10 µF
│ │
GND GND
يتم تركيب CT حول موصل واحد فقط يحمل التيار، وليس حول موصلي الفاز والمحايد معًا. فإذا مر الموصلان معًا داخل CT نفسه، فقد تتلاشى تأثيراتهما المغناطيسية إلى حد كبير، وقد تقترب نتيجة القياس من الصفر.
توصيلات ESP32
| المكون | التوصيل |
|---|---|
| إشارة CT | عبر مكثف الاقتران إلى GPIO34 |
| مقاومة حمل CT | 18Ω على طرفي الملف الثانوي لـ CT |
| مقسم الانحياز | 10 kΩ + 10 kΩ |
| جهد الانحياز | حوالي 1.65V |
| مكثف الانحياز | 10µF إلى GND |
| OLED SDA | GPIO21 |
| OLED SCL | GPIO22 |
| OLED VCC | 3.3V |
| OLED GND | GND |
| مدخل ADC في ESP32 | GPIO34 |
تم استخدام GPIO34 في هذا المثال لأنه مدخل يدعم ADC في ESP32 الأصلي. ويختلف توفر الأطراف بين إصدارات ESP32 المختلفة، لذلك يجب الرجوع إلى وثائق اللوحة قبل تغيير التوصيلات. كما توضح Espressif أن واجهات ADC وخصائصها تختلف بين الأجهزة التابعة لعائلة ESP32.
إنشاء انحياز لمدخل ADC
ينتج CT شكل موجة مترددًا يتأرجح في الاتجاهين الموجب والسالب.
لا يستطيع ADC في ESP32 استقبال جهد سالب مباشرةً، لذلك يتم إزاحة إشارة التيار المتردد إلى ما يقارب منتصف نطاق دخل ADC.
يمكن لمقاومتين بقيمة 10 kΩ إنشاء جهد يقارب:
3.3 V ÷ 2 = 1.65 V
بعد ذلك يتم ربط إشارة القياس المترددة بجهد الانحياز من خلال مكثف.
وينتج عن ذلك شكل موجة يتمركز تقريبًا حول 1.65V:
ADC Voltage
3.3 V / \ / \
/ \ / \
1.65 V ---/-----\----/-----\---- DC bias
/ \ /
0 V ___/_________\/___________
يُعد هذا النوع من واجهات التيار المتردد المنحازة أسلوبًا شائعًا لتوصيل إشارات CT بمدخل ADC في المتحكمات الدقيقة. وتوضح OpenEnergyMonitor المبدأ العام نفسه، حيث يتم تحويل تيار CT إلى جهد ثم وضع إشارة التيار المتردد الناتجة ضمن نطاق دخل ADC.
توصيل CT وملاحظات السلامة المهمة
إذا كان CT المستخدم من نوع خرج التيار، فيجب توصيل مقاومة حمل مناسبة بالملف الثانوي. ولا ينبغي ترك CT ذي خرج التيار في حالة دائرة مفتوحة أثناء تركيبه حول موصل يمر فيه تيار، لأن الملف الثانوي قد يولد جهدًا مرتفعًا قد يكون خطرًا.
أما CTs ذات خرج الجهد والتي تحتوي على مقاومة حمل مدمجة، فهي تختلف في طريقة التوصيل، ويجب توصيلها وفقًا لمواصفات الشركة المصنعة.
11. برمجة ESP32
يتولى البرنامج عدة مهام رئيسية:
- قراءة إشارة CT.
- تحديد قيمة تيار RMS للتيار المتردد.
- تقدير القدرة الكهربائية.
- تجميع الطاقة المستهلكة مع مرور الوقت.
- عرض القياسات.
- إصدار تحذير عند تجاوز الاستهلاك اليومي حدًا محددًا.
توفر بيئة Arduino الخاصة بـ ESP32 الدالة analogReadMilliVolts() للحصول على قراءة جهد ADC بعد المعايرة، كما يمكن ضبط تخفيض ADC وفقًا لنطاق الإدخال المطلوب.
في هذا المثال، يتم استخدام الافتراضات التالية:
- جهد مصدر التيار المتردد: 230 V
- معامل القدرة: 1.0
- نسبة CT: 100 A : 50 mA
- مقاومة الحمل: 18 Ω
- مدخل ADC: GPIO34
- شاشة OLED: SSD1306 128 × 64 I²C
تم جعل قيم الجهد 230V ومعامل القدرة قابلة للتعديل عمدًا، لأنهما لا ينبغي اعتبارهما قيمًا ثابتة لجميع الحالات. فقد يختلف جهد التغذية الفعلي وخصائص الحمل من تركيب إلى آخر.
مكتبات Arduino المطلوبة
قم بتثبيت المكتبات التالية من خلال Library Manager في Arduino IDE:
- Adafruit GFX Library
- Adafruit SSD1306
يمكن أيضًا تشغيل الإصدار الأساسي من المشروع دون مكتبة OLED إذا أراد المستخدم عرض القياسات من خلال Serial Monitor فقط.
كود ESP32 التوضيحي
#include <Arduino.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
// -----------------------------
// OLED configuration
// -----------------------------
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
Adafruit_SSD1306 display(
SCREEN_WIDTH,
SCREEN_HEIGHT,
&Wire,
-1
);
// -----------------------------
// ESP32 ADC configuration
// -----------------------------
const int CT_PIN = 34;
// -----------------------------
// Electrical parameters
// -----------------------------
// Nominal AC supply voltage.
// Change this to match your installation.
const float AC_VOLTAGE = 230.0;
// Assumed power factor.
// For a simple current-only monitor,
// this is an approximation.
const float POWER_FACTOR = 1.0;
// CT example:
// 100 A primary / 0.050 A secondary
const float CT_PRIMARY_CURRENT = 100.0;
const float CT_SECONDARY_CURRENT = 0.050;
// Burden resistor used with the CT
const float BURDEN_RESISTOR = 18.0;
// -----------------------------
// Measurement parameters
// -----------------------------
const unsigned long SAMPLE_WINDOW_MS = 1000;
// Daily warning threshold
const float DAILY_LIMIT_KWH = 10.0;
// Accumulated energy
double dailyEnergyKWh = 0.0;
// Last measurement time
unsigned long lastEnergyUpdate = 0;
// -----------------------------
// Calculate RMS current
// -----------------------------
float readRMSCurrent()
{
unsigned long startTime = millis();
double sum = 0.0;
double sumSquared = 0.0;
unsigned long samples = 0;
while (millis() - startTime < SAMPLE_WINDOW_MS)
{
float voltage = analogReadMilliVolts(CT_PIN) / 1000.0;
sum += voltage;
sumSquared += voltage * voltage;
samples++;
delayMicroseconds(200);
}
if (samples < 2)
{
return 0.0;
}
// Calculate average DC bias
float averageVoltage = sum / samples;
// Calculate AC RMS voltage
double variance =
(sumSquared / samples) -
(averageVoltage * averageVoltage);
if (variance < 0)
{
variance = 0;
}
float rmsVoltage = sqrt(variance);
// CT secondary current
float secondaryCurrent =
rmsVoltage / BURDEN_RESISTOR;
// Convert secondary current
// to primary current
float primaryCurrent =
secondaryCurrent *
(CT_PRIMARY_CURRENT / CT_SECONDARY_CURRENT);
return primaryCurrent;
}
// -----------------------------
// Update energy calculation
// -----------------------------
void updateEnergy(float powerWatts)
{
unsigned long now = millis();
if (lastEnergyUpdate == 0)
{
lastEnergyUpdate = now;
return;
}
unsigned long elapsedMs = now - lastEnergyUpdate;
// Convert milliseconds to hours
double elapsedHours =
elapsedMs / 3600000.0;
// Wh = W × hours
double energyWh =
powerWatts * elapsedHours;
// Convert Wh to kWh
dailyEnergyKWh += energyWh / 1000.0;
lastEnergyUpdate = now;
}
// -----------------------------
// Display information
// -----------------------------
void updateDisplay(float currentA, float powerW)
{
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Daily Energy Monitor");
display.setTextSize(1);
display.setCursor(0, 16);
display.print("Current: ");
display.print(currentA, 2);
display.println(" A");
display.setCursor(0, 28);
display.print("Power: ");
display.print(powerW, 0);
display.println(" W");
display.setCursor(0, 40);
display.print("Today: ");
display.print(dailyEnergyKWh, 3);
display.println(" kWh");
display.setCursor(0, 54);
if (dailyEnergyKWh >= DAILY_LIMIT_KWH)
{
display.print("Status: HIGH");
}
else
{
display.print("Status: NORMAL");
}
display.display();
}
// -----------------------------
// Setup
// -----------------------------
void setup()
{
Serial.begin(115200);
// ESP32 ADC
analogReadResolution(12);
// 11 dB attenuation allows a larger
// input range on supported ESP32 devices.
analogSetPinAttenuation(
CT_PIN,
ADC_11db
);
// OLED
if (!display.begin(
SSD1306_SWITCHCAPVCC,
0x3C))
{
Serial.println("OLED initialization failed!");
while (true)
{
delay(1000);
}
}
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.println("Energy Monitor");
display.setCursor(0, 15);
display.println("Starting...");
display.display();
delay(2000);
}
// -----------------------------
// Main loop
// -----------------------------
void loop()
{
// Measure RMS current
float currentA = readRMSCurrent();
// Estimate power
float powerW =
AC_VOLTAGE *
currentA *
POWER_FACTOR;
// Accumulate energy
updateEnergy(powerW);
// Serial output
Serial.println("-------------------------");
Serial.print("Current: ");
Serial.print(currentA, 2);
Serial.println(" A");
Serial.print("Power: ");
Serial.print(powerW, 1);
Serial.println(" W");
Serial.print("Daily Energy: ");
Serial.print(dailyEnergyKWh, 3);
Serial.println(" kWh");
if (dailyEnergyKWh >= DAILY_LIMIT_KWH)
{
Serial.println("WARNING: High daily consumption!");
}
else
{
Serial.println("Status: Normal");
}
// Update OLED
updateDisplay(currentA, powerW);
delay(100);
}
كيف يحسب الكود الاستهلاك؟
يبدأ البرنامج بأخذ عينات من إشارة CT لمدة تقارب ثانية واحدة.
وبما أن الإشارة تتمركز حول جهد انحياز مستمر، يحسب البرنامج متوسط الجهد ثم يزيل هذه الإزاحة رياضيًا.
بعد ذلك يحسب قيمة RMS لشكل موجة التيار المتردد المتبقي.
العلاقة التقريبية هي:
I (الثانوي) = Vrms ÷ R (الحمل)
ثم:
I (الأساسي) = I (الثانوي) × نسبة CT
بالنسبة إلى CT المستخدم في المثال:
نسبة CT = 100 A ÷ 0.05 A = 2000
لذلك، إذا أنتج الملف الثانوي في CT تيارًا مقداره 0.025 A:
I (الأساسي) = 0.025 × 2000 = 50 A
يجب أن تعتمد علاقة المعايرة الفعلية على نوع CT المحدد ومقاومة الحمل المستخدمة. وتقدم Open Energy Monitor نفس المنهجية العامة لحساب التيار في أنظمة القياس المعتمدة على CT.
تقدير القدرة
يستخدم الكود التوضيحي العلاقة:
P = V × I × PF
وبالتالي، عند استخدام:
- الجهد = 230 V
- التيار = 2 A
- معامل القدرة = 1.0
تكون القدرة المقدرة:
P = 230 × 2 × 1.0 = 460 W
وهذا مناسب كشرح مبسط لفكرة المشروع وآلية عمله.
ومع ذلك، لا ينبغي تقديم هذه النتيجة على أنها مكافئة لقياس عداد كهرباء معتمد.
فقد يكون معامل القدرة في الأحمال التي تحتوي على محركات أو مصادر تغذية بتقنية Switching أو خصائص غير خطية أو تفاعلية أخرى مختلفًا بشكل ملحوظ عن القيمة 1.
وللحصول على قياس أكثر دقة للقدرة الفعلية، يجب أن يقيس النظام الجهد والتيار في الوقت نفسه، ثم يحسب حاصل ضربهما اللحظي.
ملاحظة مهمة حول الكود التوضيحي
تم تصميم الكود السابق عمدًا ليكون نموذجًا أوليًا مناسبًا للمبتدئين وليس عداد طاقة بمستوى مختبري.
فهو يوضح مفهوم القياس الكامل:
CT → ADC → تيار RMS → القدرة المقدرة → تجميع الطاقة → الشاشة
ولإنشاء نظام قياس بجودة مناسبة للاستخدام العملي، أوصي بتطوير التصميم على ثلاث مراحل:
المرحلة الأولى — مراقبة التيار فقط
- استخدام: CT + ESP32
- هذا هو أبسط تنفيذ، وهو مناسب لتوضيح فكرة المراقبة اليومية للاستهلاك في المشروع.
المرحلة الثانية — قياس الجهد والتيار
- إضافة دائرة معزولة لقياس جهد التيار المتردد.
- يمكن لـ ESP32 عندها قياس الجهد والتيار وحساب القدرة الفعلية بدلًا من تقديرها باستخدام جهد ثابت ومعامل قدرة مفترض.
المرحلة الثالثة — دائرة متخصصة لقياس الطاقة
- للحصول على دقة أعلى، يمكن لدائرة IC متخصصة لقياس الطاقة أن تتولى جزءًا كبيرًا من عمليات القياس الكهربائية، بينما يعمل ESP32 كوحدة للتحكم في الشاشة والاتصال وإدارة البيانات.
- ويُعد هذا الاتجاه أكثر ملاءمة إذا كان المشروع سيحتاج مستقبلًا إلى الاقتراب من مستوى دقة ووظائف أجهزة مراقبة الطاقة التجارية.
ملاحظة مهمة للسلامة في المقال
- نظرًا لأن هذا المشروع يتعامل مع كهرباء التيار المتردد المنزلية، يجب ألا يوحي مخطط التوصيل بأن المبتدئ يمكنه توصيل ESP32 مباشرةً بأسلاك التيار الرئيسي.
- يجب أن تبقى دائرة ESP32 في جانب الجهد المنخفض المعزول، كما يجب اختيار CT بقدرة مناسبة وتركيبه وفقًا لتعليمات الشركة المصنعة.
- تحذر Open Energy Monitor تحديدًا من ترك CT ذي خرج التيار في حالة دائرة مفتوحة أثناء تركيبه على موصل يمر فيه تيار.
- عند تنفيذ تركيب فعلي في منزل، يجب إجراء تركيب CT وأي عمل داخل لوحة التوزيع الكهربائية بعد توفير العزل والحماية المناسبة، ومن خلال شخص مؤهل بشكل مناسب.
تحسين إضافي أوصي به بشدة
في النسخة النهائية من المقال، أقترح تغيير المشروع من طريقة
«قياس التيار فقط + 230 V + PF=1»
إلى تصميم أكثر اكتمالًا يعتمد على قياس الجهد والتيار معًا.
سيجعل ذلك المقال أقوى من الناحية التقنية بالنسبة إلى المهندسين، مع بقائه مفهومًا للمبتدئين،
لأنه سيوضح الفرق بين التيار، والقدرة الظاهرية، والقدرة الفعلية، ومعامل القدرة، والكيلوواط ساعة (kWh) بدلًا من عرض القدرة المقدرة على أنها استهلاك دقيق.
12. عرض استهلاك الكهرباء اليومي
يُفضَّل أن تركز شاشة العرض على المعلومات المفيدة للمستخدم، بدلًا من عرض بيانات تقنية غير ضرورية.

يمكن أن تعرض الشاشة الرئيسية العملية المعلومات التالية:
- طاقة اليوم: 8.42 كيلوواط ساعة
- القدرة الحالية: 620 واط
- التيار الحالي: 2.7 أمبير
- الحالة: طبيعية
كما يمكن للشاشة توفير شاشات إضافية لعرض:
- استهلاك اليوم
- استهلاك الأمس
- القدرة الحالية
- أقصى قدرة
- متوسط الاستهلاك اليومي
- سجل الاستهلاك
الشاشة الرسومية
يمكن لشاشة TFT عرض رسم بياني بسيط يوضح كيفية تغير الاستهلاك خلال اليوم.
على سبيل المثال:
- 00:00 ← استهلاك منخفض
- 08:00 ← زيادة في النشاط
- 13:00 ← استهلاك متوسط
- 18:00 ← استهلاك مرتفع
- 23:00 ← استهلاك منخفض
وهذا مفيد بشكل خاص لأن الهدف من المشروع لا يقتصر على الحصول على قيمة نهائية للاستهلاك بوحدة كيلوواط ساعة. إذ يمكن لنمط الاستهلاك التاريخي أن يساعد المستخدم على فهم متى ارتفع الاستهلاك خلال اليوم.
13. حساب الطاقة اليومية وتخزين البيانات
يجب أن يكون للنظام تعريف واضح للوقت الذي يبدأ فيه “اليوم” والوقت الذي ينتهي فيه.

على سبيل المثال:
- 00:00 ← بدء سجل يومي جديد
- 23:59 ← اكتمال السجل اليومي
عند منتصف الليل، يمكن تخزين الطاقة المتراكمة لليوم السابق، ثم إعادة ضبط عداد الطاقة اليومية لبدء تسجيل يوم جديد.
يمكن أن يتضمن السجل التاريخي بيانات مثل:
| اليوم | الطاقة |
|---|---|
| اليوم 1 | 7.8 كيلوواط ساعة |
| اليوم 2 | 8.1 كيلوواط ساعة |
| اليوم 3 | 7.9 كيلوواط ساعة |
| اليوم 4 | 8.4 كيلوواط ساعة |
| اليوم 5 | 12.7 كيلوواط ساعة |
- يسهّل ذلك اكتشاف الأيام غير المعتادة في الاستهلاك.
- يمكن استخدام الذاكرة المدمجة في ESP32 لتخزين كميات صغيرة من البيانات التاريخية، بينما يكون استخدام بطاقة SD أو التخزين عبر الشبكة أكثر ملاءمة إذا كان المطلوب الاحتفاظ بسجلات لعدة أشهر.
- كما يمكن لإصدار مزود بخاصية Wi-Fi إرسال القراءات اليومية إلى جهاز كمبيوتر أو واجهة على الهاتف الذكي أو لوحة تحكم عبر الإنترنت.
14. اكتشاف الاستهلاك الكهربائي غير الطبيعي
من أكثر الميزات فائدة في هذا المشروع إمكانية اكتشاف الارتفاع غير المعتاد في استهلاك الكهرباء اليومي.
وتتمثل أبسط طريقة لذلك في تحديد خط أساس يمثل نمط الاستهلاك الطبيعي.

على سبيل المثال:
لنفترض أن النظام يسجل القيم النموذجية التالية:
النطاق اليومي الطبيعي: 7–9 كيلوواط ساعة
إذا سجل جهاز المراقبة:
12.5 كيلوواط ساعة
فيمكن للنظام عرض:
استهلاك يومي مرتفع
- لا يحتاج جهاز المراقبة إلى تحديد الجهاز الكهربائي المسؤول عن الزيادة بشكل دقيق.
- بل يخبر المستخدم بأن إجمالي الاستهلاك كان مختلفًا بشكل ملحوظ عن النمط المعتاد.
طرق اكتشاف الاستهلاك غير الطبيعي
- يمكن للنظام الأساسي استخدام حد ثابت: إذا كانت الطاقة اليومية > الحد المحدد ← تحذير
- يمكن للنظام الأكثر تطورًا حساب متوسط استهلاك الأيام السابقة: متوسط الطاقة اليومية = مجموع استهلاك الأيام السابقة ÷ عدد الأيام
- بعد ذلك، يمكن للنظام مقارنة قيمة اليوم مع خط الأساس التاريخي.
على سبيل المثال:
- إذا كان الاستهلاك المعتاد يقترب من 8 كيلوواط ساعة وكانت قيمة اليوم أعلى بشكل ملحوظ، فيمكن للشاشة الإشارة إلى أن هذا اليوم يحتاج إلى المراجعة.
- يجب اختيار حد التنبيه بعناية، لأن استخدام الكهرباء يتغير طبيعيًا من يوم إلى آخر. ولا تعني القيمة المرتفعة تلقائيًا وجود عطل.
15. المعايرة ودقة القياس
- تُعد المعايرة أمرًا أساسيًا إذا كان من المتوقع أن يقدم جهاز المراقبة قياسات رقمية مفيدة.
- يقوم محول ADC في ESP32 بتحويل الجهد التناظري إلى قيمة رقمية، لكن قراءة ADC وحدها لا تخبر النظام بكمية التيار الكهربائي المتدفق.
- لذلك يحتاج البرنامج إلى علاقة تربط بين: قراءة ADC ← إشارة المستشعر ← التيار ← القدرة ← الطاقة
- يمكن إجراء المعايرة من خلال مقارنة قياس جهاز المراقبة بقياس مرجعي موثوق.

على سبيل المثال:
- وصّل حملًا معلومًا.
- قِس الحمل باستخدام جهاز قياس موثوق.
- سجّل القياس الذي يقرأه ESP32.
- احسب معامل التصحيح.
- طبّق معامل المعايرة في البرنامج.
- كرّر الاختبار باستخدام أحمال مختلفة.
ويُفضّل إجراء المعايرة تحت عدة ظروف تشغيل مختلفة، بدلًا من الاعتماد على حمل واحد فقط.
مصادر الخطأ
يمكن أن تنتج أخطاء القياس عن عدة عوامل، منها:
- دقة محول التيار CT
- تشبع محول التيار CT
- تحمل مقاومة الحمل (Burden Resistor)
- محدودية محول ADC
- الضوضاء الكهربائية
- التحجيم غير الصحيح للإشارة
- تغير الجهد
- الافتراضات المتعلقة بمعامل القدرة
- أخطاء طور الإشارة
- درجة الحرارة
- أخطاء المعايرة
تناقش شركة Analog Devices قياس الطاقة باستخدام محولات التيار CT من حيث اختيار مقاومة الحمل، وخطأ الطور، واختيار المستشعر، والمعايرة، مما يوضح أن الوصول إلى قياس دقيق للطاقة يتطلب أكثر من مجرد قراءة مستشعر التيار.
وبالنسبة إلى مشروع هواة، يمكن للنظام أن يكون مفيدًا بدرجة كافية دون الحاجة إلى دقة بمستوى المختبر، ولكن يجب فهم حدوده بوضوح.
16. اعتبارات السلامة الكهربائية والتركيب
يُعد هذا القسم بالغ الأهمية لأن المشروع يتعامل مع شبكة الكهرباء الرئيسية.
يمكن لمستشعر التيار من نوع CT توفير طريقة لقياس التيار دون الحاجة إلى قطع الموصل الكهربائي، ولكن تركيبه حول أحد موصلات الشبكة الكهربائية يتطلب العمل بالقرب من جهود كهربائية قد تكون قاتلة.
يجب تركيب مستشعر CT فقط وفقًا لتعليمات الشركة المصنعة الخاصة بالمستشعر.

كما أن مستشعر CT ذي خرج التيار يتطلب مراعاة مهمة تتعلق بالسلامة؛ إذ لا ينبغي ترك دائرة خرجه مفتوحة أثناء تركيبه حول موصل يمر فيه تيار، إلا إذا كان مستشعر CT المعني مصممًا ومحمياً خصيصًا للعمل في هذه الحالة.
يحذر مشروع Open Energy Monitor من أن مستشعر CT ذي خرج التيار، عند تشغيله دون حمل مناسب على خرجه، قد يولد جهدًا مرتفعًا وخطيرًا محتملًا عند أطرافه الثانوية.
كما يجب تصميم دائرة القياس المتصلة بوحدة ESP32 بحيث يبقى الجهد الواصل إلى محول ADC ضمن حدود الإدخال المناسبة والآمنة.
بالنسبة إلى مشاريع الهواة، يُعد استخدام المكونات التالية من الأساليب الأكثر أمانًا بشكل عام:
- مستشعر CT مصنف بشكل مناسب لجهد وتيار التطبيق.
- وحدة قياس معزولة ومصممة خصيصًا لهذا الغرض عند الحاجة.
- حاوية مناسبة وعزل كهربائي ملائم.
- مكونات ذات تصنيفات كهربائية مناسبة للتطبيق.
- مزود طاقة معزول ومنخفض الجهد لتشغيل الدوائر الإلكترونية.
يجب تنفيذ أي تركيب يتضمن توصيلات الشبكة الكهربائية أو فحصه بواسطة شخص مؤهل بشكل مناسب. ولا ينبغي أبدًا اعتبار وحدة ESP32 أو الدوائر الإلكترونية منخفضة الجهد بديلًا عن وسائل الحماية الكهربائية الصحيحة أو ممارسات تركيب شبكة الكهرباء المعتمدة.
17. التحسينات المحتملة والتوسعات المستقبلية
بعد تشغيل نظام المراقبة اليومية الأساسي بنجاح، يمكن توسيع المشروع وإضافة العديد من الوظائف المتقدمة.

مراقبة استهلاك الكهرباء عبر Wi-Fi
- نظرًا لأن ESP32 توفر اتصال Wi-Fi، يمكن إرسال القياسات إلى شبكة محلية أو إلى لوحة معلومات عبر الإنترنت.
- يتيح ذلك للمستخدم متابعة استهلاك الكهرباء دون الحاجة إلى التواجد بالقرب من شاشة العرض.
الرسوم البيانية التاريخية
يمكن للنظام تخزين بيانات عدة أيام أو أشهر وإنشاء رسوم بيانية توضح:
- استهلاك الطاقة اليومي.
- استهلاك الطاقة الأسبوعي.
- استهلاك الطاقة الشهري.
- ذروة القدرة الكهربائية.
- متوسط القدرة الكهربائية.
التنبيهات التلقائية
يمكن لوحدة ESP32 إصدار تنبيه عندما يتجاوز الاستهلاك حدًا محددًا مسبقًا.
على سبيل المثال: لقد تجاوز استهلاك اليوم الحد اليومي المتوقع.
قنوات مراقبة متعددة
يمكن استخدام عدة مستشعرات CT لمراقبة دوائر كهربائية مختلفة بشكل منفصل.
على سبيل المثال:
- دائرة الإضاءة.
- دائرة المكتب.
- دائرة ورشة العمل.
- دائرة تكييف الهواء.
يقرّب هذا التوسع المشروع من مفهوم مراقبة استهلاك الطاقة على مستوى الدوائر الكهربائية، مع بقائه مختلفًا عن تحديد استهلاك كل جهاز كهربائي بشكل مستقل.
قياس أكثر دقة للطاقة
- يمكن للتصميم الأكثر تقدمًا استخدام دوائر متخصصة لقياس الطاقة بدلًا من الاعتماد بشكل كامل على محول ADC الموجود في ESP32.
- يمكن أن يؤدي ذلك إلى تحسين دقة القياس وتبسيط بعض العمليات الحسابية المتعلقة بقياس الطاقة الكهربائية.
تسجيل البيانات
يسمح تسجيل البيانات على المدى الطويل باكتشاف أنماط مختلفة، مثل:
- زيادة الاستهلاك الشهري.
- الاختلاف بين استهلاك أيام العمل وعطلات نهاية الأسبوع.
- التغيرات الموسمية في الاستهلاك.
- الأيام التي شهدت استهلاكًا مرتفعًا بشكل غير معتاد.
- التغير في الاستهلاك بعد استبدال أحد الأجهزة الكهربائية.
يحوّل ذلك المشروع من مجرد نظام لعرض البيانات إلى نظام عملي لمراقبة استهلاك الطاقة وتحليله.
18. الأسئلة الشائعة
هل يمكن لهذا المشروع قياس الكهرباء التي يستهلكها كل جهاز على حدة؟
- لا. في تكوينه الأساسي، يقيس النظام الاستهلاك المجمع لجميع الأجهزة المتصلة بالدائرة التي تتم مراقبتها.
- يمكن للنظام إظهار ارتفاع إجمالي الاستهلاك، لكنه لا يستطيع تحديد ما إذا كانت الثلاجة أو التلفاز أو الكمبيوتر هو المسؤول تحديدًا عن هذه الزيادة.
ما الهدف الرئيسي من هذا المشروع؟
الهدف الأساسي هو مراقبة إجمالي استهلاك الكهرباء اليومي وتحديد ما إذا كانت كمية الطاقة المستهلكة خلال اليوم تقع ضمن النطاق المتوقع.
هل يمكن استخدام مستشعر CT مع ESP32؟
نعم. يمكن لمستشعر CT توفير إشارة قياس تناظرية يمكن تهيئتها وقراءة قيمتها بواسطة محول ADC في ESP32. ويعتمد أسلوب التوصيل الدقيق على نوع مستشعر CT وطريقة تكوين خرجه.
هل يكفي قياس التيار لحساب استهلاك الكهرباء؟
- يمكن الحصول على تقدير للاستهلاك عند استخدام جهد اسمي وافتراضات مناسبة، لكن هذه الطريقة أقل دقة من قياس الجهد والتيار معًا.
- ولإجراء قياس دقيق للقدرة الفعلية، يجب أخذ الجهد والتيار والعلاقة الطورية بينهما في الاعتبار.
ماذا تعني وحدة kWh؟
الكيلوواط-ساعة هي وحدة لقياس الطاقة. وهي تمثل كمية الطاقة المستهلكة عندما يعمل حمل بقدرة 1 كيلوواط لمدة ساعة واحدة.
لماذا يجب تركيب المستشعر حول موصل واحد فقط؟
- في الدائرة أحادية الطور، يسري التيار في موصلي الخط الحي والمحايد في اتجاهين متعاكسين.
- إذا مر كلا الموصلين داخل مستشعر CT نفسه، فقد تتعادل التأثيرات المغناطيسية الناتجة عنهما، مما يؤدي إلى ظهور إشارة قياس ضعيفة جدًا أو عدم ظهور إشارة مفيدة.
هل يستطيع ESP32 اكتشاف الاستهلاك المرتفع بشكل غير معتاد؟
نعم. يمكن للبرنامج مقارنة الطاقة اليومية المتراكمة بحد محدد مسبقًا أو بمتوسطات الاستهلاك اليومية السابقة، ثم عرض تحذير عندما يكون الاستهلاك أعلى من المعتاد.
هل تعني قيمة الاستهلاك اليومي المرتفعة بالضرورة أن أحد الأجهزة الكهربائية معطل؟
لا. فهي تشير فقط إلى أن إجمالي الاستهلاك المقاس كان أعلى من المتوقع. ويظل على المستخدم معرفة الأجهزة التي كانت تعمل خلال تلك الفترة والتحقق من سبب ارتفاع الاستهلاك.
هل يمكن للمشروع تخزين استهلاك الأيام السابقة؟
نعم. يمكن تخزين القيم اليومية في الذاكرة المحلية أو بطاقة SD أو قاعدة بيانات خارجية، وذلك وفقًا لكمية البيانات التاريخية المطلوبة.
هل يمكن للنظام العمل دون Wi-Fi؟
نعم. لا يحتاج نظام القياس الأساسي إلى اتصال Wi-Fi. إذ يمكن لوحدة ESP32 إجراء القياس والحساب وتخزين البيانات وعرضها محليًا.
هل هذا المشروع مناسب للمبتدئين؟
- نعم، إذا تم تنفيذ المشروع على مراحل متدرجة.
- يمكن للمبتدئين البدء بقراءة المستشعر وعرض البيانات، ثم إضافة حسابات الطاقة وتسجيل البيانات والمعايرة واكتشاف الاستهلاك غير المعتاد في مراحل لاحقة.
19. الخاتمة
يُعد مشروع نظام مراقبة استهلاك الكهرباء اليومي الذكي باستخدام ESP32 مشروعًا عمليًا في مجال الأنظمة المضمنة، يتيح مراقبة إجمالي استهلاك الكهرباء لمجموعة محددة من الأجهزة.
لا يتمثل الهدف الأساسي للمشروع في تحديد استهلاك الطاقة لكل جهاز كهربائي بشكل منفصل، بل في مراقبة إجمالي الاستهلاك الكهربائي بصورة مستمرة، وحساب كمية الطاقة المتراكمة المستخدمة خلال اليوم، ثم عرض المعلومات بطريقة واضحة وسهلة الفهم.
يوفر هذا الأسلوب طريقة بسيطة لإنشاء نمط طبيعي للاستهلاك اليومي. وإذا كانت كمية الطاقة المقاسة أعلى بكثير من المتوقع، يمكن للمستخدم فحص الأجهزة التي كانت تعمل خلال تلك الفترة وتحديد السبب المحتمل لزيادة الاستهلاك.
يمكن أن يعتمد التنفيذ الأساسي على وحدة ESP32، ومستشعر تيار متردد مناسب مثل CT، ودائرة تهيئة للإشارة، وشاشة لعرض البيانات. أما التنفيذ الأكثر تقدمًا فيمكن أن يضيف قياس الجهد، وحساب القدرة الفعلية، والمعايرة، وتسجيل البيانات، والاتصال عبر Wi-Fi، والرسوم البيانية التاريخية، والتنبيهات التلقائية.
يوفر المشروع للمبتدئين مدخلًا عمليًا لفهم المستشعرات، ومحولات ADC، والبرمجة المضمنة، والقياسات الكهربائية، ومعالجة البيانات. أما المهندسون والهواة ذوو الخبرة فيمكنهم استخدامه كأساس لتطوير نظام أكثر تقدمًا لمراقبة الطاقة وتحليل استهلاكها.
ويتمثل أهم مبدأ في تصميم هذا النوع من الأنظمة في اختيار طريقة القياس التي تتوافق مع هدف المشروع: إذا كان الهدف هو فهم إجمالي استهلاك الكهرباء اليومي واكتشاف الاستهلاك غير المعتاد، فإن مراقبة الاستهلاك المجمع تكون كافية، ولا تكون هناك حاجة إلى قياس استهلاك كل جهاز على حدة.







Leave a comment
You must be logged in to post a comment.