How do you use your CT Clamp Energy Monitor?

So I just built a CT Clamp energy monitor using ESP Home. I had a vision that all i needed to do was clip it around a device cable and it would measure the current… of course, this is incorrect, and as I now know you need it to go round ONLY the Live (or Neutral)

Short of stripping the wire casing all the devices I was hoping to measure with it, I wonder how anyone else uses these? I don’t even seem to be able to use it at my consumer unit since the wires are all three core…

They strip the insulation? :man_shrugging:

Your CU should have enough of a gap or wire slack to allow you to only monitor your Live. Considering the CT clamp is quite slim, you should be able to identify the live wire and clamp around it.

1 Like

Clamping a single wire (core) is the only way. It’s just how the physics work. If you clamp the whole wire carrying AC, the magnetic fields cancel each other out. The only way is to separate them, as you said.

I use CT clamps for large loads and inline meters for smaller ones.

3 Likes

I’m thinking I might build a small extension lead with the wires unsheathed to test with

1 Like

That’s what I did. That’s pretty much your only option if you want to test a plug-in device with a CT clamp.

1 Like

I’ve actually just built myself an adaptor that has the wires separate for me to clamp around, but sadly I’m still not getting any readings… wonder if someone here can help?

For reference i’m using ESP Home, ESP8266, this adaptor and a 100a/50mA clamp

I’m getting readings… but no matter what I run through the CT clamp, they don’t seem to change…

When off:

14:50:42][D][ct_clamp:041]: 'Power Sensor Live Power' - Raw AC Value: 0.001A after 181 different samples (905 SPS)
[14:50:42][D][sensor:103]: 'Power Sensor Live Power': Sending state 0.22107 W with 0 decimals of accuracy

When on:

[14:57:24][D][ct_clamp:041]: 'Power Sensor Live Power' - Raw AC Value: 0.001A after 150 different samples (750 SPS)
[14:57:24][D][sensor:103]: 'Power Sensor Live Power': Sending state 0.25732 W with 0 decimals of accuracy

No difference… but I’m running ~67W through it…

This was exactly the result I was getting when I thought it was me being an idiot, but only the live wire is going through the CT now…

My ESPHome YAML is here:

substitutions:
  device_name: power-sensor
  friendly_name: "Power Sensor"
  device_description: "CT-clamp power sensor"
  homeassistant_grid_voltage_entity: input_number.grid_voltage_helper_for_power_monitor # Set this to an entity in Home Assistant that is monitoring your grid voltage
  
  
esphome:
  name: '${device_name}'
  comment: '${device_description}'

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:
  # password: !secret api_password ## No longer recommended if using encryption. ##
  encryption:
    key: "MYKEY"

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: '${device_name}'
    password: "MYPASS"

captive_portal:

ota:
  platform: esphome

safe_mode:
  disabled: false
  reboot_timeout: 10min
  num_attempts: 5
  
output:
  - platform: esp8266_pwm
    id: power_led_output
    pin: GPIO2 #D4

sensor:
  # The grid voltage entity from Home Assistant
  - platform: homeassistant
    name: "Grid Voltage Entity from Home Assistant"
    entity_id: '${homeassistant_grid_voltage_entity}'
    id: grid_voltage
    internal: true
    
  - platform: ct_clamp
    sensor: adc_sensor
    name: "Power Sensor Live Power"
    id: power_sensor_live_power
    update_interval: 2s
    accuracy_decimals: 0
    filters:
      #- calibrate_linear:
        #- 0.001 -> 0.0
      - lambda: return x * id(grid_voltage).state;
    unit_of_measurement: "W"
    #on_value:
    #  then:
    #    - script.execute: flash_led
    
  - platform: adc
    pin: A0
    id: adc_sensor
    internal: true
    

light:
  - platform: binary
    name: "Power Sensor LED"
    id: power_led
    output: power_led_output
    internal: true
            
