To flash a Sonoff S20, solder the pins on the left of the push button, connect your USB-to-Serial convertor (RobotDyn CH340G in this case) to the headers like in the image below (from top to bottom, GND, TX, RX, 3.3v VCC), push Sonoff button while plugging in your USB-to-Serial convertor in your PC and then release the push button after a few seconds (check out this link and that one). Don't forget about the SPIFFS setting in Arduino IDE as we are using it to store custom settings via WifiManager (see step 6 below).
Unplug the 3V3 VCC cable to be able to watch the serial monitor when the Sonoff is powered on through main else you will fry the esp. You can also flash Sonoff's esp like this (be careful to not touch main current through the Sonoff when manipulating it).
It also looks like when the program is of a given size, the USB/serial adapter (CH340G at least) is not able to give enough current for the esp to run properly (crashes in loop with stacktraces). An FTDI adapter looks more reliable.
You can also use screen /dev/ttyUSB0 115200
to watch the serial monitor, but Arduino IDE serial monitor is more practical to use as it is relaunched each time it detects when the USB/serial adapter is plugged to a running chip.
Using a FTDI as below is more practical and safer as it's able to properly power the Sonoff S20. Don't forget to set the jumper to 3.3V or you will fry the ESP.
See Lomanic/presence-button on Github (sourcecode mirror).
See Lomanic/presence-button-web on Github for the remote server part (sourcecode mirror).
Authenticating…FAIL 18:43:52 [ERROR]: ERR: ERROR[4]: Not Enough Space
⇒ https://www.esp8266.com/viewtopic.php?f=32&t=19064#p80107 (see also step 6)
Today the button regularly pings a server (HTTPS requests) every ten seconds, this server registers pings from the button to notify on Matrix that the Fuz opens (on first fuzisopen=1
call) or is closed when it's not pinged anymore after 5 minutes.