Sonoff S31 Smart Plug Review and Tasmota Installation

Tue Jun 09 2020

When flashed with the Tasmota firmware, the Sonoff S31 WiFi smart plug is a powerful addition to our Smart RV home automation system.

Sonoff S31 Smart Plug Review and Tasmota Installation
As an Amazon Associate we earn from qualifying purchases.


Sonoff is a range of inexpensive, smart devices made by Itead. They include everything from smart switches to lights, temperature sensors and more.

While out of the box they can integrate with Nest, Alexa, Google Home and even IFTTT, the reason that Sonoff devices are so popular with makers is that they're designed to be hacked - in a good way! Itead makes it super easy for developers to load their own firmware onto most Sonoff products, turning them into incredibly customizable devices.

And that's where this guide comes in. I'm already using several Sonoff devices as part of the home automation system that makes up our Smart RV. The Sonoff SV devices are particularly useful because they can switch 12V DC - which is what all the lights in our RV use.

Sonoff S31 Smart Plug

But today I'll be flashing the Sonoff S31 Smart WiFi Plug, one of Sonoff's newest devices.

Sonoff S31
The small yet mighty Sonoff S31 with built-in power monitoring.

The Sonoff S31 is a smart plug that can be turned on and off via WiFi. It's a US plug, rated for 15A at 120V AC, unlike the Sonoff S20 and Sonoff S26 which are both rated to just 10A.

What really sets it apart is the power monitoring. It can report, in real-time, on how much power is being used - as well as current, voltage and even power factor (useful for us given our power comes from an inverter with a VA limit). While that's interesting to many DIY-geeks, it's particularly of interest to me in our RV where we're often reliant entirely on our batteries and solar for power.

Our Perfect Off-Grid RV Solar System

Find out how we upgraded our RV with Lithium batteries, solar panels, an inverter and more so we could camp off-grid in comfort!

Our Perfect Off-Grid RV Solar System

Previously I had been relying on the Sonoff POW R2 which also has this capability, but that unit is hardwired meaning I had to cut the plug off each device to connect it. With the Sonoff S31, it's as simple as plugging it in to a wall outlet!


But before we plug it in, I'll be flashing it with Tasmota, open source software written by Theo Arends and licensed under the GNU General Public License v3.0.

Tasmota unlocks full control over the Sonoff devices, but more importantly allows us to integrate them with our Smart RV home automation system, based on Home Assistant, MQTT and NodeRED under the hood.

For many people, keeping their data local and avoiding 3rd party cloud integrations is a matter of privacy. While that's true for us, it's not the whole story - when we're camping off-grid in our RV, we want to make sure our home automation systems still work even if we don't have internet connectivity.

Before we can flash Tasmota onto it, let's jump in and take a look at the Sonoff S31.


I ordered two Sonoff S31 smart WiFi plugs from Amazon, and a few days later they arrived, each in its own grey box.

Sonoff S31 Box
Two Sonoff S31 plugs in their minimalist grey boxes.

On the back of the box we can see the specifications - the Sonoff S31 supports up to 15 Amps at 120V AC. It can connect to WiFi via 802.11 b/g/n - no 5GHz support here.

Sonoff S31 Specifications
These specifications can be found on the Sonoff S31 itself too.

The box is well packaged and simple - containing the Sonoff S31 smart plug itself, plus a small instruction manual and a piece of paper stamped to show it had been through Quality Control.

Sonoff S31 Unboxing
There's not much inside - just a couple of pieces of paper and the Sonoff S31!

The Sonoff S31 is a nice form factor. Unlike both the Sonoff S20 and Sonoff S26, the Sonoff S31 is wide rather than tall, so two of them can be stacked vertically in a double outlet.

On the back of the Sonoff S31, we can also see the symbol showing it is UL Listed in both the US and Canada, unlike the Sonoff POW R2 (and others) which lacked this and had only the CE stamp. I'm really pleased to see the Sonoff S31 is now UL Listed and it gives me a lot of confidence when deploying it in my home!

Sonoff S31 UL Listing
The UL Listed mark in the lower right indicates it has been UL Listed in both the US and Canada.

One end of the Sonoff S31 is home to a small momentary push button that that toggles power on and off - this continues to work with the Tasmota firmware, but can be configured too if desired. There are also a couple of LEDs which indicate WiFi and power status.

