Ok, this entry will be in 2 parts – I’ll do some digging soon – but as I’ve had several requests for this…
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.
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.
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.
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
I’m a bit late to the party, but my POW (in 2018) definitely has a 4Mb Flash.
I think you are right about the 25% overhead, as when I peeled the sticker off the “16A” relay, it is actually a 10A device. The datasheet shows it rated to 16A max. I’d have preferred a little more headroom, especially on a 3kW water heater, but they are made to be cheap!
From now on, I’ll be using the POW on most projects due to…
1) 4Mb flash as standard
2) Power monitoring on eWeLink app is great
3) the connectors are sturdier than the screw terminals (my last classic, I ripped one off by accident and had to solder on fly-leads, and then used Wago connectors)
4) Earth terminals included
What I really want is the power monitoring of the POW with the 2.5mm jack of the TH16. From what I can tell, there is no device with both
because as how’s made the POW, it’s better you stay away from its GPIOs… do a quick search on tasmota or espurna wikis and you’ll see…
Later models of the Basic have a 5 pin programming header one of which exposes GPIO14. If you flash with something like Tasmota it is already configured to be controlled via MQTT and can be an LED or buzzer as long as you respect the power restraints on the ESP8266 pins.
but you’ll need an external controller, like nodered, or compile your own version and enable RULES…
https://github.com/arendst/Sonoff-Tasmota/wiki/Rules
or use espeasy, which has already rules builtin (you just need to enable them in the ADVANCED config page, no need to recompile)…
https://www.letscontrolit.com/wiki/index.php/Tutorial_Rules
is there anyway to modify a sonoff basic or dual to allow me to give the user some indication that the power is going to be switched off shortly ? Like control a flashing warning light or emit a small sound a couple of minutes before actually switching off the power ?
Specifically, i want to use one to stop my son watching TV after a certain time at night. but rather than just turn it off, id like to give him some warning a few minutes before that the TV is going off shortly ! I assume i might need a sonoff dual and seperately control some kind of light or speaker circuit but as the sonoff already has lights on it for wifi pairing, is it possible to control them via software to flash them ? or maybe i need an extra bit of circuity connected to a sonoff dual.
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
Hi. I had a bad experience with the POW. Was using it to log spa pool power use. It ended up melting a bit but luckily I smelt it before it created a fire! The max current for the spa was 13A (@240V) confirmed using a meter. These devices use soldiered tracks on the board so subject to variability at manufacture. So the answer is it depends. I think for short use they might be OK. I certainly wouldn’t install in a wall etc.
If you don’t need to measure power, best to use a small contactor and the sonoff to switch that.
Why are you pushing 13 amps through the POW? if that is typical power, peak when cold will be even higher. I would be using a contactor for that kind of heating power.
and i would add an inline fuse holder to such a setup, for better security…
https://it.aliexpress.com/item/1pcs-waterproof-auto-inline-Mini-In-Line-Fuse-Holder-1pcs-Fuse-Inserts/32815891159.html
https://it.aliexpress.com/item/New-12v-400mA-AC-DC-Supply-Buck-Converter-Step-Down-Module-Convertible-adaptor-Transformer/32829435196.html
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?
What do you do when Alexa/WiFi is not working. There are no on/off buttons on that device.
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.
My point was more about the practicality of a light switch that you cannot override manually
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.
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.
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.
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.
i think this way he looses the purpose of using the POW, so measuring actual power consumption 🙂
but you’re absolutely right, safety first…
Those using the POW and TH16 might want to take notice – a potentially dangerous situation?
https://www.itead.cc/blog/sonoff-th16-and-pow-recall-notice
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?
just off to the market – more later. F330?
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).
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
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….
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
I just use the standard Chinese rip-offs – the red ones on Ebay with the link – you need that an a mini-usb cable…
This looks like the job
http://www.ebay.co.uk/itm/Serial-Adapter-Module-FT232-FTDI-USB-TTL-Arduino-Pro-Mini-Breakout-Flux-Workshop-/111602651798?hash=item19fc095296:g:ZDwAAOSwxYxU0f0d
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!
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.
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.
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
Solved! with a 3.3V external power source.
first tests and hacks, by Andreas Spiess: https://www.youtube.com/watch?v=hv_FpBqWFrg
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.
Ebay… 5 for £3.73 – 5PCS W25Q32BVSIG W25Q32BVSIG SOP8 WINBOND
Cheers Peter. I found them locally at a slight higher price but at least I don’t have to wait around 3-4 weeks for them.
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
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.
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?
Yes – just avoid the temptation to stick other stuff on!
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)
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.
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.”
Their logo may be wrong, but their test reports and certifcates are real, that’s all that matters:
http://dl.itead.cc/CE-RoHS/ITEAD-Sonoff-Series-CE-RED-RoHS-Certificate-and-Report.zip
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.
Hi Pete,
Great write up as usual, Found this while searching for pow device.
https://github.com/arendst/Sonoff-MQTT-OTA-Arduino/blob/master/sonoff/power.ino
Hopefully this will help.
Regards
Paul
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