As discussed in our Guide Sonoff Smart Switch LAN Control without Internet, Here is how to prepare WiFi Smart Socket: Sonoff S20 for installing our opensource firmware to control it locally without internet. Follow the steps below to connect the device with PC.
Note: Always unplug the Sonoff device from AC Power Source before start working with it.
Unscrew the three screws found on the rear side of Sonoff S20 using screw driver and lift the upper lid. Also remove the screws holding the PCB fixed inside. Take the PCB out carefully without pulling the wires connected to it.
Install a male or female header on holes given for programming the device by soldering it permanently for a firm connection. Header without soldering will result in loose connection and uploading may fail.
Fix the PCB inside enclosure and tighten the screws. Let’s have a look on to the pinout. First pin starts with arrow sign is VCC followed by RX, TX and GND (GND is first pin from LED side of header). Connect FTDI according to the following combinations.
Press button present on PCB and Plug the FTDI in to PC. Now micro-controller present in our Sonoff S20 i.e. ESP8266 will start in programming mode.
Open Arduino IDE and go to File > Examples > ESPMetRED > Examples > Sonoff_S20 (Choose any Sonoff Sketch). Change WIFI_SSID, WIFI_PASSWORD, MQTT_SERVER, MQTT_USER and MQTT_PASSWORD according to your own.
const char* WIFI_SSID = "YOUR_WIFI_NAME";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
const char* MQTT_SERVER = "SERVER_IP_ADDRESS";
const char* MQTT_USER = "USER_NAME_SET_IN_MOSQUITTO_BROKER";
const char* MQTT_PASSWORD = "PASSWORD_SET_IN_MOSQUITTO_BROKER";
Choose “Generic ESP8266 Module” under Tools > Board. Change Flash Mode to “DOUT”, Flash Size to “1M(64K SPIFFS)” and choose your Port. Click on Sketch > Verify/Compile to compile the sketch.
Once your Sonoff device starts into programming mode, upload the sketch on Arduino IDE by visiting Sketch > Upload. It will take some time to upload the firmware. One it’s done uploading, disconnect the device from PC and reassemble it according to the Step D.
Reassemble Sonoff S20 by joining both lids carefully by holding lid with button on side below to avoid button fall off and tighten the screws back.
Proceed the Step E in our Guide Sonoff Smart Switch LAN Control without Internet.