If you want to measure AC mains current without cutting wires or exposing bare copper, a split-core current sensor transformer (CT) is the correct tool. The direct answer for microcontroller interfacing: a passive CT outputs an analog AC signal (either current or voltage, depending on the model) that must be shifted into your MCU's ADC range using a DC bias circuit. To get accurate physical units, you must sample the waveform at high speed, subtract the DC offset, and calculate the Root Mean Square (RMS) in software.
This guide covers the exact hardware interface, the raw-to-unit math, and the specific failure modes you will encounter when wiring a YHDC SCT-013 series CT to a 3.3V ESP32 or 5V Arduino Uno.
How a Current Sensor Transformer Actually Works
A current sensor transformer operates on Faraday’s law of induction, but unlike a voltage transformer, it steps down current, not voltage. The AC wire passing through the center of the core acts as a single-turn primary winding. The secondary winding inside the plastic housing contains thousands of turns of fine enameled copper wire. When AC current flows through the primary, it generates an alternating magnetic field in the ferrite core, inducing a proportional, isolated AC current in the secondary winding. For a standard 100A:50mA CT, 100 amps in the primary yields exactly 50 milliamps in the secondary.
The most critical distinction when buying a CT is whether it outputs current or voltage. The SCT-013-000 is a current-output device; it requires an external "burden resistor" to convert the secondary current into a measurable voltage. The SCT-013-030 has an internal burden resistor and outputs an analog AC voltage (typically 1V RMS at 30A). Never connect a current-output CT directly to a microcontroller without a burden resistor. Without a load to dissipate the energy, the induced voltage will spike to hundreds of volts, arcing across the connector, saturating the core, and potentially destroying the sensor or shocking the user.
Hardware Wiring and Pin Mapping
Because the CT itself is entirely passive, it requires no power supply. However, microcontrollers like the ESP32 and Arduino cannot read negative voltages. Since the CT outputs an AC waveform that swings above and below 0V, you must build a DC bias network to shift the entire signal up to the midpoint of your ADC's reference voltage (1.65V for a 3.3V system, or 2.5V for a 5V system).
| Component / Pin | Value / Target | Function & Supply Range |
|---|---|---|
| CT Sensor (SCT-013-000) | 100A:50mA | Passive. No VCC required. Max primary current 100A continuous. |
| Burden Resistor (R_b) | 33Ω (for 3.3V) / 62Ω (for 5V) | Converts secondary AC current to AC voltage. Must be 1% tolerance metal film. |
| Bias Resistors (R1, R2) | 10kΩ each | Voltage divider from VCC to GND. Creates the 1.65V (or 2.5V) DC offset midpoint. |
| Filter Capacitor (C1) | 10µF to 47µF | Stabilizes the DC bias midpoint. Connects between the bias midpoint and GND. |
| MCU ADC Pin | GPIO34 (ESP32) / A0 (Arduino) | Analog input. ESP32 range: 0-3.3V. Arduino range: 0-5V. |
Numbered Wiring Steps
- De-energize and Verify: If clamping over existing mains wiring, turn off the breaker and verify dead with a non-contact voltage tester and a multimeter. (NEC-style guidance: never work on live panels unless you are qualified and using appropriate PPE).
- Install the Burden Resistor: Solder a 33Ω resistor directly across the two wires of the SCT-013-000's 3.5mm jack or bare leads. This must be physically close to the sensor plug to prevent open-circuit conditions if the plug is bumped.
- Build the Bias Network: Connect two 10kΩ resistors in series between the MCU's 3.3V VCC pin and GND. The junction between them is your 1.65V bias point.
- Add the Filter Cap: Connect the positive leg of a 10µF electrolytic capacitor to the 1.65V bias point, and the negative leg to GND.
- Connect the Sensor: Wire one CT lead to the 1.65V bias point. Wire the other CT lead to your MCU's ADC pin (e.g., ESP32 GPIO34).
From Raw ADC Counts to Amps: The Output Math
Reading a current sensor transformer is not like reading a temperature sensor; you cannot just take a single analogRead() and map it. You are measuring a 50Hz or 60Hz sine wave. To find the actual current, you must calculate the RMS (Root Mean Square) value over at least one full AC cycle. The authoritative open-source library for this is EmonLib by OpenEnergyMonitor, but understanding the underlying math is critical for debugging.
The Raw-to-Unit Conversion Pipeline
Assume an ESP32 with a 12-bit ADC (0-4095 counts) and a 3.3V reference, using an SCT-013-000 (100A:50mA) and a 33Ω burden resistor.
- Sample the Waveform: Read the ADC as fast as possible for one full cycle (20ms for 50Hz, 16.67ms for 60Hz). Collect ~1,500 samples.
- Remove the DC Offset: Subtract the theoretical midpoint (2048 counts) or the dynamically measured offset from every raw sample.
- Convert to Voltage: Multiply the offset-adjusted count by the ADC resolution:
V_inst = (raw - 2048) * (3.3 / 4095). - Convert to Secondary Current: Apply Ohm's law across the burden resistor:
I_sec_inst = V_inst / 33.0. - Scale to Primary Current: Multiply by the turns ratio. For a 100A:50mA sensor, the ratio is 100 / 0.05 = 2000.
I_pri_inst = I_sec_inst * 2000. - Calculate RMS: Square every instantaneous primary current value, sum them up, divide by the total number of samples, and take the square root.
Calibration Reality Check: The theoretical math assumes a perfect ADC and perfect burden resistor. In practice, the ESP32's actual VCC might be 3.28V, and your 33Ω resistor might measure 32.8Ω on the bench. You must apply a calibration constant (often called I_CAL in EmonLib). Measure the actual mains current with a trusted Fluke clamp meter, read your MCU's calculated RMS value, and adjust I_CAL until they match.
Troubleshooting Interference and Signal Noise
Current sensor transformers are highly susceptible to environmental noise because the secondary signal is in the millivolt or milliamp range before amplification. If your RMS readings jump around by 0.5A when no load is connected, you are picking up interference.
- Capacitive Coupling from Mains: If the unshielded CT wires run parallel to the AC mains cable for more than a few inches, the 50/60Hz electric field will induce noise. Fix: Keep CT leads short, or use a twisted-pair cable for the secondary leads to reject common-mode electric fields.
- Magnetic Interference: Placing the CT near the AC busbar of a breaker panel, or near the transformer of a power supply, will induce stray magnetic flux into the ferrite core. Fix: Orient the CT core perpendicular to nearby magnetic sources and maintain at least 2 inches of clearance from other current-carrying conductors.
- Bias Network Ground Loops: If your DC bias resistors are tied to a noisy 3.3V rail (like the one generated by a cheap AMS1117 linear regulator on an ESP32 dev board), that switching noise will inject directly into your ADC readings. Fix: Use a dedicated, low-noise 3.3V LDO for the sensor bias network, or power the bias network from the USB 5V rail and step it down with precision resistors.
- ADC Crosstalk: Reading multiple CTs on adjacent ESP32 ADC pins (e.g., GPIO34 and GPIO35) causes internal multiplexer charge-injection crosstalk. Fix: Add a 10kΩ series resistor and a 100nF ceramic capacitor at each ADC pin to form a low-pass RC filter, stabilizing the sample-and-hold circuit.
Current Sensor Transformer FAQ
Can I use a current sensor transformer to measure DC battery current?
No. A current sensor transformer relies entirely on a changing magnetic field (dΦ/dt) to induce a secondary current. Direct Current (DC) produces a static magnetic field, which induces zero voltage in the secondary winding. To measure DC current from a battery or solar array, you must use a Hall-effect sensor (like the Allegro ACS712 or ACS724), a fluxgate sensor, or a low-resistance shunt resistor paired with an instrumentation amplifier (like the INA219).
What happens if I open-circuit a current sensor transformer while it is clamped over a live wire?
An open-circuited CT is extremely dangerous. Without a burden resistor to limit the voltage, the transformer attempts to drive the secondary current through infinite resistance. This causes the ferrite core to saturate heavily, inducing voltage spikes of several hundred volts across the open secondary terminals. This can result in arcing across the connector, melting the fine secondary wire insulation, permanent loss of core permeability, and a severe shock hazard. Always ensure the burden resistor is securely soldered before clamping the sensor over an energized conductor.
How do I calibrate a split-core current sensor transformer for accurate low-current readings?
Split-core CTs suffer from significant non-linearity and phase shift at the bottom 10% of their rated range (e.g., reading a 5W LED bulb on a 100A CT). The ferrite core's permeability drops at very low flux densities. To improve low-end accuracy, use a CT with a lower primary rating (like a 20A or 30A model) if you are primarily measuring small loads. In software, avoid using a single linear calibration constant; instead, implement a piecewise linear calibration array in your code that applies different scaling factors based on the raw ADC magnitude.
Why is my ESP32 reading 0.2 Amps when the breaker is turned off?
This is a classic "ghost current" reading caused by ADC noise and the RMS calculation math. The RMS formula squares the noise values before averaging them, meaning even 20 counts of random ADC jitter will yield a non-zero RMS result. To fix this, implement a software noise floor: if the peak-to-peak raw ADC variation over one cycle is less than a defined threshold (e.g., 15 counts), hardcode the final RMS output to 0.0A.






