Ok, this entry will be in 2 parts – I’ll do some digging soon – but as I’ve had several requests for this…

POW, TH16 and DUAL

So what you’re looking at above are the Sonoff Pow, TH16 and DUAL mains controllers. These are ESP8266-based low cost controllers to turn things on and off. The TH16 has a sister product, the TH10 and we covered these a while ago. Now complete with CE markings (which we are told does NOT mean China Engineering before anyone steps in to defend British manufacturing…. and looking quite spiffy.

POW, TH16 and DUAL

Ok, critical bits first, I’m not convinced about the push to connect stuff inside – I know it is fashionable to do away with screwdrivers but hell, you need a screwdriver to get into the thing in the first place  and those push to fit jobs work GREAT with single-core wire – not quite so well with multi-strand, depending on the thickness. Also due to the case design the connectors at the ends could be a tad tricky to sort in a dark cupboard – however, generally very well built.

Note that all three have a proper fuse inside which is really nice to see – and two of them have 16 amp relays – the DUAL having a couple of 10 amp relays.

POW, TH16 and DUAL

Note also that they all have the 4 way programming connector at the top left in these photos. Vcc I should note is 3v3 and not 5v. I usually manage to reprogram them straight from a 3v3 FTDI but it is pushing it a bit.

The ESP8266, FLASH and other bits are on the underside of these boards but if you’re just programming them – then you need go no further as the large button on the top is GPIO0 and hence you can use that for programming. I have programmed the TH16 and 16 extensively, the Dual and the POW are delights I have yet to tackle – the POW in particular as right now I’ve no idea how to read the power chip.

But of course you can use these out of the box with the Expressif cloud to control things. We’ve had the discussion in the past about power, I would not take the 16 amps too literally nor the 10amps – maybe keep the maximum power 25% under what is being claimed – though the tracks are quite thick. Of all the boards of this type I’ve seen – these seem to be about the best put-together.

POW, TH16 and DUAL

on the rightmost image – I’m pretty sure that piece of copper in the middle is the power sensor and there appears to be an 8-pin control chip above it and to the right. Other than that they are much the same… note the nice cutouts in the board, decent spacing and thick tracks for power. A lot of designers could learn from this.  My only gripe is their continued use of a tiny FLASH chip… HOWEVER, here’s a thing – in the old boards, the FLASH chip was on the top – partially obscured by the programming button – NOW it is on the bottom – which should make it one hell of a lot easier to replace – WHEEEEEEEE. I do note two different sizes of FLASH – note the two boards on the right – topmost right 8-pin chip. Last time I tried updating a TH16 I ripped the tracks to bits – now – I might just be able to do it – and the chips I bought are the bigger size. Mind you my biggest problem is more basic – having shipped all my stuff from Spain to the UK for the winter I now have to FIND my supply of SMT flash chips!

More soon on this one but I thought I’d give you a head’s up.  To give you an idea of pricing – here’s the page for the TH10 and 16 - https://www.itead.cc/sonoff-th.html   - they have gone up in price since the early days so just under £7 plus postage for the TH16 – probably a good idea to buy a few – but WAY less than anywhere else as far as I know. I have one of the original boards controlling an electric heater in my office and another controlling the likes of salt and room lights at home and they’ve been happily working away all summer.

As for pricing – with this link you get discount (don’t worry I don’t get anything) – and by the look of it – a shipment of one POW to the UK is (in dollars as their site screws up pounds) $8.62 for the DUAL and $4.62 postage… You are better off buying TWO as the postage is only another dollar..  all of this if you translate to Sterling – even with the atrocious state of the pound – is still cheap.

There is a link for the POW but I think they are out of stock right now.

So – you have these  - and you can use their built in software – or you can roll your own. Our own software handles the TH10 and TH16 but not yet the DUAL and POW (note that the DUAL for reasons best known to ITEAD has a 4MB Flash whereas the others have smaller FLASH). If you’re in a hurry – here’s a link to a fellow who has done the hard work – and who is very responsive – if you’re an Arduino/ESP type – this might be of interest. https://github.com/arendst/Sonoff-MQTT-OTA-Arduino 

4 Channel WiFi Wireless Switch  IM160920099 – blogged elsewhere

And coming up soon – writeups on:

Sonoff Touch EU
sonoff LED


25 thoughts on “POW, TH16 AND DUAL

    1. I was just about to post the same link. beat me to it by 10mins!

      here are the pin definitions
      #define HLW_SEL 5 // GPIO 05 = HLW8012 Sel input (Sonoff Pow)
      #define HLW_CF1 13 // GPIO 13 = HLW8012 CF1 voltage / current (Sonoff Pow)
      #define HLW_CF 14 // GPIO 14 = HLW8012 CF power (Sonoff Pow)

      info on the chip HLW8012 is rather scarce and in Chinese only! adapting to ESP8266 generically should not be too hard though

  1. From what I understand from the HLW8012 Chinese datasheet, CF is a 50% (+/=-20%) duty cycle frequency output proportional to the active power:

    Fcf = (V1 * V2 * 48) / Vref ^ 2 * fosc / 128

    CFI is a a 50% (+/=-20%) duty cycle frequency output either proportional to the RMS current if the SEL input = 0, or to the RMS voltage if SEL input = 1, using the following formulas:

    Fcfi = (V1 * 24= / Vref * fosc / 512
    Fcfu = (V2 * 2) / Vref * fosc / 512

    V1 is the differential voltage between measurement pins V1P - V1N (+/-43.75mV peak) and V2 is the differential voltage between measurement pins V2P and GND (+/-700mV peak). fosc is 3.579 MHz -+/-15 %) and Vref is 2.43 V.

    Accuracy on active power is +/-0.2% and +/-0.5 %) on Vrms and Irms, typical.

    In the MCU, you just need to measure the period, the best way is using edge-triggered IRQs and a counter. Based on the safe peak values for V1 and V2, I get 145 Hz max for power, 3020 Hz max for current and 4027 Hz max for voltage values. You probably have to dive these values by sqrt(2) for RMS, but this gives us a rough idea of what frequencies to expect from the chip.

    I guess the best way to calibrate is using a DMM.

  2. looking at the pictures that is not a CE mark. they have got there art work wrong if they have CE marked them most directives show the correct layout of the mark.

    Draw a circle around the outer and inner curve C and the E and they should over lap, otherwise they don't mean anything. (china export, china engineering etc)

    1. Too much detail - frankly personally I could give two hoots about CE - I just mentioned it as they contacted me a little while back with the certificates to show that they do in fact have proper CE certification. I'm sure if they have the printing wrong you can drop them a line and let them know. 🙂


      1. Well after a few emails and pictures we have an answer from Itead which i though i'd share as i raised the CE mark issue.

        Itead's final reply:

        "Many thanks.
        It's very clear now, I got the point.
        We have produced around 10k wrong enclosure... 🙁
        Anyway, it's better late than never."

  3. Good idea don't know why i did not think of it. have just let them know no point in spending the cash if you don't promote it.

    Has anyone tried to use a PC UPS to power the pi, router etc during power cuts, which i get a lot of in our village (overhead power lines). a small one in not much more in cost than adding a battery backup just for the PI?

  4. I did get a message from ITEAD to say postage was high - so I checked - normal post it is not - and now they've given me a link to give you discount (no - I don't get anything) - if you buy two the postage is way better than one but even then - quite reasonable. Enjoy.

  5. I have been playing a bit with the DUAL and have to come to the conclusion that the switch on the board does not connect to GPI0. I am quite experienced in reading circuit diagrams but the one they publish is very weird.
    In any case I have failed(so far) to get it to go into firmware update mode.
    Maybe somebody has an idea..cos I have run-out of them

  6. Peter, what is the part number of the larger FLASH chip you used? I have ordered 2 of the plug in modules and want to swap out the FLASH on them for 4MB.

  7. I have a problem when I want to update the firmware Sonoff DUAL or Sonoff TH16.
    My computer can not load the CP210x USB to UART drivers when I connect the FTDI port to Sonoff device.
    Instead I had no problems to update old Sonoff or S20 smart socket.

    It is a power problem of the PC USB port?
    Thank you

  8. Hi Peter,
    You mentioned you had re-programmed the DUAL units.
    The DUAL units that I have do not have the push button connected to GPIO0 and the relays are not connected to the ESP2866.
    There is a F330 chip sitting in the middle of all of this with the push button, leds and relays being interfaced through it not via the ESP2866.
    How did you reprogram these and control the leds/relays?

    1. Hi Neil - I did program the DUAL but not with my own software which is designed as general purpose and very powerful but wasted on the Sonoffs really. I recommend this for the Sonoff Dual - https://github.com/arendst/Sonoff-MQTT-OTA-Arduino

      Up to now he's still managed to keep the code down to fit in the standard 1MB on the Sonoffs (though it may be the Dual that has more) and it does MQTT - slightly differently to mine but it's fine - and the button on the DUAL works well with a series of multi-click options - one click turns one output on or off, a double click turns the other one on and off etc. Check out his code.

  9. Hi Pete - thanks for making the time to publish all this valuable information that others can learn from. I've just received a couple of Sonoff Pow units and have a good understanding of how to flash them with code so I can use them in my fledgling home automation system. I haven't worked with ESP8266 units before; what do you recommend as a pre-made FTDI controller/cable assembly to get the code on the chip after I've soldered on some headers? I will be using Windows 10 or an old Mac Mini - I appreciate I may have to install drivers.

    Thanks very much

      1. Pete - you are a star! I posted a question, went away to make a cup of tea, came back, and received an answer! Thanks very much. Brilliant!

  10. Hello,

    When I try to flash Sonoff dual using arduino code, throwing some warnings, I made connections and followed procedure right way, please help,

    Sketch uses 231649 bytes (24%) of program storage space. Maximum is 958448 bytes.
    Global variables use 32304 bytes (39%) of dynamic memory, leaving 49616 bytes for local variables. Maximum is 81920 bytes.
    warning: espcomm_sync failed
    error: espcomm_open failed
    error: espcomm_upload_mem failed
    error: espcomm_upload_mem failed

    1. I'm not an Arduino man - but it looks to me like a simple case that the board is either not connected, you're not using the right port or you don't have the Sonoff in programming mode....

Leave a Reply

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