Announcement

Collapse
No announcement yet.

DIY firmware upgrade to ITead S31 Smart Socket switch

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    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!

    Click image for larger version  Name:	S31-1.jpg Views:	0 Size:	36.4 KB ID:	1347574

    Click image for larger version  Name:	S31-2.jpg Views:	0 Size:	40.9 KB ID:	1347575
    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.

    Click image for larger version  Name:	S31-3.jpg Views:	0 Size:	26.4 KB ID:	1347576
    Click image for larger version  Name:	S31-4.jpg Views:	0 Size:	52.3 KB ID:	1347577

    Click image for larger version  Name:	S31-5.jpg Views:	0 Size:	58.4 KB ID:	1347578

    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.

    Click image for larger version  Name:	S31-6.jpg Views:	0 Size:	99.9 KB ID:	1347579

    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.

    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.

    Soldered 4 wires to board; RX, TX, GND and VCC and used new programmer. Worked fine.

    Click image for larger version  Name:	S31A.jpg Views:	0 Size:	147.5 KB ID:	1348326
    Click image for larger version  Name:	S31B.jpg Views:	0 Size:	147.2 KB ID:	1348327

    Flashing

    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.

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

    GUI - Power Status - connected to Christmas Tree

    Click image for larger version

Name:	S31-Power1.jpg
Views:	1142
Size:	46.2 KB
ID:	1348354

    GUI - General Espurna Status

    Click image for larger version

