Flashing Sonoff POW R3 to ESPHome

Good morning. I couldn’t find any information on how to hack a Sonoff POW R3 to make it an ESPHome device. Can someone please help me?
Thank you

Have you had any joy with this? I have a POW R3 on order and also want to intigrated with HA using ESPHome (I am migrating devices to ESPHome to avoid having to run a seperate MQTT server).

Almost… for some reason the switch want work, and the V showing 15v - but its a start, to get you online.

esphome:
name: sonoffvpkids

esp32:
board: nodemcu-32s

Enable logging

logger:

wifi:
ssid: xxxxx
password: xxxxx

Optional manual IP

manual_ip:
static_ip: x.x.x.x
gateway: x.x.x.x
subnet: 255.255.255.0
dns1: x.x.x.x

Enable fallback hotspot (captive portal) in case wifi connection fails

ap:
ssid: “sonoffvpkids Fallback Hotspot”
password: “xxxxxxxxxxxxx”

captive_portal:

Enable Home Assistant API

api:
password: “xxxxx”

ota:
password: “xxxxx”

uart:
rx_pin: GPIO16
baud_rate: 4800

sensor:

  • platform: cse7766
    update_interval: 2s
    current:
    name: sonoffvpkids Current
    id: a_sensor
    voltage:
    name: sonoffvpkids Voltage
    id: v_sensor
    power:
    name: sonoffvpkids Power
    id: w_sensor
    on_value_range:
    - above: 4.0
    then:
    - light.turn_on: switch_led
    - below: 3.0
    then:
    - light.turn_off: switch_led
    energy:
    name: sonoffvpkids Energy
    id: wh_sensor

output:

  • platform: ledc
    id: led
    pin:
    number: GPIO18
    inverted: True

light:

  • platform: monochromatic
    id: switch_led
    output: led
    internal: True
  • platform: status_led
    id: wifi_status_led
    internal: True
    pin:
    number: GPIO05
    inverted: True

switch:

  • platform: template
    name: sonoffvpkids sw
    optimistic: true
    id: relay_1
    lambda: |-
    if (isnan(id(w_sensor).state)) {
    return {};
    } else if (id(w_sensor).state > 4) {
    // Running
    return true;
    } else {
    // Not running
    return false;
    }
    turn_off_action:
    • switch.turn_on: relay_off
      turn_on_action:
    • switch.turn_on: relay_on
  • platform: gpio
    restore_mode: ALWAYS_OFF
    internal: true
    id: relay_off
    pin: GPIO04
    on_turn_on:
    • switch.turn_on: relay_off
    • delay: 500ms
    • switch.turn_off: relay_off # bi-stable relay so no need to keep on.
    • light.turn_off: switch_led
      interlock: [relay_on]
  • platform: gpio
    restore_mode: ALWAYS_OFF
    internal: true
    id: relay_on
    pin: GPIO02
    on_turn_on:
    • switch.turn_on: relay_on
    • delay: 500ms
    • switch.turn_off: relay_on # bi-stable relay so no need to keep on.
    • light.turn_on: switch_led
      interlock: [relay_off]
  • platform: restart
    name: sonoffvpkids Restart
2 Likes

Not sure if this is helpful, but I recently set up a Sonoff POW R3 with ESPHome for use with a hot water tank immersion heater.

Took various bits of code from various sources locally and online. In my case, I’ve added 3 Dallas temperature sensors connecting to GPIO4 so I can monitor the tank temperature.

I’m using this to utilise spare solar power after the car is charged. (better than selling to the grid for 4p a kWh :stuck_out_tongue: )

I initially used GPIO15 for the temperature sensors but that stopped everything from working.

substitutions:
  esphome_name: hotwatersonoff
  esphome_friendly_name: Hot Water Sonoff

esphome:
  name: ${esphome_name}
  friendly_name: Hot Water Heater Sonoff

esp8266:
  board: esp8285

# Enable logging
logger:
  baud_rate: 0

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxx"

ota:
  password: "xxxxxxxxx"