script:
  - id: flash_led
    then:
      - light.turn_on:
          id: power_led
      - delay: 100ms
      - light.turn_off:
          id: power_led

Anyone got any ideas?!

Can you post an annotated picture of this adapter and the rest? Label the wires so that we can understand what you have done.

1 Like

Sure - probably doesn’t need much annotation as speaks for itself, but typical Brown live, Blue Neutral, Green/Yellow earth

Clamp is around brown live wire

ESP etc here


Also, for completeness going to add the logs headers:

[16:12:27][C][logger:252]: Logger:
[16:12:27][C][logger:252]:   Max Level: DEBUG
[16:12:27][C][logger:252]:   Initial Level: DEBUG
[16:12:27][C][logger:258]:   Log Baud Rate: 115200
[16:12:27][C][logger:258]:   Hardware UART: UART0
[16:12:27][C][esp8266_pwm:021]: ESP8266 PWM:
[16:12:27][C][esp8266_pwm:022]:   Pin: GPIO2
[16:12:27][C][esp8266_pwm:023]:   Frequency: 1000.0 Hz
[16:12:27][C][light:088]: Light 'Power Sensor LED'
[16:12:27][C][adc.esp8266:026]: ADC Sensor 'adc_sensor'
[16:12:27][C][adc.esp8266:026]:   State Class: 'measurement'
[16:12:27][C][adc.esp8266:026]:   Unit of Measurement: 'V'
[16:12:27][C][adc.esp8266:026]:   Accuracy Decimals: 2
[16:12:27][C][adc.esp8266:026]:   Device Class: 'voltage'
[16:12:27][C][adc.esp8266:030]:   Pin: GPIO17
[16:12:27][C][adc.esp8266:032]:   Samples: 1
[16:12:27][C][adc.esp8266:032]:   Sampling mode: average
[16:12:27][C][adc.esp8266:036]:   Update Interval: 60.0s
[16:12:27][C][ct_clamp:013]: CT Clamp Sensor 'Power Sensor Live Power'
[16:12:27][C][ct_clamp:013]:   State Class: 'measurement'
[16:12:27][C][ct_clamp:013]:   Unit of Measurement: 'W'
[16:12:27][C][ct_clamp:013]:   Accuracy Decimals: 0
[16:12:27][C][ct_clamp:013]:   Device Class: 'current'
[16:12:27][C][ct_clamp:014]:   Sample Duration: 0.20s
[16:12:27][C][ct_clamp:015]:   Update Interval: 2.0s
[16:12:27][C][captive_portal:099]: Captive Portal:
[16:12:27][C][esphome.ota:075]: Over-The-Air updates:
[16:12:27][C][esphome.ota:075]:   Address: power-sensor.local:8266
[16:12:27][C][esphome.ota:075]:   Version: 2
[16:12:27][C][safe_mode:018]: Safe Mode:
[16:12:27][C][safe_mode:019]:   Boot considered successful after 60 seconds
[16:12:27][C][safe_mode:019]:   Invoke after 5 boot attempts
[16:12:27][C][safe_mode:019]:   Remain for 600 seconds
[16:12:27][C][web_server.ota:224]: Web Server OTA
[16:12:27][C][api:205]: Server:
[16:12:27][C][api:205]:   Address: power-sensor.local:6053
[16:12:27][C][api:210]:   Noise encryption: YES
[16:12:27][C][mdns:124]: mDNS:
[16:12:27][C][mdns:124]:   Hostname: power-sensor
[16:12:27][C][homeassistant.sensor:030]: Homeassistant Sensor 'Grid Voltage Entity from Home Assistant'
[16:12:27][C][homeassistant.sensor:030]:   State Class: ''
[16:12:27][C][homeassistant.sensor:030]:   Unit of Measurement: ''
[16:12:27][C][homeassistant.sensor:030]:   Accuracy Decimals: 1
[16:12:27][C][homeassistant.sensor:031]:   Entity ID: 'input_number.grid_voltage_helper_for_power_monitor'

