Lingan SWA1 Plug in Wi-Fi Socket with MQTT (ESP8266)

Lingan SWA1

This is another cheap plug in Wi-Fi mains socket that uses the ESP8266, comparable to the Sonoff S20. Cost was £8.34 + £2.34 shipping to the UK from TVC-Mall. It is also available from Banggood for a little more and is starting to show up on eBay now too.

I didn’t try the standard software/firmware combination, it’s likely to be as rubbish as they usually are and I need MQTT support so I jumped straight into flashing something more useful. This one isn’t supported as standard by my favoured firmware TASMOTA but it is easy to add it in.

Rated current is 10A, maximum power 2000W. It has an FCCID (2AJK8-SWA1) and is CE marked.

Relay and red LED are on GPIO5
Blue LED is on GPIO 4
Button is on GPIO 13

Opening the case is easy, first remove the screw in the middle of the 3 pin plug and remove the plate and you can then access the four screws, once they are removed the case just unclips.

Remove plate to access screws

The ESP8266 is on a separate board with the push button and LEDs, be careful with the 3 wires linking it to the mains board as they seem to be quite fragile and I had to resolder two of them. It’s probably easiest to unscrew the board attached to the front of the housing but there is no need to take the whole thing to bits.

You don’t need to go this far.

There are pads for a programming header but unusually the power is to the input of the AMS1117 3V3 regulator and not directly to the 3V3 input of the ESP8266. I just fed 5V into the header but you could also tap 3V3 onto the output of the regulator.


Making it work with TASMOTA

I’ve been standardising on TASMOTA for as many of my ESP8266 devices as possible, it doesn’t support the SWA1 as standard but it only requires a couple of modifications to add it, both are in the file sonoff_template.h

First add an entry for the SWA1 under “Supported hardware modules” at the bottom, before MAXMODULE as below:

// Supported hardware modules
enum module_t {

and then at the end of the file under the module setting for Sonoff SC” add a new section as below before the final };

 { "Lingan SWA1",    // Lingan SWA1
   0,                // GPIO00 Button
   GPIO_USER,        // GPIO01 Serial RXD and Optional sensor
   0,                // GPIO02
   GPIO_USER,        // GPIO03 Serial TXD and Optional sensor
   GPIO_LED1_INV,    // GPIO04 Blue Led (0 = On, 1 = Off)
   GPIO_REL1,        // GPIO05 Red Led and Relay (0 = Off, 1 = On)
   GPIO_KEY1,        // GPIO13 Button
   0, 0, 0, 0

Now when you have flashed the code to the device you will have a new entry in the module config which sets the correct GPIO pins for the SWA1.

Module type in TASMOTA


Due to the positioning of the programming header and the lack of room in the case I decided not so solder pin headers on this time and just held one in place while flashing it and fed 5V to the power input as it goes through the 3V3 regulator. Don’t forget to ground the GPIO0 connection to get into programming mode.

Header in place for flashing firmware

When using TASMOTA I always preset my Wi-Fi credentials in user_config.h and then upload with PlatformIO. After flashing, restart it and connect to the web interface and set the correct module type, MQTT settings and so on.


Controlling via MQTT is then just a matter of sending an MQTT message with a payload of “on” or “1” to the topic “cmnd/lingan-swa1/power” to turn it on and “off” or “0” to turn it off. A payload of “toggle” will toggle the output. The device will publish the status to “stat/lingan-swa1/POWER” (examples assume you set the topic in the device conifg as “lingan-swa1”). See the TASMOTA Wiki here for more MQTT features.



13 thoughts on “Lingan SWA1 Plug in Wi-Fi Socket with MQTT (ESP8266)

  1. Hi Nathan,
    Nice write up 🙂 I’ve been trying to do this for some time but I can’t even get a blink sketch running on it 🙁 The code uploads but does not appear to run, as no LEDs blink or relay clicks and there is no serial ouput. Can you think of any reason why it would not run the code?

  2. Hi Keith,
    i had the same problem, but got it to work! Newer Lingan SWA1 uses the ESP8285 CHIP!

    I use the Arduino IDE to flash ESPEasy (
    So i just have to change ESP8266 to ESP8285.
    Maybe this solve your problem too

    The bootloader uses 74880 baud, if you see “csum err” the upper procedure my help 😉
    .Flash uses DOUT


  3. In fact Tasmota can be flashed though doesn’t want to function correctly when plugged in through the ttl adaptor, just plug it in and it works.

  4. Hello,

    i have flash with Atom (PlatformIO) and the message means success. My plug connect to wlan and become a ip and i can ping it. But no website is runnning. The port 80TCP is open and i can connect with telnet but no data will be send from the plug. W10 X64 and FTDI232 USB used.
    thanks for help and ideas

  5. Flashed all ok, set the module and the LED now works, however the power output does not work, any ideas?

  6. Hello, a question: when I sept in tasmota: Generic module to create node mcu with 4 relays they work according to each other. When I turn on one of them, the other goes off. For example: if I turn on the relay 1 while the number 3 is on, the latter goes out as soon as the relay 1 goes ON.
    Is there any command to give in the console? Thank you

  7. Thanks a lot for your explanations.
    I have the same electrnoic card and i have to fash it for domoticz use and you are the first one with the picture with exactly the same for me.
    Sorry for my english , I am french…

  8. I’ve got a few of these, and I am able to flash the sonoff firmware using the tuya-convert scripts instead of removing all the housing, but I’m not sure which firmware I should actually be flashing. If I try to setup a template using your configuration above, the LED and power aren’t working, either so I can connect to the WiFi but that’s about it. Do you happen to have the firmware available (as in already built) that I can just flash through the web interface to try and get this thing up and running again?

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.