• You've been granted Beta access to this site, allowing you to explore some of the new features while they're still under construction. More information can be found in the Beta forum.

DIY firmware upgrade to ITead S31 Smart Socket switch


Purchased the SonOff S31 with energy monitoring from Amazon for $18.99- one day delivery.

Sonoff S31 Wi-Fi Smart Plug with Energy Monitoring UL Listed, Smart Socket Outlet Timer Switch, Compatible with Alexa & Google Home Assistant, IFTTT Supporting,

Note too that this is more of a US designed switch rather than an EU designed switch.

This one has a smaller footprint and includes energy monitoring. Note that this is my first endeavor that includes energy monitoring (using MQTT).

From the Tinkerman site:

It's not that other Sonoff products are not “serious” business, but there are a number of design changes in the Sonoff S31 that make this new product a world apart. For the functional point of view it looks like a S20 with POW-powers, but they have redesigned the product completely. The result is very very interesting.
  • Revamped case, more compact and sturdy
  • Redesigned PCB, actually 2 different PCBs for main and control
  • Different power monitor chip: the CSE7766 (same as in the new POW R2) replaces the HLW8012
The only drawback: it's only compatible with plug types A & B, tat is central and north-america and few other countries. I'd love to see a S31-EU schuko version!
The device itself is kind of pretty, compact and robust. It has some appealing design choices (outside and inside) and the way everything fits together (see more pictures below) is great.

Aside from the male and female type A plugs, you have a ON/OFF button on the dark gray side and two LEDs. The red LED closer to the side shows the relay status and the blue one, closer to the plug is used for notifications.

Opening the case to hack the device it's not hard. The only tricky step is to measure the strength you have to apply to first remove the dark grey cap where the ON/OFF button is.
The design is based on two PCBs. The bigger one for the AC connections, AC/DC transformer and relay. And the smaller one for the the DC circuitry, including the ESP8266, an SPI flash memory and the CSE7766 power monitoring chip. It sounds like a good idea but it gets somewhat screw because they don't actually isolate AC from DC. AC is in the secondary PCB too since the power monitor chips needs access to mains. Also the distance between AC and DC traces is thinner than what would be desirable.

Note this picture is from Tinkermans site. Here will just be soldering some small wires for VCC (3.3VDC), GND, RX and TX.

Soldering USB serial TTL device pins VCC, RX, TX and GND. Here utilize painting tape to hold wires in place to solder and used a bit of flux to solder.
Firmware updating:

Here downloaded S31 current bin to download directory on Linux.

You need Python 2.7 or Python 3.4
Easey Peasey to install

pip install esptool

/home/pete# esptool.py --port /dev/ttyUSB0 write_flash --flash_size 1MB --flash_mode dout 0x00000 espurna-1.14.0-itead-sonoff-s31.bin

Desoldered 4 wires and put device back in case.
Connected S31 to Christmas Tree - Power GUI

Espurna GUI status

Espurna S31 Power stats*



Senior Member
pete_c said:
Updated OP.
Appears to me that kWh is off a bit.
Our 200 LED lite Christmas tree uses 7 watts. The switch controlling it probably uses more. Yours must not be LED or its VERY big.


Yes it is an old pre lit tree (no LEDs) with three sets of incandescent lights (that get warm to the touch).
I did try small battery operated LED lamps this year on three outdoor wreaths.  They are doing fine using the built in timer.
I also tried a solar powered string of lights which too are still doing OK outside.  I like these better than the timer lamps.