Gosund SP111 v1.1 or Nous A1 power montor/switch plug

April 7, 2021

Removing your smart switch, or at least IOT device from the cloud. Not sure why everyone keeps calling them smart, there's nothing smart about these devices. What wasn't clear to me in the beginning was that you needed to calibrate every sensor. See not so smart after all.

Requirements

  • FTDI USB To TTL 3.3V & 5.5V Serial Adapter + Cable
  • esptool
  • Jumper wires
  • Firmware binary

Generate firmware with ESPHome

substitutions:
devicename: "whatever"
upper_devicename: "Gosund SP111"
# Higher value gives lower watt readout
current_res: "0.00280"
# Lower value gives lower voltage readout
voltage_div: "775"
wifi_ssid: "wifi_ssid"
wifi_pass: "wifi_password"
fallback_pass: "wifi_fallback_password"
api_pass: "api_password"
ota_pass: "ota_password"

esphome:
name: $devicename
platform: ESP8266
arduino_version: 2.5.1
board: esp8285

# Enable logging
logger:
baud_rate: 0

# Enable Home Assistant API
api:
password: "${api_pass}"

# Enable over the air updates
ota:
password: "${ota_pass}"

wifi:
ssid: "${wifi_ssid}"
password: "${wifi_pass}"

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

# see: https://esphome.io/components/time.html
time:
- platform: homeassistant
id: homeassistant_time

# Enable Web server
web_server:
port: 80

text_sensor:
- platform: version
name: "${devicename} - Version"
icon: mdi:cube-outline

binary_sensor:
- platform: status
name: "${devicename} - Status"
device_class: connectivity

# toggle relay on/off
- platform: gpio
pin:
number: GPIO13
mode: INPUT_PULLUP
inverted: True
id: "${devicename}_button_state"
on_press:
- switch.toggle: button_switch

sensor:
- platform: wifi_signal
name: "${devicename} - Wifi Signal"
update_interval: 60s
icon: mdi:wifi

- platform: uptime
name: "${devicename} - Uptime"
update_interval: 60s
icon: mdi:clock-outline

- platform: total_daily_energy
name: "${devicename} - Todays Usage"
power_id: "power_wattage"
filters:
# Multiplication factor from W to kW is 0.001
- multiply: 0.001
unit_of_measurement: kWh
icon: mdi:calendar-clock

- platform: adc
pin: VCC
name: "${devicename} - VCC Volt"
icon: mdi:flash-outline

- platform: hlw8012
sel_pin:
number: GPIO12
inverted: True
cf_pin: GPIO05
cf1_pin: GPIO04
change_mode_every: 4
current_resistor: ${current_res}
voltage_divider: ${voltage_div}
update_interval: 3s

current:
name: "${devicename} - Ampere"
unit_of_measurement: A
accuracy_decimals: 3
icon: mdi:current-ac

voltage:
name: "${devicename} - Volt"
unit_of_measurement: V
accuracy_decimals: 1
icon: mdi:flash-outline

power:
name: "${devicename} - Watt"
unit_of_measurement: W
id: "power_wattage"
icon: mdi:gauge

status_led:
pin:
number: GPIO00
inverted: True
id: led_red

output:
- platform: gpio
pin: GPIO02
inverted: True
id: led_blue

switch:
- platform: template
name: "${devicename} - Switch"
icon: mdi:power
optimistic: true
id: button_switch
turn_on_action:
- switch.turn_on: relay
turn_off_action:
- switch.turn_off: relay
- platform: gpio
pin: GPIO15
id: relay
on_turn_on:
- output.turn_on: led_blue
on_turn_off:
- output.turn_off: led_blue

Wireing diagram

FTDI SP111
3.3v 3.3v
GND GND
RX TX
TX RX
GND GPIO2

Board layout

My board says SP111 v1.1

Pinout

Backup current binary from chip

sudo esptool --port /dev/ttyUSB0 --baud 115200 read_flash 0x00000 0x100000 backup.bin

Erasing chip

Was not supported for this particular chip, at least for me. :p

sudo esptool --port /dev/ttyUSB0 --baud 115200 erase_flash

Writing binary to chip

sudo esptool --port /dev/ttyUSB0 --baud 115200 write_flash -fs 1MB -fm dout 0x0 firmware.bin