Gosund SP111 with ESPHome - Power Measurement

Hey guys!

I’ve a question about my Gosund SP111 flashed with ESPHome.

This is my current configuration:

substitutions:
  plug_name: Waschmaschine
  # Higher value gives lower watt readout
  current_res: "0.00260"
  # Lower value gives lower voltage readout
  voltage_div: "940"

esphome:
  name: waschmaschine
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "Le_SSID"
  password: "Le_PW"
  
  manual_ip:
  # Set this to the IP of the ESP
    static_ip: Le_IP
  # Set this to the IP address of the router. Often ends with .1
    gateway: Le_GW
  # The subnet of the network. 255.255.255.0 works for most home networks.
    subnet: 255.255.255.0

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "${plug_name} Hotspot"
    password: "Le_PW"



captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:
  password: "Le_API"

ota:
  password: "Le_OTA"
  
# Enable Web server
web_server:
  port: 80

time:
  - platform: homeassistant
    id: homeassistant_time

sensor:
  - platform: wifi_signal
    name: "${plug_name} - WiFi Signal"
    update_interval: 6s
  
  - platform: uptime
    name: "${plug_name} - Uptime"
    icon: mdi:clock-outline
    update_interval: 60s
    
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO05
    cf1_pin: GPIO14
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    
    current:
      name: "${plug_name} - Ampere"
      unit_of_measurement: A
      accuracy_decimals: 3
      icon: mdi:flash-outline
      
    voltage:
      name: "${plug_name) - Volt"
      unit_of_measurement: V
      accuracy_decimals: 1
      icon: mdi:flash-outline
      
    power:
      name: "${plug_name} - Watt"
      unit_of_measurement: W
      id: "${plug_name}_Wattage"
      icon: mdi:flash-outline
      
    change_mode_every: 4
    update_interval: 3s
    
  - platform: total_daily_energy
    name: "${plug_name} - Tagesverbrauch"
    power_id: "${plug_name}_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:clock-alert  

text_sensor:
  - platform: version
    name: "${plug_name} - ESPHome Version"
  
status_led:
  pin:
    number: GPIO02
    inverted: True 
    
binary_sensor:
  - platform: gpio
    id: button
    internal: true
    pin:
      number: GPIO13
    on_state:
      - switch.toggle: relay

output:
  - platform: gpio
    pin: GPIO00
    inverted: true
    id: led

switch:
  - platform: gpio
    pin: GPIO15
    id: relay
    name: '${plug_name} - Schalter'
    icon: mdi:power-socket-eu
    on_turn_on:
      - output.turn_on: led
    on_turn_off:
      - output.turn_off: led

In HA i can see the sensors for volt, ampere and watt, but only the watt one is working for now. (Volt and Ampere are both always zero)

First question: How am i able to get them working? I don’t really know what to change in my config.

Second one: Is there a way to check, if the sensor outputs are correct? I tested the watt sensor with a Hue White and Color E27 (Internet says it needs about 9.5-10W) and i got an output with my config about 9.5W (100% brightness, cold light (the concentration scene inside the Hue App, according to some posts this one need the most power)).

Hope someone is able to help me with this one :slight_smile:

Greetings

1 Like

Howdy there,

I don’t have a specific answer for you - in fact, I’m surprised that both voltage and ampere sensors show zero when the power sensor is accurate. I assume you are verifying the power by looking at the entities on your developer page?

I suppose you could leave the espHome console up to the device, where you should see it spitting out numbers.

There are power measurement devices that you can use to calibrate/verify… Kill-a-watt is one of them. I check it out from my local library.

Hey,

Yeah both, volt and ampere, show zero and i don’t know why.

Yep i’m looking at the entities, but also in the ESPHome logs, volt and ampere are always zero, but at least the volt sensor should be around 230V, because the plug is on, so it’s consuming a little bit of electricity, i don’t get it why that’s not working.

Ok thanks for that tip, i’ll look for a power measurement device, just to check if it the numbers are correct.

As an experiment, you could try altering your current_res and voltage_div numbers, but again, it strikes me as strange that you are able to get correct power number while those are zero.

Hello,

I have exactly the same ‘problem’.

I have te same issue, same plug. do you managed to fix it?

*Edit. Got It!

Change this line:

cf1_pin: GPIO14

From GPIO14 to 04. Must be a typo i guess

So.make it this:

cf1_pin: GPIO04

I did and now have values for volts and amps. Where my watts dont need a calibration with these settings, amps and volts do. So thats for tomorrow!

3 Likes

I have this working, but a far too high voltage…

What can be wrong?


esphome:
  name: wallswitch02
  platform: ESP8266
  board: esp8285

wifi:
  ssid: "IOTDOM"
  password: "nono"
  use_address: 192.168.6.21

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Wallswitch01 Fallback Hotspot"
    password: "nono"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

time:
  - platform: homeassistant
    id: homeassistant_time
    
substitutions:
  plug_name: wallswitch02
  # Higher value gives lower watt readout
  current_res: "0.00260"
  # Lower value gives lower voltage readout
  voltage_div: "940"

# Enable Web server
web_server:
  port: 80

sensor:
  - platform: wifi_signal
    name: "${plug_name} - WiFi Signal"
    update_interval: 6s
  
  - platform: uptime
    name: "${plug_name} - Uptime"
    icon: mdi:clock-outline
    update_interval: 60s
    
  - platform: hlw8012
    sel_pin:
      number: GPIO12
      inverted: True
    cf_pin: GPIO05
    cf1_pin: GPIO04
    current_resistor: ${current_res}
    voltage_divider: ${voltage_div}
    
    current:
      name: "${plug_name} - Ampere"
      unit_of_measurement: A
      accuracy_decimals: 3
      icon: mdi:flash-outline
      
    voltage:
      name: "${plug_name} - Volt"
      unit_of_measurement: V
      accuracy_decimals: 1
      icon: mdi:flash-outline
      
    power:
      name: "${plug_name} - Watt"
      unit_of_measurement: W
      id: "${plug_name}_Wattage"
      icon: mdi:flash-outline
      
    change_mode_every: 4
    update_interval: 3s
    
  - platform: total_daily_energy
    name: "${plug_name} - Dagverbruik"
    power_id: "${plug_name}_Wattage"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
    unit_of_measurement: kWh
    icon: mdi:clock-alert 

text_sensor:
  - platform: version
    name: "${plug_name} - ESPHome Version"
  
status_led:
  pin:
    number: GPIO02
    inverted: True 
    
binary_sensor:
  - platform: gpio
    id: button
    internal: true
    pin:
      number: GPIO13
    on_state:
      - switch.toggle: relay

output:
  - platform: gpio
    pin: GPIO00
    inverted: true
    id: led

switch:
  - platform: gpio
    pin: GPIO15
    id: relay
    name: '${plug_name} - Switch'
    icon: mdi:power-socket-eu
    on_turn_on:
      - output.turn_on: led
    on_turn_off:
      - output.turn_off: led

Have you already calibrated the plug? Or is this the out of the box measurement

Out of the box directly flashed espurna and then esphome… how should I calibrate?

OMG… it’s never easy…

Is there a “usable” config for “all gosunds sp111”?

Playing with the

substitutions:
voltage_div:

Gives me correcter values for Voltage.

On other thing…

Pressing the button locally only does a “holding on- no holding off” how can that be changed?

EDIT:
I meant… I have this in:
restore_mode: RESTORE_DEFAULT_ON

That works when power was lost and it turns on when plugging in. But no led is active then.

EDIT2:
foun it:

    #on_state:
    on_press:
      - switch.toggle: relay