Sonoff S31 LEDs
The small LEDs on the top edge indicate power and WiFi status.


Warning: Do not attempt to disassemble this device while it is connected to AC power. This blog post is for research purposes only and if you choose to act on anything herein you do so entirely at your own risk. If at any point you don't feel completely confident, STOP and consult a professional.

To flash the Sonoff S31 we first need to gain access to the PCB inside. The screws are hidden, and to get to them we have to remove some plastic covers.

First, pop the grey cover off the end. You may be able to do this with your fingernails, but I found it easier to use a small penknife.

Sonoff S31 End Cover
I used a small penknife blade to pop the grey end cover off.

With the grey cover removed, slide out the two white plastic pieces - they're fit into guiderails and should slide smoothly out, revealing three screws behind.

Sonoff S31 Disassembly
The white bars then easily slide out...

Using a small screwdriver, remove the three screws. I found them to be incredibly tight, so be careful not to strip the screwheads. I didn't see any evidence of thread lock though, so just take your time.

Sonoff S31 Screws
...revealing three screws underneath. These were really tight on mine!

Once the screws have been removed, you can pull the PCB out of the white casing.

Sonoff S31 Disassembled
The Sonoff S31 laid bare for all to see!

Here's a high-resolution image of the Sonoff S31 circuit board in case you're interested.

Sonoff S31 Circuit Board PCB
High resolution photo of the Sonoff S31 circuit board - click to enlarge.

On on end of the device you'll see a daughter board, containing the pins needed to flash the Tasmota firmware onto it.

Sonoff S31 GPIO Pads
The daughterboard on the end contains the solder pads for attaching the wires to flash it with.

Connect Flashing Wires

In the corner of the daughter board, you'll see six GPIO pads. There are actually two pairs of RX / TX pins - you want the pair closest to the VCC pin.

There aren't any holes (or much space!) to solder headers on, so I chose to simply solder some short jumper wires onto the pads. Once it has been flashed the first time, it's easy to update the firmware over-the-air (OTA). Make sure you read the pins carefully - don't accidentally solder the ground on the 4th pin down like I did at first! Fortunately I spotted it quickly and moved it.

I used my Hakko FX888D soldering station to attach the wires - it's a bit messy, but was hard to do with a camera lens right in front of me!

Sonoff S31 RX TX Pads
Use the RX and TX pads nearest VCC.

For flashing devices via Serial over USB, I like to use my Moyina FTDI USB adapter. It has convenient headers and a toggle to switch between 3.3V and 5V. For this, make sure it is set to 3.3V.

Warning: If you connect 5V to the Sonoff S31 pins, you will damage the device.
Moyina FTDI USB Adapter
I find that using the Moyina FTDI USB adapter is the easiest way to flash Sonoff devices.

Before you connect it to the Sonoff S31, make sure you have the drivers installed. Windows and Mac OS should both install them automatically when you plug it in, but you can download them from the FTDI Chip website if necessary.