wifi:
  output_power: 18db
  power_save_mode: light
  ssid: !secret wifi_ssid
  password: !secret wifi_password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Hot-Water-Heater-Sonoff"
    password: "xxxxxxxxx"

captive_portal:

dallas:
  - pin: GPIO4

# Enable web server
web_server:
  port: 80

time:
  - platform: homeassistant
    timezone: Europe/London

#GPIO0 Button (inverted)
#GPIO12 Relay and Red LED
#GPIO13 Blue LED (inverted)


uart:
  rx_pin: RX
  baud_rate: 4800

binary_sensor:
  - platform: gpio
    pin:
      number: GPIO0
      mode: INPUT_PULLUP
      inverted: True
    name: "${esphome_friendly_name} Button"
    on_press:
      - switch.toggle: fakebutton

switch:
  - platform: template
    name: "Hot Water Relay"
    optimistic: true
    id: fakebutton
    turn_on_action:
    - switch.turn_on: relay
    - light.turn_on: led
    turn_off_action:
    - switch.turn_off: relay
    - light.turn_off: led
  - platform: gpio
    id: relay
    inverted: yes
    pin: GPIO12
    restore_mode: RESTORE_DEFAULT_ON

output:
  - platform: esp8266_pwm
    id: pow_blue_led
    pin:
      number: GPIO13
      inverted: True

light:
  - platform: monochromatic
    name: "${esphome_friendly_name} Blue LED"
    output: pow_blue_led
    id: led
    internal: true

sensor:
  - platform: wifi_signal
    name: "${esphome_friendly_name} WiFi Signal"
    update_interval: 60s
  - platform: uptime
    name: "${esphome_friendly_name} Uptime"
  - platform: cse7766
    update_interval: 2s
    current:
      name: "${esphome_friendly_name} Current"
    voltage:
      name: "${esphome_friendly_name} Voltage"
    power:
      name: "${esphome_friendly_name} Power"
    energy:
      name: "${esphome_friendly_name} Energy"
  - platform: dallas
    address: 0xb60000001284c428
    name: "${esphome_friendly_name} Temperature Sensor 1"
    id: temp_1
    icon: "mdi:water-thermometer"
    filters:
      - filter_out: nan
  - platform: dallas
    address: 0x4f00000012821c28
    name: "${esphome_friendly_name} Temperature Sensor 2"
    id: temp_2
    icon: "mdi:water-thermometer"
    filters:
      - filter_out: nan
  - platform: dallas
    address: 0xb10000001483f228
    name: "${esphome_friendly_name} Temperature Sensor 3"
    id: temp_3
    icon: "mdi:water-thermometer"
    filters:
      - filter_out: nan
  - platform: template
    name: "{esphome_friendly_name} Average Tank Temperature"
    icon: "mdi:water-thermometer"
    unit_of_measurement: "°C"
    lambda: |-
      return (id(temp_1).state + id(temp_2).state + id(temp_3).state)/3;
    update_interval: 60s
  - platform: template
    name: "{esphome_friendly_name} Max Tank Temperature"
    icon: "mdi:water-thermometer"
    unit_of_measurement: "°C"
    lambda: |-
      return ((id(temp_1).state > id(temp_2).state) ? ((id(temp_1).state > id(temp_3).state) ? id(temp_1).state : id(temp_3).state) : (id(temp_2).state > id(temp_3).state) ? id(temp_2).state : id(temp_3).state);
    update_interval: 60s
  - platform: template
    name: "{esphome_friendly_name} Min Tank Temperature"
    icon: "mdi:water-thermometer"
    unit_of_measurement: "°C"
    lambda: |-
      return ((id(temp_1).state < id(temp_2).state) ? ((id(temp_1).state < id(temp_3).state) ? id(temp_1).state : id(temp_3).state) : (id(temp_2).state < id(temp_3).state) ? id(temp_2).state : id(temp_3).state);
    update_interval: 60s
    

Hi Rich/Thansen1980 , can any of you post the clean configuration that will work with pow r3 (25A) for esp home

Thank you so much :heartbeat:

+1, any clean fully working config?