POW, TH16 AND DUAL

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

Facebooktwittergoogle_pluspinterestlinkedin

38 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. 🙂

      Pete.

      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?
    Thanks,
    Neil.

    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,

    warnings:
    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....

    1. Hi Peter, I really like your blog and it has helped me greatly! Thanks!
      I'm currently stuck with a project incorporating a Sonoff Dual as an electric blinds control. For that I need the two channels to be mutually exclusive on at any time. When doing this wirelessly, that's no issue as I can make sure of that in the relay control code, but a problem arises when also using the buttons 0 & 1.
      I can successfully read the buttons and control the relays accordingly, BUT since the F330 has it's own idea about controlling the relays when a button press is detected things get a bit messy especially in case of race conditions which makes it rather hard to ensure the mutual exclusivity of channels.
      Have you got an idea how to prevent the F330 to control the relays on button press but only obey to control commands issued by the ESP8266?

        1. SIL F330 is the helper chip that does the relay and button control on the Sonoff Duals. It communicates with the ESP8266 via RX/TX in a 4-byte-protocol (read/write 0xA0 0x04 0x## 0xA1)

          In your photo of the bottom side of the three devices on the most left (this is the Dual) you've got the ESP8266 (top left), then the 8Mbit flash (top middle) and finally the F330 (top right).

  11. A question for those with experience with the Sonoff's, specifically the POW. I'm taking delivery of a new kitchen. I'm very interested to keep an eye on the biggest consumers and that certainly includes the microwave/oven. I was thinking to put a Sonoff POW behind it. The maximum current matches that specification exactly. So I read it's advised not to go to the maximum. I do however wonder whether that means I should just not pursue with my idea. Will an oven really run at it's maximum rated power? Will the Sonoff be reliable (note, it'll not be straightforward to get to it once installed...)? I'm interested in your thoughts.

    1. Oh, absolutely DO NOT go to the maximum. Just... don't. Get a contactor that will handle at least 50% more than you need and use the Sonoff or similar to fire that off. Now, I've not used these so someone feel free to prove me wrong - but this job here... won't exactly break the bank..

      http://www.ebay.co.uk/itm/JZC4-22-220-240V-50-60Hz-Coil-20A-2P-Three-Pole-2NO-2NC-AC-Contactor-SE-/122299886557?hash=item1c79a42bdd:g:ivEAAOSwImRYbsAU

      Actually the smallest Sonoff will power one of these without losing a breath.

      As you go for even higher current the cost seems to get out of hand but that one looks ok at first glance.

  12. Thanks! Well, clear, I will drop the initial idea. Indeed, using a contactor would defeat the purpose. I suppose I'm then better off using just current sensing such as with an emontx from the openenergymonitoring project.

  13. My idea: We have a 2 gang light switch in the kitchen. My GOAL is to install a SONOFF DUAL into a new electrical box above the installed switches (see example One picture) where the top item would be replaced with a DUAL.
    image

    The DUAL would be mounted like in the second picture:
    image

    A clear cover would be used so that the wifi signal could be received.

    I think this would allow us to control both lights from our Echo Alexa. Does this sound practical?

      1. If I were faced with an Alexa which was not responding - I'd pair it and check with the phone - the Alexa app. I think you hold the button with the dot for a while.... at least with the little version.

          1. So put manual controls in? At the end of the day most of these techniques end up turning a relay on or a MOSFET unless you go and buy stuff like Philips bulbs which you probably have no manual control over...

            Just put a switch over the relay etc for manual override.

  14. Hope someone can give a little advice.
    i wanted to get a dual pow 16 amp to use on an electric stove type fire (looks like a log burner).
    the fire rating on the back is stated at 220-240v 1850w (13 amp at the wall)
    the flame effect light would always be on but they are only 4 x 3w led bulbs
    the part i want to use the dual pow with are the 3 switches (1 x fan blower 2 x heater switches) the fan as to be on otherwise the heater switches don't work , either switch can be used to turn on half the heat output, turning on the second doubles the heat, so im assuming i can have each heater on on its own output, but the question is would it be safe to add the fan to the first output along with the first heat element.

    i wanted to still use the switches as a manual override also which i hope also wouldn't be a problem

    would the sonoff dual pow be safe to use like this

    the heater is underneath the fire and the sonoff will be placed near the top of the fire so around 18inches away so i assume it shouldn't get to hot from the heat, infact at present the top remains cold so that part should be fine.

    any help appreciated

Leave a Reply

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