SonOff POW V2.0

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

SonOff POW V2.0

#1 Post by rayE » 17 Aug 2018, 10:22

Hi All,
I have a couple of SonOff POW V2.0 (not revision 2) units and im trying to find a pre-built bin file to test these out. The power sensor chip in these units is a CSE7759 that i believe from data sheets is very similar to the HLW8012 chips found in the V1.0 units, both are VI to frequency converters with slightly different calibration requirements.

I have tried flashing different bin files from different releases but without success in obtaining sensor readings. I have noticed that only _4096 bin files will successfully flash and run, all the _1024 files will flash but cause constant rebooting so im guessing the memory in the units i have is 4mb? I have tried the ESP_Easy_mega-2018xxxx_hard_SONOFF_POW.bin from various builds but these just cause constant rebooting.

Can anyone give me any pointers to a pre-compiled version of ESPEasy that may work with the V2.0 (not revision2) of the SonOff pow?

Thanks all
Ray

User avatar
ThomasB
Normal user
Posts: 1065
Joined: 17 Jun 2018, 20:41
Location: USA

Re: SonOff POW V2.0

#2 Post by ThomasB » 17 Aug 2018, 17:20

If you have the V2.0 (not R2) then I understand it has the HLW8012. The firmware that may work with it is ESP_Easy_mega-2018nnnn_hard_SONOFF_POW.bin. I don't use the Sonoff POW so I can't confirm this firmware works.
- Thomas

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#3 Post by rayE » 17 Aug 2018, 20:54

Hi Thomas,
I have tried ESP_Easy_mega-2018nnnn_hard_SONOFF_POW.bin from a few different builds but it causes my unit to constantly reboot, im guessing it's a memory difference?

Thanks
Ray

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SonOff POW V2.0

#4 Post by TD-er » 17 Aug 2018, 21:50

That build is based on the ESP8266. Try to find out if you're having an ESP8266 or an ESP8285 on that board of yours.

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#5 Post by rayE » 17 Aug 2018, 22:40

I cannot see the number on the ESP chip but it has and external 4mb memory so i assume it's an 8266. Also it all seems ok running the ESP_Easy_mega-20180815_dev_ESP8266_4096.bin. The problem is this build does not have the required device i need. Here is a dump of the system information. Also a pic of the PCB attached.

***My system info*****
Firmware
Build 20102 - Mega
Libraries ESP82xx Core 00000000, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.0.3
GIT version mega-20180815
Plugins 73 [Normal] [Testing] [Development]
Build Md5 998d9482205a7f39bc5bbd6928b33acf
Md5 check passed.
Build time Aug 15 2018 02:18:55
Binary filename ESP_Easy_mega-20180815_dev_ESP8266_4096.bin
ESP board
ESP Chip ID 5147447 (0x4E8B37)
ESP Chip Freq: 80 MHz
Storage
Flash Chip ID Vendor: 0xEF Device: 0x4016
Flash Chip Real Size: 4096 kB
Flash IDE Size: 4096 kB
Flash IDE speed: 40 MHz
Flash IDE mode: DIO
Flash Writes 0 daily / 0 boot
Sketch Size 793 kB (2276 kB free)

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#6 Post by rayE » 17 Aug 2018, 22:45

IMG_5785.JPG
IMG_5785.JPG (645.73 KiB) Viewed 8347 times

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#7 Post by rayE » 17 Aug 2018, 23:13

I can confirm the following regarding the V2.0 board.

Sensor chip = CSE7759, Looking at the data sheet this looks the same as the HLW8012 chip but there will be calibration differences.
RAM = 32mbit = 4mbyte
ESP8266? im sure it is as it has external memory and works with some 8266 builds.

I tried to flash with the following.
ESP_Easy_mega-20180815_dev_ESP8285_1024, this causes constant reboots.
ESP_Easy_mega-20180815_hard_SONOFF_POW, this causes constant reboots.
ESP_Easy_mega-20180815_dev_ESP8266_4096, this works OK but has no device i require.

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#8 Post by rayE » 18 Aug 2018, 14:36

OK, it's now working. I bit the bullet and compiled my own version using arduino. There are some issues maybe down to timing differences and calibration differences between HLW8012 (the plugin im using) and the CSE7759 (the VI chip in the V2.0 SonOff units i have). I will try to work through these issues once i find some English data sheets for both these chips and post back here.

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SonOff POW V2.0

#9 Post by TD-er » 18 Aug 2018, 17:05

rayE wrote: 18 Aug 2018, 14:36 OK, it's now working. I bit the bullet and compiled my own version using arduino. There are some issues maybe down to timing differences and calibration differences between HLW8012 (the plugin im using) and the CSE7759 (the VI chip in the V2.0 SonOff units i have). I will try to work through these issues once i find some English data sheets for both these chips and post back here.
That would be great.
I have plans to make builds with pre-configured settings that just work, for commercially sold boards like the Sonoff POW.
The existing POW build is a very first step towards that, but as you already noticed, it is far from complete.

