User Tools

Site Tools


projects:sonoff-s20-esp8266-wifi-smart-socket

Sonoff S20 ESP8266 WiFi Smart Socket

Description Switch power socket over
Project Owner Trinitor
Project Start 2017-09-31
Status in progress

Overview

It would be very convenient to turn on the lights in the base automatically when someone opens it.
There are some smart sockets out there, but most of them connect to external servers and require some special kind of software.
If the vendor decides to shut down their server we couldn't use our devices anymore.

The Sonoff S20 uses a ESP8266 and can be flashed with alternative firmware.
Depending on the firmware it will then support other protocols.
The device is also relatively cheap.

The ESP8266 GPIO 12 is connected to the relay (1=on, 0=off).
The GPIO 0 is connected to the push button.

Prepare Hardware

  • Unplug the device from power!
  • Check the FTDI jumper for voltage.
    • must be set to 3.3V
  • Connect the FTDI converter
    • Sonoff S20 connections
Sonoff FTDI
PIN 1 - VCC PIN 3 - VCC
PIN 2 - RX PIN 4 - TX
PIN 3 - TX PIN 5 - RX
PIN 4 - GND PIN 1 - GND

Arduino IDE Config

Tasmota Firmware

git clone https://github.com/arendst/Sonoff-Tasmota.git
edit settings in Sonoff-Tasmota/sonoff/user_config.h

#define STA_SSID1              "yourSSID1"
#define STA_PASS1              "12345678"
#define STA_SSID2              "yourSSID2"
#define STA_PASS2              "12345678"
#define SYS_LOG_HOST           "syslog"
#define OTA_URL                "http://webserver:80/api/arduino/" PROJECT ".ino.bin"
#define MQTT_HOST              "yourMQTTserver"
#define MQTT_USER              "username"
#define MQTT_PASS              "12345678"
#define WEB_PASSWORD           "12345678"
#define FRIENDLY_NAME          "power02"

ESP8266 Board config

To gain as much code space as possible from the available 1M flash memory Tasmota provides a linker file without SPIFFS area

cp Sonoff-S20-Tasmota/Sonoff-Tasmota/arduino/version\ 2.3.0/tools/sdk/ld/eagle.flash.1m0.ld ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/tools/sdk/ld
cp Sonoff-S20-Tasmota/Sonoff-Tasmota/arduino/version\ 2.3.0/boards.txt ~/Library/Arduino15/packages/esp8266/hardware/esp8266/2.3.0/boards.txt

Flash

  • Upload Using: Serial
  • Flash Mode: DOUT
  • Flash Frequency: 40MHz
  • CPU Frequency: 80MHz
  • Flash Size: 1M (no SPIFFS)
  • Debug Port: Disabled
  • Debug Level: None
  • Reset Method: ck
  • Upload Speed: 115200
  • Port: Your COM port connected to sonoff
projects/sonoff-s20-esp8266-wifi-smart-socket.txt · Last modified: 2017-11-21 19:34 by trinitor