p1240886s

Sonoff S31, a world apart

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!

You can buy the S31 from Itead (see link above) or via the usual marketplaces. Actually the S31 is slightly cheaper [Ebay] on some of them.

Not an unboxing

You know I don’t do unboxings so  this is not an unboxing. They just happen to be pictures with the device in a box.

p1240882s

p1240883s

p1240884s

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.

p1240886s

p1240887s

p1240890s

Every time I look at a USA plug I get the same feeling. Ooooh, how is that you are so sad? But this time it was also my face. The slick design of the device gets completely ruined with the two adapters (C to A and A to C).

p1240891s

S20 Smart SocketThe design is very different from the S20. The later is used by several manufacturers for their branded smart plugs, so it’s probably someone else’s design. I can’t tell about the S31 but the level of integration makes me think it’s an adhoc design.

Opening it

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.

p1240894s

p1240896sThen you have to slide the corners to reveal 3 small Philips screws that will let you remove the top completely. The bottom side (the one with the male plugs) seems to be glued to the PCB so it is not easy to remove without risking breaking something. Anyway you don’t need to access the bottom side of the PCB where there are only a few passives and a SO8 chip, probably the switching power supply chip.

p1240897s

p1240898s

Compact design

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.

p1240877s

p1240878s

Notice that, unlike the S20 where the PCB is connected to the plug barrels via wires, in the S31 the connectors are soldered to the PCB. This saves some space for sure but probably makes the device more sturdy too. The removable cap has separators to ensure the contacts are isolated from other components, including the small cables from the transformer.

p1240879s

For a complete photo book of the S31 you can check the FCC database photos.

The CSE7766 power monitoring chip

IteadStudio has switched from the HLW8012 chip to the CSE7766 for power monitoring with their latests products, the S31 and the POW R2. The reason might be that the new chip by Chinese manufacturer Chipsea offers a more stable reading, according to the first tests. The good news are that both chips are pin compatible even thou the protocol is very different.

You might remember from my post about the HLW8012 that this IC uses two pins to output power and current/voltage as variable-frequency square wave. Those pins are number 6 and 7 in the SO8 package. Pin 8 is used in the HLW8012 as an input pin to select whether the output in pin 7 would be proportional to the current or the voltage.

The CSE7766 [datasheet, PDF] uses a serial protocol instead. At the moment only TX line (pin 6) is enabled. The RX line in pin 8 is flagged as “reserved” in the datasheet. Pin 7 outputs a 50% duty cycle pulse with frequency proportional to the active power, just like the HLW8012.

hlw8012-circuit

HLW8012 suggested application

cse7766_application

CSE7766 suggested application with isolation

So you see that on both chips have the same AC interface (left side of the chip) and a similar interface on the MCU part (right side). Actually pins 6 and 7 are outputs and pin 8 is an input on both chips.

Mind that the CSE7766, just like the HLW8012, ties the logic ground to the mains neutral line. This is commonly known as “hot ground”. It’s not bad by itself as long as ground is not exposed outside the case.

But

We all know about Itead products. They have walked a long path since the first Sonoff Basic (or Sonoff WiFi). But still, they do not provide any electrical safety certifications (ETS, UL, ETSI) with their products. They have applied for FCC, claim to be CE and comply with RoHS but EE and professional electricians will probably not install these devices. It’s true the S31 is a plug-and-play device, no electrician required, but in some sense it’s an “AS IS” product. You are a maker, right?

Even thou IteadStudio is improving with every design, safety distance between AC and DC traces is not met.

The POW and S31 have the caveat of being non-isolated devices. Mains are connected to the logic ground and the power monitor IC output is not isolated from the MCU. Even thou the datasheet suggests an isolated application using an optocoupler I have not seen it in the S31. So please, take all the safety precautions when the PCB is exposed.

Flashing ESPurna on the S31

REMEMBER: do not do this while the device is connected to mains. The logic ground in the device is connected to the mains neutral line.

Flashing the S31 with custom firmware requires soldering some wires or a header to the pads at the edge of the small PCB. These pads expose (not only) GND, 3V3, RX and TX. Just connect them to your USB2UART programmer. Then press and hold the button (which is tied to GPIO0) and connect the programmer to your computer so it will power the board.

With GPIO0 connected to GND (that’s what the button does) the ESP8266 will enter flash mode. You will then be able to flash ESPurna (or any other firmware) to the device via serial from your favorite IDE or from the console using esptool.

p1240877seESPurna supports the Sonoff S31 since version 1.12.6. It can control the relay, the notifications LED and report current, voltage, active power and energy to Thingspeak, InfluxDB, Home Assistant, Domoticz or any other service via MQTT.

espurna-s31That’s it. You might have notice I’m not writing as much as I used to a few months ago. I happen to be quite busy lately which is not bad news. But I really miss to be able to spend some more time exploring new devices…

See you soon, hopefully!

CC BY-SA 4.0 Sonoff S31, a world apart by Tinkerman is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Leave a Reply (all comments are moderated, be patient)

This site uses Akismet to reduce spam. Learn how your comment data is processed.