And now that I come to think of it, it may also be related to the system notification LED. I remember some report last week (?) someone mentioning the only thing he changed was the notification LED and that led (pun intended) to crashes.
So I really have to look into that too.
The Sonoff POW build has the notification LED changed, since it is wired differently on those Sonoff boards.

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#10 Post by rayE » 19 Aug 2018, 09:43

I have no experience with the build process but i guess ill learn, i just followed the tutorial here.
https://www.letscontrolit.com/wiki/inde ... are_Upload

This is what iv done so far.

1. Added this to the first line of ESP.ino file "#define PLUGIN_SET_SONOFF_POW" to provide the minimal set of devices during this testing phase.

2. First i compared the 2 data sheets, the only difference i found was the maximum input level on the VI inputs, EVERYTHING else looks the same, no timing or calibration differences as i first suspected.

3. The "#define HLW_DELAYREADING 500" in "P076_HLW8012.ino" file is currently set at 500mS. From what iv read on the HLW chip this should be a minimum of 2000mS to allow the pulse being measured to settle. The effect of the larger delay is to increase accuracy. I set this to 2000mS and re-compiled, the upshot was better accuracy BUT because of the increased delay this made the web interface painfully slow and also the load indicator on the main GUI screen indicated 100% load. Is there a way to implement an interrupt here instead of a delay loop?

4. I noticed in HLW8012.cpp that the 2 pulse inputs on the ESP chip are set to pull up's, they should just be regular inputs according to the schematic for the SonOff POW. I changed them accordingly, im not sure this made any difference, i think not?

Code: Select all

// pinMode(_cf_pin, INPUT_PULLUP);
// pinMode(_cf1_pin, INPUT_PULLUP);
pinMode(_cf_pin, INPUT);
pinMode(_cf1_pin, INPUT);
Ray

TD-er
Core team member
Posts: 8739
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: SonOff POW V2.0

#11 Post by TD-er » 19 Aug 2018, 19:53

The internal pull-up resistors inside the ESP are resistors with a high value, so the can easily be pulled down when needed.
If there was already communication possible, I guess it will not make much of a difference.

A lot of plugins still use delay to get their timing right. I am working very hard to get rid of all those delays where possible, but haven't started on the Plugins yet.
Using a delay is blocking for other tasks, so this is not the way to do stuff.
If you need to wait, split the code in parts and let it schedule to run when the delay time is over.
If all code did this, the set timers would be quite accurate and you'll get a very responsive ESP that's still processing a lot.

Using delays is throwing away resources.

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#12 Post by rayE » 20 Aug 2018, 01:21

So is it possible to run a timer from within the plugin?

I also notice from the HLW8012.cpp file that it uses

Code: Select all

_voltage_pulse_width = pulseIn(_cf1_pin, HIGH, _pulse_timeout)
, i take it this is a software method? if so then this will also cause blocking on low frequency signals.

All that being said, the application i have in mind will only use this plugin so im thinking your suggestion to split the code into 2 parts and use a timer to run both may free up the resources and make the GUI more responsive. Im tied up with some other work for the next day or 2. Ill put a flow chart together of what im thinking regarding how the code will run and get rid of the delays.

Ray

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#13 Post by rayE » 20 Aug 2018, 03:00

So would this mean 2 plugin's are required or can this be done in one? One thing missing from the drawing is the update timer already present in the plugin, this fits between the re-entry to the loop.........or better still we loose the "bottom" rules timer on the drawing and make the update timer have a minimum update rate of 2 seconds :-)
Attachments
IMG_5786-1.JPG
IMG_5786-1.JPG (576.52 KiB) Viewed 8377 times

rayE
Normal user
Posts: 144
Joined: 12 Oct 2017, 12:53
Location: Philippines

Re: SonOff POW V2.0

#14 Post by rayE » 21 Aug 2018, 13:19

Using a slightly modified plugin 076, running on a heavily modified SonOff POW with a 100A current clamp for the current input. Using very rough calibration of V+I it's looking pretty good, +/- 5%. This is monitoring the main power feed into a site with 5 apartments and 3 small houses in the Philippines. Looking forward to fixing this plugin to make it rock :-)

Sorry i cannot disclose any details on the hardware mods required to use the non intrusive current clamp as this is part a commercial product (maybe). I do not mind sharing details of the driver fix if/when it happens or any other details related to thingspeak :-)

The original firmware provided by SonOff totally SUCKS! i purchased 2 POW units some months back, paired them without problems only to find they connect to local WiFi no probs BUT have one HELL of a problem connecting with the SonOff cloud server (maybe around 50% of the time, if the wind is blowing in the right direction)................totally USELESS in my opinion, thank god for ESPeasy and thingspeak, they ROCK!

https://thingspeak.com/channels/562022

Ray
Attachments
sct-013-000.jpg
sct-013-000.jpg (5.21 KiB) Viewed 8333 times

Post Reply

Who is online

Users browsing this forum: No registered users and 46 guests