Connect the FTDI USB adapter to the Sonoff S31 as follows (I've included the color wire I used to make it easier to interpret the pictures):

ColorSonoff S31FTDI USB Adapter

It's pretty straightforward - just map VCC and GND to their respective pins, and switch TX and RX.

Flashing Sonoff S31
Sonoff S31 connected to the FTDI USB adapter ready for flashing.

Preparing for Flashing

To install the Tasmota firmware, you'll need to download the firmware itself and a tool to flash the firmware with. I personally prefer to use esptool, so that's what we'll use here. If you haven't already downloaded and installed esptool, you can follow the directions in the esptool GitHub repository.

You can download the Tasmota firmware from the Releases page in the GitHub repository - scroll down until you see the list of Assets.

To keep things simple, we'll be installing the "standard" Tasmota firmware - simply called tasmota.bin. There are lots of other variants too, but these are beyond the scope of this document. Download your chosen file to your computer.

For the purposes of this guide, I'll be using Tasmota version 7.2.0 and then I'll show you how to update to the latest version using an over-the-air (OTA) update later. You can skip this and go straight to the latest version, but it's good to know how to update via OTA for when you need it later.

The button in the middle of the board is the toggle button that was covered by the grey end cap. It is connected to GPIO 0 and this button needs to be held down before plugging the USB adapter in, and for several seconds afterwards. This forces the device to start in serial bootloader mode.

Sonoff S31 GPIO 0
The gold-colored button in the center is connected to GPIO 0 and needs to be held down while powering up.

Once you have installed esptool and downloaded the Tasmota firmware, you're ready to start.

Flashing the Firmware

While holding down the button on the Sonoff S31 connected to GPIO 0, plug the FTDI USB adapter into a spare USB port on your computer. Keep holding the button down for several seconds - you should see some lights flashing on the FTDI adapter. Count to 5 seconds after plugging it in and you should be safe to let go of the button.

We'll be running a series of commands using the Terminal on Mac and Linux, or the Command Prompt on Windows.

The instructions below are from my Mac, but the process on Windows is similar. First you need to find out the name of the USB device. On Mac, we can do that using the command:

ls /dev/tty.*

Listing USB Devices
In my case, the device was named /dev/tty.usbserial-AD0JKNK3 but yours will be different.

And look for one that looks similar to /dev/tty.usbserial-AD0JKNK3 (the suffix at the end of yours will be different to mine). On Windows, you want to look in Device Manager for the device name which should be something like COM Port 5. You should replace <port> with the name of your port in each of the following commands.

I always start by double checking that esptool can communicate with the device, by running the --port <port> flash_id

ESPTool Flash ID
This step isn't strictly necessary but is an easy way to confirm everything is working correctly.

If successful, it will print data including the chip type and MAC address on the terminal. The device will then hard reset, but if you aren't still holding the button then it will have booted into normal mode rather than entering the serial bootloader. Don't worry - just pull out the USB plug, wait a few seconds, then hold down the GPIO 0 button and reinsert the USB plug, counting to 5 before releasing the button.

You'll need to hold down the button and reset the device by unplugging it and reinserting it after each command, so you'll have plenty of chance to practise!

If you got an error on the screen, double check your wires are correctly attached and that the device name is correct in your command.

At this point, the Sonoff S31 is running Itead's original firmware. Before we replace it, you can back it up now if you want. I don't typically do this as I have no intention of using Itead's firmware, but if you want to then run the command: --port <port> read_flash 0x00000 0x10000 s31backup.bin

This will write the Itead firmware to a file called s31backup.bin and reset the device.

ESPTool Read Flash
You can backup the original Itead firmware in case you ever want to reinstall it.

Before installing the Tasmota firmware, we'll erase the flash with the command: --port <port> erase_flash

ESPTool Erase Flash
This will completely erase the Sonoff S31 flash memory - the point of no return!

Don't forget to reset the device while holding down GPIO 0 again.

The final step is to write the Tasmota firmware onto the device: --port <port> write_flash -fs 1MB -fm dout 0x0 tasmota.bin

You'll need to make sure that tasmota.bin exists, or change the path to wherever you downloaded the Tasmota firmware.

ESPTool Write Flash
This step might take up to a minute or so as it uploads the new firmware - be patient!

If all went well, you've now flashed Tasmota onto your Sonoff S31. Nice work!

If it didn't work, then double check your wiring is correct and all your wires are soldered and attached securely. Failing that, did you remember to press and hold the GPIO 0 button while inserting the USB plug?

Setting up Tasmota

Before reassembling, I like to check everything is working, and the easiest way to do that is to set up Tasmota with some basic settings.

First, unplug and reinsert the FTDI USB adapter, but this time do NOT hold down the GPIO 0 button. This will just provide power to the device so it can boot up.

After a few seconds, check on your phone or computer for a WiFi access point, named starting tasmota- and followed by 4 digits.

Tasmota Sonoff S31 WiFi
The WiFi network called tasmota-8118 is being broadcast by the Sonoff S31 running Tasmota.

Click on it to connect to the Tasmota WiFi, and after a few seconds, a screen should pop up.

Fill in your WiFi SSID name and password in the boxes named AP1 SSId and AP1 Password respectively.

Tasmota WiFi Connecting
Fill in your WiFi name and password here. You can customize other parameters now too, or change them later.

Click Save, and the Sonoff S31 will reboot.

Rejoin your main WiFi network. You'll need to look up the IP address of the Sonoff S31 - I find the easiest way is to connect to my router and find the list of clients. In my case, the new device had been assigned the IP address Navigating to this URL in a browser will show you the main Tasmota screen.

Tasmota Sonoff Basic Module
By default, Tasmota assumes the device is a Sonoff Basic Module, so we'll change that.

Since the Sonoff S31 is only connected with 3.3V power, I don't recommend clicking the Toggle button to switch the relay on / off just yet - soon, don't worry!

Click into Configuration and then Configure Module, then select Sonoff S31 (41) from the Module type dropdown list. Click Save and the Sonoff S31 will restart.

Tasmota Module Type
The process is similar for other Sonoff devices - just choose the corresponding module type from the dropdown list.

That's the basic configuration complete. We'll get it reassembled before we do anything else.

Reassembling the Sonoff S31

Reassembling is simply a case of reversing the disassembly steps.

Carefully unsolder the flashing wires from the pads on the Sonoff S31 circuit board. Reinsert the board into the white plastic casing, and reassemble it. Make sure the white plastic guides are seated correctly in the rails when you slide them back on - there is a right way and a wrong way to put them in.

Take your time reassembling and make sure all the screws are tight and everything fits correctly - there's going to be a lot of power running through it when it's connected!

When it's fully reassembled, it's time to test it out.

Sonoff S31 Tasmota
Turning on the Sonoff S31 with the Tasmota firmware for the first time.

Plug it into an empty wall outlet and wait a few seconds while it boots up and connects to the WiFi. If you browse to the IP address of the device in your browser, you should see the same screen as before.

This time, pressing the Toggle button should turn the relay ON. Pressing it again will turn the relay OFF. You can also press the button on the side of the Sonoff S31 itself to toggle the relay on and off - the web page will update automatically.

If you plug something in (I've been using a small electric heater), you can see the power consumption on the screen too.

Sonoff S31 Power Monitoring
The Sonoff S31 is reporting my heater is drawing 1413W using 12.837A at 110V. Sounds about right!

Tasmota is incredibly powerful firmware with a lot of configurability, so if you haven't already done so, I highly recommend reading through the Tasmota documentation. With everything from customizable button behavior to MQTT messaging, I'm looking forward to the Sonoff S31 being an integral part of our Smart RV home automation system.

OTA Firmware Update

Wouldn't it be a pain if each time you wanted to upgrade the firmware to get access to a new piece of capability, you had to disassemble the entire device and solder on some wires?

Fortunately, there's an easier way. Tasmota supports over-the-air (OTA) updating, allowing you to upload new firmware to the device via WiFi.

In your browser, load up the Tasmota main page by visiting the device's IP address. Click on the Firmware Upgrade button.

Here you have two choices. You can either upload custom firmware (e.g. that you've downloaded from the Tasmota GitHub Releases page) using the Upgrade by file upload option.

Tasmota OTA Update
No more flashing with wires - the simple OTA update process lets you update the firmware via WiFi.

Alternatively, you can use the Upgrade by web server option to automatically download and install the latest firmware directly from the Tasmota downloads page (or any other URL you insert here). Enter the URL you want to use (or leave the default for the latest Tasmota version) and click Start upgrade.

Tasmota Upgrade Screen
It might take a minute or so for the device to reboot after installing the new firmware.

The Sonoff device will restart, and when it does, it will be running whichever firmware you selected - in my case, I chose to upgrade to the latest version using the Upgrade by web server option. It might take a minute or so for the device to restart, but give it time!

Tasmota 8.3.1
The Information screen now shows I'm running the latest version of Tasmota, version 8.3.1.


For me, the new Sonoff S31 is a great device that, when paired with Tasmota, checks a lot of boxes!

I love that it's so inexpensive that I can deploy several of them around the place, conneccted to different devices. I'm very reassured to see that the Sonoff S31 is now UL Listed in both the US and Canada. And being able to fit two next to each other on a double outlet is great too!

Sonoff S31 Dual Outlet
There's even space for an air freshener in the outlet above it.

I use Tasmota to communicate with our home automation system via MQTT. Using its messages, I can capture real time power usage in addition to being able to turn on and off devices remotely. Plus, with the full power of Home Assistant's automations and even more capability with NodeRED, it's easy to create timers, conditions and automations.

The Moyina FTDI USB Adapter is the easiest way I have found to flash devices using a serial bootloader, and has saved me a lot of time vs other methods I've tried in the past.

I hope this guide was useful, and let me know in the comments how you plan to use your Sonoff S31 smart WiFi plug!

Previous postEvery Day We're ShufflingNext postDinosaur National Monument