Name:	S31-Power2.jpg
Views:	1137
Size:	43.7 KB
ID:	1348355
    - Pete

    Auto mator
    Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
    Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
    HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

    HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
    HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

    X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

    #2
    I have the the Sonoff S31 and it is a well made product. They also have a version without energy monitoring. I think it is called the "Lite" version. Be careful when ordering. There are other plugs avaialbe, but this one does have 16A rating so good for house wiring of 14 gauge. This means that the breaker trips first rather than the plug failing in some manner that could include fire. The Sonoff Basic and many others are rated at 10 amps and there is no US wiring that I am aware that has 10A breakers or fuses. Just think that a space heater is typically rated at 1500 watts which is more that 10 Amps.

    Comment


      #3
      Thank you Michael. Yes Amazon had both versions.

      The "lite" version is $4 less.

      Not sure yet what I will be using it for yet.
      - Pete

      Auto mator
      Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
      Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
      HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

      HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
      HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

      X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

      Comment


        #4
        Hi Pete,

        I have purchased 2 of S31 and i'm going to attempt to replace firmware on it.
        According to your picture above, there is 4 connections to the board from programmer, RX, TX, GND and VCC.
        Picture is blurry , but are those pins the same as picture below?





        Attached Files

        Comment


          #5
          From the Tasmota site https://github.com/arendst/Tasmota/wiki/sonoff-S31

          "The pads are labeled, you need VCC, RX, TX, GND. There are two others that also have RX and TX on them. The ones next to the GND pin are not used for flashing."

          Make certain you connect RX on the S31 to TX on you UART. Same swap for TX.

          Comment


            #6
            Originally posted by Michael McSharry View Post
            From the Tasmota site https://github.com/arendst/Tasmota/wiki/sonoff-S31

            "The pads are labeled, you need VCC, RX, TX, GND. There are two others that also have RX and TX on them. The ones next to the GND pin are not used for flashing."

            Make certain you connect RX on the S31 to TX on you UART. Same swap for TX.
            Thank you Michael.
            Will try to find programmer tomorrow.

            Best Regards
            Tim

            Sent from my EML-L09 using Tapatalk

            Comment


              #7
              Yes here just soldered wires to the board then removed them. From left to right

              1 - first pin - labeled ground
              2 - 4th pin - labeled TX
              3 - 5th pin - labeled RX
              4 - 6th pin - labeled VCC

              - Pete

              Auto mator
              Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
              Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
              HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

              HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
              HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

              X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

              Comment


                #8
                Originally posted by Pete View Post
                Yes here just soldered wires to the board then removed them. From left to right

                1 - first pin - labeled ground
                2 - 4th pin - labeled TX
                3 - 5th pin - labeled RX
                4 - 6th pin - labeled VCC
                Thank you Pete.

                Best Regards
                Tim

                Sent from my EML-L09 using Tapatalk

                Comment


                  #9
                  Using the serial cables / power works great. It is a one time thing and you can later on update the firmware via the web gui. Wireless initial firmware updating was hit or miss for me.
                  - Pete

                  Auto mator
                  Homeseer 3 Pro - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e 64 bit Intel Haswell CPU 16Gb
                  Homeseer Zee2 (Lite) - 3.0.0.548 (Linux) - Ubuntu 18.04/W7e - CherryTrail x5-Z8350 BeeLink 4Gb BT3 Pro
                  HS4 Lite - Ubuntu 22.04 / Lenovo Tiny M900 / 32Gb Ram

                  HS4 Pro - V4.1.18.1 - Ubuntu 22.04 / Lenova Tiny M900 / 32Gb Ram
                  HSTouch on Intel tabletop tablets (Jogglers) - Asus AIO - Windows 11

                  X10, UPB, Zigbee, ZWave and Wifi MQTT automation-Tasmota-Espurna. OmniPro 2, Russound zoned audio, Alexa, Cheaper RFID, W800 and Home Assistant

                  Comment


                    #10
                    You can do an over the air flash on the Sonoff S31. It is covered here:
                    https://youtu.be/ONFhXM5R-t4
                    Karl S
                    HS4Pro on Windows 10
                    1070 Devices
                    56 Z-Wave Nodes
                    104 Events
                    HSTouch Clients: 3 Android, 1 iOS
                    Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                    Comment


                      #11
                      Do yourself a favor as I did and try this software for any ESP8266 or ESP32 based devices They have 15 days free trial and the software itself is dirt cheap at $4. I have now over 2 dozen ESP8266 devices controlling anything from dog feeders to entry gates and from sauna to HVAC all running zumungo software. There are several advantages of Zumungo the most important one being "taking the intelligence to the edge of the network". Although my zumungo driven relays are connected to HS3 all the time they do not need much control. While there are many ESP8266 relays out there that can execute on/off commands, zumungo takes it one step further by making such commands driven by sensors. For example my sauna control uses the build-in feature to trigger by 1wire temperature sensor. All HS3 needs to do is to "tell" the relay the target temperature and to start the sauna. Everything else including safety features is controlled by the ESP8266 relay board running zumungo software. Last but not least unlike others Zumungo has completely open and well documented protocol running over TCP, MQTT, HTTP your choice and easy to integrate with HS3. As far as hardware goes I'm using Sonoff Basic, Shelly 1, LinkNode R4 and R8, YunShan and Aptinex.
                      Designed by IoT professionals around multiple real home automation cases and vigorously tested in the field. Drives the home automation of many happy users. Become one of them today. Free trial available. No credit card required.

                      Comment


                        #12
                        risquare am I missing something or do I still need to flash zumungo onto the device?
                        Karl S
                        HS4Pro on Windows 10
                        1070 Devices
                        56 Z-Wave Nodes
                        104 Events
                        HSTouch Clients: 3 Android, 1 iOS
                        Google Home: 3 Mini units, 1 Pair Audios, 2 Displays

                        Comment


                          #13
                          ksum
                          ​​​​​​​Of course like with any firmware it needs to be flashed into the device. You do flash an Installer actually and the Installer does the rest of the work "over the air" OTA. Later on all updates happen automatically OTA. All is well explained at their "get started" page https://www.zumungo.com/get-started/

                          Comment


                            #14
                            Originally posted by risquare View Post
                            Do yourself a favor as I did and try this software for any ESP8266 or ESP32 based devices They have 15 days free trial and the software itself is dirt cheap at $4. I have now over 2 dozen ESP8266 devices controlling anything from dog feeders to entry gates and from sauna to HVAC all running zumungo software. There are several advantages of Zumungo the most important one being "taking the intelligence to the edge of the network". Although my zumungo driven relays are connected to HS3 all the time they do not need much control. While there are many ESP8266 relays out there that can execute on/off commands, zumungo takes it one step further by making such commands driven by sensors. For example my sauna control uses the build-in feature to trigger by 1wire temperature sensor. All HS3 needs to do is to "tell" the relay the target temperature and to start the sauna. Everything else including safety features is controlled by the ESP8266 relay board running zumungo software. Last but not least unlike others Zumungo has completely open and well documented protocol running over TCP, MQTT, HTTP your choice and easy to integrate with HS3. As far as hardware goes I'm using Sonoff Basic, Shelly 1, LinkNode R4 and R8, YunShan and Aptinex.
                            Ok,
                            I have flashed tasmota firmware into Costco dimmers and never finished mqtt part of it.
                            Will try this as soon as I find suitable interface.

                            Sent from my EML-L09 using Tapatalk

                            Comment


                              #15
                              risquare is trying to promote a product with which he is affiliated Tasmota is a much more widely supported product and free. There is also wide interest for ESPHome and Espurna. I would stay with things that have wide interest as support and growth will be much better.

                              Comment

                              Working...
                              X