I use some inepro PRO380 multimeter and read them via modbus. But i know this could be a bit expensive.

1 Like

Thanks, the clamp looks fine. Just keep in mind that the coil has a direction, so mount it the right way around if you are planning on using the power factor (lead/lag of voltage to current).

That said, there are a number of things to look at.

You cannot just wire a CT clamp straight into an ADC. The ADC can only measure positive values, but alternating current will swing across zero. You need to do two things: Add a circuit to offset the signal so that it swings between zero and 3.3V. That also means you need to calibrate your sensor.

Also, you cannot multiply your measured current value with a voltage. Your grid voltage entity from HA is likely an RMS voltage (110V or 220V) while your current reading from the CT clamp is an instantaneous value. You could calculate an RMS current and multiply those two values, but here’s the catch: You’d need the power factor, because how the two signals vary together matters a lot. Using a voltage value from HA you will surely be out by a significant factor, making your calculation meaningless. Say your voltage sensor updates every second, while grid power is probably 50Hz (100 zero crossings per second), you can imagine that there’s no way that can work. You ideally must measure the current and voltage at the same point, at the same time. You’ll find circuits online for doing this, so you can measure the voltage with the same ESP.

I would also recommend you use the CT clamp platform that ESPHome provides: CT Clamp Current Sensor - ESPHome - Smart Home Made Simple.

PS: Which power figure you want also depends, because there’s apparent, reactive and true power. Usually you’d want true power, as that is what you typically get charged for as a residential user. Just note these power values are related, but different.

2 Likes

2 Likes

Great.

In that sheet they also mention the burden resistor needed to measure the voltage.

Thanks for taking the time to help - I want to clarify a few things as I’m starting to get a bit lost…! Honestly this started as something I thought I could knock up reasonably easily to measure a couple of devices, and I was following this video

As I understand it, this is what the Motram Labs board does, no?

Also understood, but I need base readings to calibrate from… (which I’m not getting)

I’m not sure I agree here - I am aware it’s not going to be entirely accurate based on a static grid figure but it’s only “meaningless” if you’re looking for super accuracy. I know the UK grid sits at between 230-240v - and my intended use case was to simply get comparative values from a couple of devices in my house. Therefore on a comparative scale it’s as accurate as I need.
It is not intended for long term use (maybe one day when I have Solar and can get the true values and get better use out of it) - the HA entity is simply a static 230v for this purpose

Isn’t that what I’m using?

  - platform: ct_clamp
    sensor: adc_sensor
    name: "Power Sensor Live Power"
    id: power_sensor_live_power
    update_interval: 2s
    accuracy_decimals: 0
    filters:
      #- calibrate_linear:
        #- 0.001 -> 0.0
      - lambda: return x * id(grid_voltage).state;
    unit_of_measurement: "W"
    #on_value:
    #  then:
    #    - script.execute: flash_led
    
  - platform: adc
    pin: A0
    id: adc_sensor
    internal: true

I did miss this… i just tried it on my 3kw kettle and I got a reading! It was only 8W but I assume that’s a calibration error :crossed_fingers:

I actually tried it both way arounds and got the same reading?

1 Like

You’re welcome.

I’m happy to read any tutorials you have followed, but I don’t have time to watch videos, neither is that my mode of learning. I prefer to read docs (I was born in 1980).

This is your first mention of this hardware. I’m not familiar with it, but I was illustrating a principle. If that’s what the board does, then it’s perfect.

Right, agreed.

I hate to do this, but I actually have a master’s degree in electronic, electronical and computer engineering.

Real power is calculated as P = V_rms x I_rms x cos(phase angle), where cos(phase angle) is known as the power factor. When the power factor is 0, you have a purely capacitive or inductive load and your real power will be 0. In other words, if you are trying to combine two measurements from wildly varying points in time, the result is meaningless. The HA state machine runs at 1 second intervals, so if you are getting a voltage reading from HA and try to use that in a real-time formula, it will be wrong. That 1 second should be seen as a value in the range of 0-2 seconds, meaning your latest value is either close to 0 if you’re lucky, or nearly 2 seconds behind if you happen to have missed the 1 second interval. That’s an eternity for a signal of 50Hz. In fact, it’s impossible that this can work, because whatever value you get from HA will always be behind.

