Hi,
I want to make a measurement!
The gas boiler turns on a relay (230VAC), whose independent pole output short-circuits the input of a nodemcu (D5).
The time should be measured in the tightened state, when the relay pulls and drops!
What is the rule for this, because I couldn't find one!
Since the gas boiler has a fixed consumption, the consumption can be recovered from the time!
I look forward to your ideas
Csaba
relay operating time measurement
Moderators: grovkillen, Stuntteam, TD-er
Re: relay operating time measurement
I've recently added some example code, based on an answer to a very similar question, to the documentation in a pull request on Github, over here. This hasn't been merged yet, but it is quite readable, IMHO.
The example was based on this thread
The example was based on this thread
/Ton (PayPal.me)
Re: relay operating time measurement
Not sure if you succeeded in writing the rules to handle this, but I saw a chance to add another example to the documentation, so I built this:
- Add the Generic - Dummy Device, as described in the code
- Adjust the On TransmitPower Do event so the data gets sent where you need it, or comment out the code if it doesn't have to be transmitted
- After pasting this code in a Rules file either reboot the ESP, or run command event,System#boot to initialize the Monitor command and the power value in Watt (you may have to adjust that to your situation)
(check if you don't already have a On System#Boot Do event in there, if so, add the code from this one to your existing On System#Boot code, and leave the code from this example out)
- Add the Generic - Dummy Device, as described in the code
- Adjust the On TransmitPower Do event so the data gets sent where you need it, or comment out the code if it doesn't have to be transmitted
- After pasting this code in a Rules file either reboot the ESP, or run command event,System#boot to initialize the Monitor command and the power value in Watt (you may have to adjust that to your situation)
(check if you don't already have a On System#Boot Do event in there, if so, add the code from this one to your existing On System#Boot code, and leave the code from this example out)
Code: Select all
// Uses a Generic - Dummy Device, name: Power, output data type: Dual, first value: Seconds (0 decimals), second value: PowerUsed (4 decimals)
On GPIO#14 Do // GPIO-14 = D5 on Wemos boards
If %eventvalue1%=0 // On state
Let,1,%syssec_d% // Store current nr of seconds of today in var#1
Else // Off state
Event,CalcPower // Don't queue
AsyncEvent,TransmitPower // Send out to receiver
Endif
Let,5,!%eventvalue1% // 0 = On, to invert on/off state change to: Let,5,%eventvalue1%
LogEntry,"Power [int#5#O#C], measured: [Power#Seconds] sec. [Power#PowerUsed#d.4] kWh"
Endon
On CalcPower Do
TaskValueSet,Power,Seconds,[Power#Seconds]+%syssec_d%-[int#1] // Add run time to Power#Seconds
Let,4,[Power#Seconds]*[var#3] // Wattseconds
If [var#4]>0
TaskValueSet,Power,PowerUsed,[var#4]/3600000 // Wattseconds to kWh
Endif
TaskRun,Power
Endon
On TransmitPower Do
// Send value of [Power#Seconds] and [Power#PowerUsed] to wherever you need it, adjust as needed
PostToHTTP,192.168.1.20,8080,/receiver.php,'','%lcltime% !!! Total RunningTime = [Power#Seconds] Seconds, PowerUsed = [Power#PowerUsed] kWh'
Endon
On Clock#Time=All,00:00 Do // At midnight
// Include power used until midnight
If [Plugin#GPIO#PinState#14]=0 // Still on?
Event,CalcPower // Don't queue
Endif
Let,1,0 // Reset start time
Event,TransmitPower // Send out remainder of the day immediately
TaskValueSet,Power,Seconds,0 // Reset total counter
TaskValueSet,Power,PowerUsed,0 // Reset total power
Endon
On System#Boot Do
Monitor,gpio,14 // Generate an event when the GPIO state changes
Let,3,250 // Wattage of the load, adjust as needed
Endon
/Ton (PayPal.me)
Re: relay operating time measurement
Hi,
Thanks for the help!
The program is very good as a starting point.
Csaba
Thanks for the help!
The program is very good as a starting point.
Csaba
Re: relay operating time measurement
Thanks, you're welcome
Instead of the 'kWh' unit I used, you can of course use 'kCal/hr' or your measure of choice for the heater-used energy, you probably need to adjust the calculation factor for that
Instead of the 'kWh' unit I used, you can of course use 'kCal/hr' or your measure of choice for the heater-used energy, you probably need to adjust the calculation factor for that
/Ton (PayPal.me)
Who is online
Users browsing this forum: Bing [Bot] and 35 guests