Page 1 of 1

ESP Easy and POW R2

Posted: Monday 18 June 2018 11:45
by Prutsium
Hello all,

I started already a topic on the ESPEasy forum in regards of the support for the POW R2 and this is implemented now.
But i run in some issues mainly related to Domoticz.

First as ESPEasy sends all 4 values to 1 IDX i had to split them up and thats perfectly working via:

Code: Select all

On POW_2_Sensors#POW_2_Voltage do
SendToHTTP 192.168.99.5,8080,/json.htm?type=command&param=udevice&idx=93&nvalue=0&svalue=[POW_2_Sensors#POW_2_Voltage] //Send the Voltage data to Domoticz
SendToHTTP 192.168.99.5,8080,/json.htm?type=command&param=udevice&idx=94&nvalue=0&svalue=[POW_2_Sensors#POW_2_Power] //Send the Watt data to Domoticz
SendToHTTP 192.168.99.5,8080,/json.htm?type=command&param=udevice&idx=95&nvalue=0&svalue=[POW_2_Sensors#POW_2_Current] //Send the Amp data to Domoticz
SendToHTTP 192.168.99.5,8080,/json.htm?type=command&param=udevice&idx=96&nvalue=0&svalue=[POW_2_Sensors#POW_2_Pulses] //Send the Usage data to Domoticz
endon
And i am able to get all the 4 values in Domoticz.
The tricky part comes for the pulse counter. As ESPEasy is using an rotating pulse counter that counts from 0 - 65535 and then restarts at 0 it seems Domoticz is not able to handle that. (As far as i could figure out 12530 pulses would be 1KW) https://github.com/letscontrolit/ESPEas ... SE7766.ino

Anybody a clue how to add this rotating pulse counter as power meter to Domoticz?

Re: ESP Easy and POW R2

Posted: Monday 18 June 2018 11:56
by jake
By adding a couple extra lines to your script: put the current counter in a variable and compare next time. If new < old then usage is (new+65k) - old. New pulse value is current pulse value + usage.
Only send that calculated value to the domoticz idx.

Re: ESP Easy and POW R2

Posted: Monday 18 June 2018 12:44
by Prutsium
jake wrote: Monday 18 June 2018 11:56 By adding a couple extra lines to your script: put the current counter in a variable and compare next time. If new < old then usage is (new+65k) - old. New pulse value is current pulse value + usage.
Only send that calculated value to the domoticz idx.
Not sure how to do that within ESPEasy .....

Re: ESP Easy and POW R2

Posted: Thursday 21 June 2018 15:48
by Prutsium
Btw ... this is how Domoticz handles right now the incoming data from the POW (R2)
Image

Keep in mind i did not set any divider yet but its clear to see its not adding but just restarting the counter.

Re: ESP Easy and POW R2

Posted: Sunday 24 June 2018 20:39
by sincze
Prutsium wrote: Monday 18 June 2018 12:44
jake wrote: Monday 18 June 2018 11:56 By adding a couple extra lines to your script: put the current counter in a variable and compare next time. If new < old then usage is (new+65k) - old. New pulse value is current pulse value + usage.
Only send that calculated value to the domoticz idx.
Not sure how to do that within ESPEasy .....
I guess this pointer is for ESPEasy to create a rule under rules to do this for you.
Rules are explained on the https://www.letscontrolit.com/wiki/inde ... rial_Rules

Store the 'old' values in a ESP Task with HW Dummy and do the calculation.
Currently I haven't prepared my R2 with ESPEASY as I did not notice the progress that it actually works ;-) now.

Re: ESP Easy and POW R2

Posted: Sunday 29 July 2018 18:38
by sincze
Indeed it is working. POW R2.
Fun part is that the manual is totally wrong regarding the connections.... :oops:
Its L GG L N N in my case looking at it from the front.
Luckily it was mentioned on the PCB as well.

Now I will extract the data using rules and store them in several devices in Domoticz. :D
Sonoff POW R2.JPG
Sonoff POW R2.JPG (47.06 KiB) Viewed 9674 times

Re: ESP Easy and POW R2

Posted: Sunday 29 July 2018 18:49
by Prutsium
sincze wrote: Sunday 29 July 2018 18:38 Indeed it is working. POW R2.
Fun part is that the manual is totally wrong regarding the connections.... :oops:
Its L GG L N N in my case looking at it from the front.
Luckily it was mentioned on the PCB as well.

Now I will extract the data using rules and store them in several devices in Domoticz. :D
Sonoff POW R2.JPG
Let me know the progress as i switched to Tasmota right now and actually that works flawless and at least support bi-directional MQTT/

Re: ESP Easy and POW R2

Posted: Sunday 29 July 2018 20:36
by sincze
@Prutsium: Guess you were looking for the KwH right? Or different value? As you mentioned the pulses. I'll be sending the data every 30 sec of 1 minute we can do something with that or count the amount of pulses indeed over a time period and look at the difference.
Sonoff POW R2-vpc.JPG
Sonoff POW R2-vpc.JPG (87.36 KiB) Viewed 9657 times

Re: ESP Easy and POW R2

Posted: Sunday 29 July 2018 21:06
by Prutsium
sincze wrote: Sunday 29 July 2018 20:36 @Prutsium: Guess you were looking for the KwH right? Or different value? As you mentioned the pulses. I'll be sending the data every 30 sec of 1 minute we can do something with that or count the amount of pulses indeed over a time period and look at the difference.

Sonoff POW R2-vpc.JPG
Yupp the Total usage (pulses) as they are a rolling counter (goes to 65xxx and then back to 0) You must do a lot of tricks to get them stored.
Thats why i went on the dark side of Tasmota (i run about 25 different devices with ESP Easy in my house but only the ones requiring current or bi-directional MQTT are on Tasmota)

With Tasmota its plug and play for the POW(R2) and for the bi-directional MQTT i need it on some devices due power outages so when they come back (pi runs on a UPS but not the plugs) Domoticz will set them back to their old state (MQTT Remain state) Since in ESP Easy its not possible to send data to it over MQTT.

Re: ESP Easy and POW R2

Posted: Sunday 29 July 2018 21:37
by sincze
Prutsium wrote: Sunday 29 July 2018 21:06
sincze wrote: Sunday 29 July 2018 20:36 @Prutsium: Guess you were looking for the KwH right? Or different value? As you mentioned the pulses. I'll be sending the data every 30 sec of 1 minute we can do something with that or count the amount of pulses indeed over a time period and look at the difference.

Sonoff POW R2-vpc.JPG
Yupp the Total usage (pulses) as they are a rolling counter (goes to 65xxx and then back to 0) You must do a lot of tricks to get them stored.
Thats why i went on the dark side of Tasmota (i run about 25 different devices with ESP Easy in my house but only the ones requiring current or bi-directional MQTT are on Tasmota)

With Tasmota its plug and play for the POW(R2) and for the bi-directional MQTT i need it on some devices due power outages so when they come back (pi runs on a UPS but not the plugs) Domoticz will set them back to their old state (MQTT Remain state) Since in ESP Easy its not possible to send data to it over MQTT.
Ok so we got the amount of pulses between measurements. I guess??
Sonoff POW R2-pulses.JPG
Sonoff POW R2-pulses.JPG (67.91 KiB) Viewed 9650 times

Re: ESP Easy and POW R2

Posted: Monday 30 July 2018 8:49
by Prutsium
sincze wrote: Sunday 29 July 2018 21:37
Prutsium wrote: Sunday 29 July 2018 21:06
sincze wrote: Sunday 29 July 2018 20:36 @Prutsium: Guess you were looking for the KwH right? Or different value? As you mentioned the pulses. I'll be sending the data every 30 sec of 1 minute we can do something with that or count the amount of pulses indeed over a time period and look at the difference.

Sonoff POW R2-vpc.JPG
Yupp the Total usage (pulses) as they are a rolling counter (goes to 65xxx and then back to 0) You must do a lot of tricks to get them stored.
Thats why i went on the dark side of Tasmota (i run about 25 different devices with ESP Easy in my house but only the ones requiring current or bi-directional MQTT are on Tasmota)

With Tasmota its plug and play for the POW(R2) and for the bi-directional MQTT i need it on some devices due power outages so when they come back (pi runs on a UPS but not the plugs) Domoticz will set them back to their old state (MQTT Remain state) Since in ESP Easy its not possible to send data to it over MQTT.
Ok so we got the amount of pulses between measurements. I guess??
Sonoff POW R2-pulses.JPG
Yes but also did you handle the fact that the total pulses will jump to 0 when they reach 65xxx? So you must create a virtual Previous + New.

Re: ESP Easy and POW R2

Posted: Monday 30 July 2018 11:02
by sincze
Prutsium wrote: Monday 30 July 2018 8:49
Yes but also did you handle the fact that the total pulses will jump to 0 when they reach 65xxx? So you must create a virtual Previous + New.
Yes I did, that was the tricky part right ??
Store the value of the pulses in new variable and then the magic starts.
It was described a few posts back on how to do it.

Now I need to figure out what we want to do with the pulses. :D

Re: ESP Easy and POW R2

Posted: Monday 30 July 2018 18:46
by sincze
I've been looking into Tasmota as well. Pretty nice.
I'll backup my configuration for now and try Tasmota,
But maybe not I'm not using MQTT.. Nor MQTT Client..

Tasmota:

Code: Select all

Message   | Unit | Description
----------|------|-----------------------------------------------------
Total     | kWh  | Total Energy usage including Today
Yesterday | kWh  | Total Energy usage between 00:00 and 24:00 yesterday
Today     | kWh  | Total Energy usage today from 00:00 until now
Period    | Wh   | Energy usage between previous message and now
Power     | W    | Current power load
Factor    |      | The ratio of the real power flowing to the load to
          |      |   the apparent power in the circuit 
Voltage   | V    | Current line voltage
Current   | A    | Current line current

Re: ESP Easy and POW R2

Posted: Monday 30 July 2018 20:05
by sincze
If you just create a virtual sensor Electric (Instant+Counter).

Open the sensor and select 'computed'.
https://www.domoticz.com/wiki/Domoticz_ ... counter.29 it can help to monitor the kwh.
1
1
Sonoff POW R2-kwh.JPG (19.36 KiB) Viewed 9576 times
In this case I just see no usage anymore for the pulse counting.

Any suggestions?

I now have:
2
2
Sonoff POW R2-kwh-final.JPG (50.57 KiB) Viewed 9576 times
tnx.

Re: ESP Easy and POW R2

Posted: Tuesday 16 October 2018 8:05
by michass
Hi, is there compiled packege for POW R2?
Please tell me, which is proper for this item

Re: ESP Easy and POW R2

Posted: Tuesday 16 October 2018 8:46
by Prutsium
michass wrote: Tuesday 16 October 2018 8:05 Hi, is there compiled packege for POW R2?
Please tell me, which is proper for this item
Just grab Tasmota this is the most easy way to get the values into domoticz (MQTT Required)

Re: ESP Easy and POW R2

Posted: Tuesday 16 October 2018 9:14
by michass
Thanks, but my hardware (NAS) are not compatible with mosquitto yet.
I need to use HTTP communication with Domoticz.

Re: ESP Easy and POW R2

Posted: Tuesday 16 October 2018 11:35
by sincze
michass wrote: Tuesday 16 October 2018 9:14 Thanks, but my hardware (NAS) are not compatible with mosquitto yet.
I need to use HTTP communication with Domoticz.
Please Have a look at [http://www.letscontrolit.com/forum/viewtopic.php?t=5246]

Did the job for me just fine. Still up and running.