Sonoff S20
The Sonoff S20 is a smart socket off-the-shelf product to switch main power consumers. It is using the ESP8266 CPU and 1 MByte Flash and can be used with the Minimal Example.
Sonoff ITEAD is a brand for several off-the-shelf Smart Home WLAN devices like switches that use the ESP8266 chip.
The Minimal Example can be flashed onto his device to support a remote switch with options for time based switching.
GPIO usage
GPIO# | Component | Usage |
---|---|---|
GPIO13(D7) | LED | LED (green), (0 to switch on). |
GPIO0(D3) | button | button, can also be used for start flashing |
GPIO12(D6) | relay+LED | relay and LED(blue), (1 to switch on). |
Warning
- This warning is serious.
- Stay away from devices with contact to mains voltage.
- Never handle this module when connected to the mains voltage as the contacts are not safe.
- Uploading firmware to devices that have contact to mains voltage is dangerous.
- DO NOT connect the any device to the mains during flashing or while using the serial interface.
- You may kill your computer and yourself.
- When you are making these kind of projects you really need to know what you are doing.
- I have warned you, do not blame on me.
Example env.json configuration
This configuration registers the device with the name “sonoff01” on the networks and enables using the button during boot for starting into the configuration mode.
{
"device": {
"0": {
"name": "sonoffs20",
"description": "Sonoff S20 plug",
"homepage": "/ding.htm",
"led": "D7",
"button": "D3"
}
},
"ota": {
"0": {
"port": 8266,
"passwd": "123",
"description": "Listen for 'over the air' OTA Updates"
}
}
}
Example config.json configuration
This configuration allows switching the relay using the button and showing the relay state using the LED.
{
"digitalin": {
"button": {
"pin": "D3",
"invert": 1,
"pullup": 1,
"onLow": "switch/relay?toggle=1"
}
},
"switch": {
"relay": {
"value": 0,
"onValue": "digitalout/relay?value=$v"
}
},
"digitalout": {
"relay": {
"pin": "D6",
"invert": "false"
}
}
}
See also
- DigitalIn Element
- Switch Element
- DigitalOut Element
- http://www.andremiller.net/content/programming-an-itead-sonoff-wireless-smart-switch-esp8266