A 50Hz signal has a period of 20ms. If the value you read is 10ms behind (lagging) from where it really is, it will look like you’re generating power. If you’re off by 5ms, you will read no power.

Congrats, you’re building a random number generator. :slight_smile:

I can recommend this or a similar product: Shelly EM Gen3 – Shelly Europe.

Based on what you’re saying here a CT clamp in ESP home is never going to work - why is there even a template for it?

I did mention the adaptor btw :wink:

Anyway, if this isn’t going to give me a reading I may as well give up… But it seems to be working for other people…

Also heres a GPT summary of the video (from an 1983 child ;))

### Summary  
This video demonstrates how to build an affordable, smart CT clamp energy and power monitor using readily available components, primarily the D1 Mini microcontroller, a Mottram Labs ADC module, and an SCT-013-000 CT clamp. The creator highlights that commercial smart CT clamp solutions like the Aeotec Z-Wave home energy meter or Shelley EM are often costly and complicated to install, whereas this DIY project offers a plug-and-play solution at a fraction of the price. The Mottram Labs ADC module simplifies converting analog signals from the CT clamp into digital signals readable by the D1 Mini, allowing for seamless assembly by simply stacking the modules. To protect the device, a custom 3D-printed case is recommended, and the video creator shares their experience using an online 3D printing service for the first time.  

Programming the sensor involves configuring ESPHome with Home Assistant integration. The critical technical challenge is calibrating the sensor accurately, which requires clamping the CT sensor around a cable with a known current and adjusting the configuration accordingly. Voltage measurement is necessary for power calculation, and the video suggests either hardcoding the UK mains voltage of 240V or importing voltage sensor data from a solar inverter or another source for improved accuracy.  

Calibration is done by comparing the sensor’s readings against known current values, typically provided by a solar inverter or a main meter, and tweaking the linear calibration parameters in ESPHome’s configuration until the readings align closely. Once configured, the system provides power measurements comparable to commercial sensors, with the added benefits of low cost (£24.26 total), Wi-Fi connectivity, and customization. The creator shares all configuration files and component links in the video description and encourages viewers to try the project themselves.  

### Highlights  
- 🔧 DIY smart CT clamp energy monitor using D1 Mini and Mottram Labs ADC module  
- 💷 Cost-effective alternative to commercial smart energy meters (~£24 total)  
- 🔌 Compatible with SCT-013-000 CT clamp for easy current sensing  
- 🖨️ Custom 3D-printed case protects the device, with files available online  
- ⚙️ ESPHome and Home Assistant integration for seamless home automation  
- 🔍 Calibration essential for accurate current and power measurements  
- 🌍 Option to use real voltage readings from solar inverters or hardcoded voltage  

### Key Insights  
- 🔌 **Affordable and Accessible Hardware**: The project leverages inexpensive, off-the-shelf components such as the D1 Mini (~£3), Mottram Labs ADC module (~£3.50), and a commonly available SCT-013-000 CT clamp (~£9). This accessibility makes it an attractive option for hobbyists and homeowners who want to monitor energy usage without investing in expensive commercial solutions. The modular nature of these components also simplifies sourcing and replacement.  

- ⚙️ **Simplified Signal Conversion with Mottram Labs ADC Module**: The Mottram Labs ADC module plays a critical role by converting analog signals from the CT clamp into digital signals compatible with the D1 Mini microcontroller. Its design allows it to stack neatly onto the D1 Mini, reducing wiring complexity and assembly errors. This module substantially lowers the barrier to entry for users unfamiliar with advanced electronics or signal processing.  

