Energy Counter based on GPIO Output?

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Energy Counter based on GPIO Output?

#1 Post by Oetsch » 18 Jun 2021, 16:04

Hi
I´m operating a fridge based on ESPEasy with it´s level controler. The status of the 2-point controler is transfered by Mqtt and the energy consumption is calculated in the home automation system (iobroker). During some months of stable operation and my steady intention to check if sth. can be improved I do not like the missing energy information when the MQTT information gets lost. Therefore I think it might be better to calculate the energy consumption directly in espeasy and send this valvues by MQTT. In case the connection is disturbed this might have no big impact because the right values are transfered suddenly when the connection is up again.

But in case the energy is calculated in ESPeasy can the calculation result be stored also in case espeasy is rebooted?
The calculation itself is easy because the fridge always consumes 95W when it is switch on.

Try to find sth similar but haven´t found so far. Do you have hint if there is sth to reuse for me?

Big Thx!

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

Re: Energy Counter based on GPIO Output?

#2 Post by TD-er » 18 Jun 2021, 17:51

As long as the ESP remains powered, you can store the values in a dummy task.
Task values are stored in RTC memory which is kept during a reboot and restored at boot.

Accessing dummy task values can be done in the rules, so you can store data in there using taskvalueset and just use the values with the [taskname#taskvaluename] syntax.

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: Energy Counter based on GPIO Output?

#3 Post by Oetsch » 21 Jun 2021, 18:57

Thank you very much.
So far it works but according your description only in case power supply still exists.

Is there any other possibility to keep the values also during power shutdown like a mechanical energy counter?

My current rule looks like this:

Code: Select all

on System#Boot do
Monitor GPIO,9
endon

on GPIO#9=0 do
  timerSet,1,0                    // stop and reset timer 1
  Let,1,0                         // reset timer runtime   
endon

on GPIO#9=1 do
  timerSet,1,1
endon

On Rules#Timer=1 Do
   Let,1,[VAR#1]+1                 //runtime of timer
   Let,2,[energycounter#energy]    //get old energycounter value
   Let,3,[VAR#2]+95               // calculate new energy consumption in Ws (95W consumer)
   TaskValueSet 4,1,[VAR#3]
  Publish %sysname%/Energy/Energy,[energycounter#energy]"
  timerSet,1,1
endon

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

Re: Energy Counter based on GPIO Output?

#4 Post by TD-er » 21 Jun 2021, 20:17

There might be one, but it is a bit tricky and not without risk.

The level plugin can be used to store its settings to flash.
It is still on my todo list as that's wearing out the flash.
But if you write to the flash once a day, then I guess you could get away with it.

Oetsch
Normal user
Posts: 195
Joined: 13 Jul 2020, 12:10

Re: Energy Counter based on GPIO Output?

#5 Post by Oetsch » 22 Jun 2021, 08:48

Thanks this gives me a good indication and I´ll keep having a look at the ESPEasy releases.

In between will implement a check in the automation system what counter values are transfered from the ESP unit and do appropriate calculations. So keep the "master energy counter" in the central system. By this change I have added tolerance against single failure of missed signals or temporary faulty wifi network which make sence and gives value for me.


By the way regarding dummy devices. I recognized a difference in the current release from 03.05.2021 and the release of 23.02.2021. In the older release it is possible to check/activate "send to controler" for the dummy device. In the release from 03.05. isn´t the checkbox available and have to do unit manually (publish).

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

Re: Energy Counter based on GPIO Output?

#6 Post by TD-er » 22 Jun 2021, 10:14

Oetsch wrote: 22 Jun 2021, 08:48 [...]
By the way regarding dummy devices. I recognized a difference in the current release from 03.05.2021 and the release of 23.02.2021. In the older release it is possible to check/activate "send to controler" for the dummy device. In the release from 03.05. isn´t the checkbox available and have to do unit manually (publish).
That's a bug for sure...

Post Reply

Who is online

Users browsing this forum: No registered users and 33 guests