Another power monitoring solution (UK) - Mottramlabs CT clamp board

With the advent of the energy dashboard I started to look around at the various solutions to get data into HA. My meter (UK) is a smart meter with a remote display, but I couldn’t find any access to the data that was available to HA. I use ESPHome on all my smart devices where possible and ideally I wanted an ESPHome based solution, however I was close to going for the Shelley EM when I tripped over an excellent solution.

The Mottram Labs ESP8266 - 4 Channel Mains Current Sensor uses an ESP 8266 with 4 CT clamps via an ADS1115 A/D converter.
PIX201077

Although no ESPHome yaml is provided, all the key components are supported by ESPHome and there is a git with firmware source code that has all the necessary GPIO details. I’ve used the ADS1115 in other projects so was very confident ESPHome would be perfect. Sure enough within a few minutes of receiving it and plugging in a D1 Mini and CT clamp I had energy monitoring in HA.

You obviously need to add a D1 Mini, 12V PSU, CT Clamp(s) and an enclosure but at £12.99 for 4 Channels it’s pretty cost effective.

Ebay Link
Pastebin for Esphome YAML

Unlike a lot of the other CT solutions that board does not appear to measure the AC voltage (required for power measurements). How are you accomplishing that?

I have a Voltage measuring plug and have taken any number of readings over the years which have been pretty consistent at 240v for me. So not dynamic and hard coded. Good enough for “info” based monitoring I think at the moment.

Just had a look at my voltage for the past 24hrs. There’s about 18V difference between the highest and lowest voltage. At 240V nominal (though I think we are supposed to be 230V now) that’s about +/-4% so I guess it’s not that bad.

Just realised I have about 6 power monitoring plugs in HA all recording voltage. I’ll probably average them inside HA and then monitor that voltage back in the Energy Monitor ESP.

1 Like

Average of Power monitoring plug voltages in HA…(unavailable entities are ignored in the averaging)

  - platform: min_max
    type: mean
    name: average_voltage
    entity_ids:
      - sensor.plug_01_energy_temp_voltage
      - sensor.plug_02_energy_temp_voltage
      - sensor.plug_03_energy_temp_voltage
      - sensor.plug_04_energy_temp_voltage
      - sensor.plug_05_energy_temp_voltage
      - sensor.plug_06_energy_temp_voltage
      - sensor.plug_07_energy_temp_voltage
      - sensor.plug_08_energy_temp_voltage

ESPHome has a HA sensor to track…

  - platform: homeassistant
    name: "Voltage"
    #ESPHome ID
    id: average_voltage
    entity_id: sensor.average_voltage
    internal: true

Which can then be used in the Watts calculation…

sensor:
# Channel 1
  - platform: ct_clamp
    sensor: ads1115_1_a0
    id: current_ch1
    name: "${esp_id} Current Ch 1"
    update_interval: 30s
    # Needs adjusting for individual Deployment
    filters:
      - calibrate_linear:
        - 0 -> 0
        - 0.03 -> 3.45
        - 0.11 -> 16.6
    # When Current updates, update Watts
    on_value:
      then:
        - sensor.template.publish:
            id: watts_ch1
            # Local Voltage read from HA average sesnor. 
            state: !lambda 'return id(current_ch1).state * id(average_voltage).state;'

To use in the HA Energy Dashboard need a total_daily_energy sensor for each channel.

sensor:
# Energy Sensors (kWh) for HA Dashboard
  - platform: total_daily_energy
    name: ${esp_id} Total kWh Ch1
    power_id: watts_ch1
    filters:
      - multiply: 0.001
    unit_of_measurement: kWh

Are these bi-directional? Looking to use CT clamp in position 1 over the incoming live supply, is there a way to configure for the grid consumption and grid return in the Energy dashboard?

Just bought a couple of these boards! Just awaiting delivery of the clamps and will start testing! However initial impressions seem positive!

I bought the 1 channel version of this a while back but couldnt get it to differentiate between import and export.

Has anyone else?

Did you message the creator? I’ve sent him a couple of messages and he’s been very helpful! I am hopefully going to get testing now all the clamps have arrived

I did but had no reply, did you contact him via the email on his site?

Thanks

Reading your initial post, i dont think its possible to read import and export through a CT Clamp

Just bought one of these but went for v2 of the board (the blue one) … Not had it delivered yet but intrigued

Let me know how you get on! I went for the V3 (green coloured) board and have yet to really start working on them! Assume you are flashing with ESPHome?

I’ve now got 2 connected up and reading, they definitely cant differentiate from incoming and outgoing, so had to get creative. I’m now trying to create a sensor that i can use in the energy dashboard to tell me how much i’m exporting.

template:
  - sensor:             
      - name: "Grid Usage"
        unique_id: grid_usage
        device_class: energy
        unit_of_measurement: 'kWh'
        state_class: measurement
        state: >
          {% set pv_generated = states('input_number.sensor.measured_pv_power_2') | float(0) %}
          {% set mains_power = states('sensor.measured_grid_power_2') | float(0) %}
          {{ ((pv_generated - mains_power) ) | round(1, default=0) }}
                     
        availability: >
          {{ 
            states('input_number.sensor.measured_pv_power_2') | float(none) != none and
            states('sensor.measured_grid_power_2') | float(none) != none
          }} 

For some reason i cant use the above in the energy dashboard BUT if i add this to the dev template it actually calculates fine.

          {% set pv_generated = states('input_number.sensor.measured_pv_power_2') | float(0) %}
          {% set mains_power = states('sensor.measured_grid_power_2') | float(0) %}
          {{ ((pv_generated - mains_power) ) | round(1, default=0) }}e code here

Can anyone see what im doing wrong

I customised the code form someone else but now cant find the original post lol.

Afternoon all,

I have a few of the MottramLabs 4-way boards, have successfully calibrated them, but only needed to use them for the one-way monitoring of WATTS at various points in my house.

Now I have a battery system, I would like to monitor both positive/negative values - it sounds like it is possible with this board.

At the minute, I am looking for an Arduino Sketch to do this as I have various “things” pumping to an influxdb, so would like to try that first.

Has anyone seen any Sketches or instructions on how to do this?

Many thanks, Neil.

Hi, Good to see another user of this MottramLabs 4 way boards! Out of interest, what are your calibrations?

I am going to embark on something similar soon regards to Solar Generation & Battery, as i purchased 3 of these boards

Has anyone use this with these boards? Or know where it connects to on the board?

What coils did you use? I gues the desing was made for the 100a/50ma ones.
I only need a max current of 30A , so i was thinking of using the lower curent coils to increase the resolution, but they give 1V instead of 50mA.

ads_gain: "2.048"

This is the default ref voltage. Can esphome also write the register to change this Vref?

I havnt used this board, however I did buy a ZMPT101B board and integrated this with a WemosD1 Mini. Works great!

I didnt buy the board attached as it wasn’t in stock at the time!

1 Like