- 🖥️ **ESPHome and Home Assistant Integration Enhances Usability**: By using ESPHome firmware, the device can be programmed easily and integrated directly into Home Assistant, a popular open-source home automation platform. This integration enables real-time monitoring, data visualization, and automation based on energy consumption patterns. It also allows the import of voltage data from other smart devices, improving the accuracy of power calculations.  

- 📏 **Calibration is Crucial for Accuracy**: The video stresses that the sensor must be calibrated against a known current source for reliable readings. This process involves temporarily disabling certain calibration lines in the ESPHome configuration, installing the firmware, observing the reported current, and then adjusting calibration parameters to match known values. The example shows slight deviations due to interference but encourages experimentation to fine-tune accuracy. This step is essential since CT clamps only measure current, and power calculation requires accurate voltage knowledge as well.  

- ⚡ **Voltage Measurement Strategy Impacts Accuracy**: Power is calculated as the product of current and voltage. The creator suggests two approaches: hardcoding a fixed 240V value typical in the UK or importing voltage data from an existing sensor like a solar inverter’s voltage measurement. Using real-time voltage measurements improves power accuracy but requires additional sensors or data sources. Users without voltage data can still get functional current monitoring but with less precise power readings.  

- 🖨️ **3D Printing Enables Custom Enclosures**: Protecting the hardware with a case is important for longevity and safety. Mottram Labs provides 3D printable case files tailored for their modules, allowing users with access to a 3D printer to create neat, purpose-built enclosures. For those without printers, online 3D printing services provide a convenient alternative. The video creator shares their positive experience ordering from Craft Cloud and emphasizes the professionalism and satisfaction of receiving a custom-printed case.  

- 🌐 **Open Sharing and Community Support**: The project’s configuration files, shopping links, and detailed instructions are shared openly, fostering community involvement and enabling others to replicate or improve upon the design. This open-source approach encourages innovation, troubleshooting, and customization, which are hallmarks of the maker and smart home communities.  

### Conclusion  
This project provides a practical, inexpensive, and educational approach to smart energy monitoring

Because you can measure current with it, which is what it does. You want power, so there’s some extra work and understanding involved.

Right, I don’t seem to have the best day here.

I need to make a correction: If you are going to measure resistive loads then you can use the grid RMS voltage you’re measuring. Also, for purely esistive loads the PF is 1. IRL, the PF at your home should be in the range 0.90 to 0.99 (your energy provider typically wants it to be as close as possible to 1), so your error should be in that range (0-10%).

The gross tangent I need to correct as that the AC voltage you have isn’t the voltage signal itself you’re measuring, so my lead/lag explanation isn’t relevant (but the explanation itself is correct).

This isn’t actually what you’re getting from HA:

I think @orange-assistant got you on the right path, so proceed with fixing your calibration.

From a quick couple of searches, if your specific board has jumpers, check that those are set correctly.

Have a look at this topic too, since it looks closely related: Setting up a current sensor with d1_mini.

1 Like

The grid would be happy, but afaik only big/business customers are forced to apply extra power factor correction. Private Individuals nowadays often have (mostly to switching power supplies) power factors much lower… Us for example goes lower as 0.5 :point_down:

Hence a current meter would be totally useless to get anything meaningful measured - hence we use a power meter for that task (which btw. also includes a CT!) :ok_hand:

Yeah, indeed, precisely because large industries (mines, factories) have massive inductive loads.

Interesting… I really thought the average household should have a fairly high power factor, except for times big motors are running (usually the culprits), like washing machines spinning up, swimming pool pumps and also woodworking equipment. I have a digital power meter for the whole house in the distribution box, and it give my own PF as 0.3 (at the moment, and we’re not running anything big). I haven’t so far really paid attention to my own PF much. That said, my country’s energy supplier isn’t exactly known for their service, after decades of scheduled load shedding.

EDIT: I do have a hybrid (grid-tied) inverter setup with solar, and the inverter is of the switching type (Sunsynk). I need to do some research to understand what the effects might be. The inverter is reporting my PF as exactly 1 (well, to some level of precision, I would assume).

