Skip to main content

SONOFF S31

One of the top favorite smart plugs. Easy to disassemble with a screw driver, exposed pin headers to the ESP8266, button on GPIO 0, and excellent power monitoring! You can even flash it without soldering utilizing a USB TTL adapter and dupont test clips known as clippy bois - see the pics section below.

Purchase on Amazon Amazon
Purchase on iTead iTead
Purchase on Aliexpress Aliexpress Purchase on CloudFree CloudFree

Video Setup

Tasmota Template

None needed as it is built into TASMOTA. Click Configuration -> Configure Module -> Pick SONOFF S31 and hit Save.

alt text

TASMOTA Settings

The power calibration for the S31 is usually pretty close on default but it can be fine tuned via Tasmota Calibration Procedure

GPIO Layout

GPIOComponentDescription
GPIO00Button 1
GPIO01CSE7766 TxPower monitoring chip
GPIO03CSE7766 RxPower monitoring chip
GPIO12Relay1Relay for Load
GPIO13Led_i_1Onboard LED

ESPHome YAML

# Basic Config
esphome:
name: sonoff_s31
platform: ESP8266
board: esp01_1m

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

logger:
baud_rate: 0 # (UART logging interferes with cse7766)

api:
ota:

uart:
rx_pin: RX
baud_rate: 4800

binary_sensor:
- platform: gpio
pin:
number: GPIO0
mode: INPUT_PULLUP
inverted: True
name: "Sonoff S31 Button"
on_press:
- switch.toggle: relay
- platform: status
name: "Sonoff S31 Status"

sensor:
- platform: cse7766
current:
name: "Sonoff S31 Current"
accuracy_decimals: 1
voltage:
name: "Sonoff S31 Voltage"
accuracy_decimals: 1
power:
name: "Sonoff S31 Power"
accuracy_decimals: 1
id: my_power
- platform: total_daily_energy
name: "Sonoff S31 Daily Energy"
power_id: my_power

switch:
- platform: gpio
name: "Sonoff S31 Relay"
pin: GPIO12
id: relay
restore_mode: ALWAYS_ON

status_led:
pin:
number: GPIO13
inverted: True

Pics

alt text alt text alt text alt text alt text alt text alt text

alt text