Yup, a typical way for single phase supplies is to have a CT clamp, combined with a voltage metering circuit at the same point in order to take the measurement at the same time. There are more ways, and other ways for 3-phase supplies, but it’s not really something I’m an expert in (I’ve never worked commercially in this area).

1 Like

Don’t give up. They do work. I’ve had one - identical to yours as far as I can tell (YHDC 100A/50mA SCT-013-000, the Mottram MLP191020 board, and an ESP8266) and it all works fine. I’ve got mine providing power-consumption figures for a heat-pump, clamped to the consumer-unit live feed to that - so the numbers are quite high (anywhere up to 7kW or more and possibly higher at full chat), and thus they’re well above that 100W minimum you’ve discovered.

The nub of it all though, is those calibration lines. Get those wrong, and it can be wildly inaccurate, because they’re the root of all the maths later in the process.

BTW don’t worry about the burden resistor - if you’ve definitely got a CURRENT version of the CT clamp (and it appears you have), then the burden resistor is on the Mottram board by default. The only consideration is if your clamp is a VOLTAGE kind (in which case it’ll say V instead of mA/A on it), in which case it would already have a burden resistor inside it, and then the one on the Mottram board would be redundant (in fact, worse; it would be doubling the effect), and would need cutting out. But I think you’re ok as-is, from what you’ve said.

To calibrate, you’re going to need to find some reasonably punchy loads to drag a few KNOWN amps down through the clamp, while logging (with the default config file) and see what numbers you’re getting. There’s more data here on how to go about it - CT Clamp Current Sensor - ESPHome - Smart Home Made Simple

In my case, I was able to clamp to a couple of reasonably accurate sources (though I confess I forget what they were now), which I had already measured by other methods and thus had a calibration yardstick. I ended up with the following filter lines in the yaml:

    filters:
      - calibrate_linear:
        - 0.0 -> 0.0
        - 0.001 -> 0.0
        - 0.015 -> 4.66
        - 0.029 -> 9.06

I also cheated with regards to the conversion of the current (amps) to final output Watts for Home Assistant, and just used a nominal 240 V in the calculation:

#      - lambda: return x * id(grid_voltage).state;
      # hardcoded nominal 240V
      - lambda: return x * 240.0;

Quick and dirty, I know, but good enough for government work (as they say). It gives me numbers that correspond accurately enough for my domestic needs, and gaining a general idea of how much power my heat-pump is yanking, and I can compare that with my grid-import, solar-generation and battery-discharge figures in realtime to work out whether the heat-pump is costing me at peak rate, or playing nice and running from sunshine or stored cheap-rate 'leccy. I wouldn’t want to use that code on a space-mission, maybe, but it’s plenty enough for my needs!

In short, it does work - well enough - so don’t give up. Your biggest pain is going to be finding some chonky enough loads of known current-draw (or having a previously calibrated clamp or other measurement readout) to calibrate this one. If you’ve got any kind of solar generation (with an inverter that shows its AC current output to crib from), or access to the line side of an EV charger with a readout, then these will help, but worst case, you could get something from a kettle or an electric fire that might be enough to get you into the ballpark.

Just remember the safety issues involved with ‘untethered CT clamps’ if you’re dealing with highly loaded wires to calibrate; it’s easy to rush and forget. Always ensure the CT clamp is plugged-in/terminated in circuit, and not flopping about loose, nor in your hand, BEFORE turning the power on down the wire being measured! I’ve never seen it first-hand, and my electrician seemed to think it was a ‘meh’ worry, but I’ve heard it can be dangerous or at the very least ‘uncomfortable’, if you’re touching the clamp outputs (more info here - "safe" handling of CTs (Current Transformers)? | Archived Forum )

Good luck!

2 Likes

Thank you - this has been sitting on a shelf since my last post - you’ve inspired me to revisit it when i get time!

2 Likes