Temp cycle counts

Hi all, I have tempreture being monitored using brainboxes units being sent to node red.

I would like to count how many time these temps went over 100 degrees. This is a heated press and I'd like to use the temps to count the heating cycles essentially giving me the product through put.

Welcome to the NR-Forum
I am not sure I understand your requirement exactly, but will this do ?

[{"id":"6766281d2a46243c","type":"inject","z":"223ecfacc7a6462f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"101","payloadType":"num","x":370,"y":170,"wires":[["6399777de74131b3"]]},{"id":"f76347345a0a06fa","type":"inject","z":"223ecfacc7a6462f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"90","payloadType":"num","x":370,"y":230,"wires":[["6399777de74131b3"]]},{"id":"6399777de74131b3","type":"switch","z":"223ecfacc7a6462f","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gte","v":"100","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":570,"y":200,"wires":[["c17e290758dc7b6e"]]},{"id":"6407583b6bb4e0e8","type":"inject","z":"223ecfacc7a6462f","name":"Reset to Zero","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":100,"wires":[["c17e290758dc7b6e"]]},{"id":"c17e290758dc7b6e","type":"counter","z":"223ecfacc7a6462f","inc":1,"name":"","x":770,"y":180,"wires":[["b945946d57f3761d"]]},{"id":"b945946d57f3761d","type":"debug","z":"223ecfacc7a6462f","name":"debug 2474","active":true,"tosidebar":false,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":950,"y":180,"wires":[]}]

I have used a contrib node


You would create a boolean from temp over 100 and then increase count when true, with a filter node to count on change.

[{"id":"f92d2086f260e277","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":90,"y":2600,"wires":[["a285eff6489e8bf4"]]},{"id":"cfb2073f6d65572b","type":"inject","z":"d1395164b4eec73e","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"101","payloadType":"num","x":110,"y":2660,"wires":[["a285eff6489e8bf4"]]},{"id":"a285eff6489e8bf4","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"temp_bool","pt":"msg","to":"$$.payload > 100 ? true : false","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":2620,"wires":[["516ed5bdfebfa26a"]]},{"id":"516ed5bdfebfa26a","type":"rbe","z":"d1395164b4eec73e","name":"","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":410,"y":2620,"wires":[["4521bcf9b4df41d2"]]},{"id":"4879731ff71c6917","type":"change","z":"d1395164b4eec73e","name":"","rules":[{"t":"set","p":"temp_count","pt":"flow","to":"$sum([$flowContext(\"temp_count\")]) + 1","tot":"jsonata"},{"t":"set","p":"payload","pt":"msg","to":"temp_count","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":2620,"wires":[["d69d9dbd24a1f0cf"]]},{"id":"d69d9dbd24a1f0cf","type":"debug","z":"d1395164b4eec73e","name":"debug 2460","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":670,"y":2660,"wires":[]},{"id":"4521bcf9b4df41d2","type":"switch","z":"d1395164b4eec73e","name":"","property":"temp_bool","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":2620,"wires":[["4879731ff71c6917"]]}]

I have solid fuel boiler which needs cleaning time to time. I do count heating cycles to send reminder message that it is time to clean it.
It is a bit more complex that just count when it is over high threshold because of different amount of stuff to burn produces different kind of temeratures and cycles.

It uses global context to store the state.

// cycle is complete when temerature has been over the high threshold and then cooled down below low limit.

let cct = global.get('cct') || { cycles: 0, max: Number.MIN_SAFE_INTEGER, threshold: { lo: 44, hi: 65 }, limit: 20 }
let temp = msg.payload
let state = ""
const between = (x, min, max) => { return x >= min && x <= max; };

if (between(temp, cct.threshold.lo, cct.threshold.hi)) {
    // between hi and low. do nothing, just show correct node status
    state = "between"
else {
    if (temp > cct.threshold.hi) {
        // over high threshold. store max
        state = "high"
        if (cct.max < temp) {
            cct.max = temp
            global.set("cct", cct);
    else {
        state = "low"
        if (cct.max > cct.threshold.lo) {
            //cycle is complete. store state and send message
            cct.max = Number.MIN_SAFE_INTEGER
            global.set("cct", cct);
            node.send({ payload: cct, topic: 'cct', to: "dash" })

            if (cct.cycles > cct.limit) {
                // over the limit of cycles. send some kind of warning message  
                node.send({ payload: cct, topic: 'cct', to: "signal" })

node.status({ fill: "green", shape: "dot", text: 'cycles: ' + cct.cycles + " | " + "state: " + state + " | " + temp.toFixed(1) + "°c" });

Thanks you all for the feedback, i'll have a look at these .

Thankyou E1cid

The flow looks to work by counting a temp over 100 and outputs a 1. it then only counts again when the temp goes down to 10 and then goes back up to 100. This enables me to count the oven curing profiles and how many times its gone through a cycle.


It counts when over 100 and then will reset if below 100 not 10, if you want to set a lower limit the msg.temp_bool expression would need modifying.

Yes, thankyou, I see now.

The reset is the key thing for me, allowing it to only count the once when above the setpoint. Fortunately in my case I have the cycle go to high temp once and then lower.

Thankyou, where do input this code.

You say this would just count the heating cycles?. The other solutions, gratefully received count continuously once over a value. I'm just looking for a single count when a temp of 145 is reached. Then not to count again until the temp has gone down and this temp is then seen again on the next cycle.

The code is content of the function node which then expects single value on msg.payload representing the teperature.

There are some drawbacks when making decision by only one threshold point. For example this kind of situation:

red line as the threshold and blue line as the temperature curve.

Depending on reset strategy you may get many readings which may actually be false positives.

It all depends. But knowing practically nothing about your cycle parameters, it is not possible to give solid advise. It takes to know many more things and most cases deeper analyse of data.

1 Like

Thanks for the response,

The cycle is very the opposite to what you have drawn. the highest temp is actually the last part of the cycle. so I thought it would be good to capture at 5 degrees below the max temp as this in reality pretty much there as I'm only requiring cycle counts. Is there a way to only have it output one reading so it would only catch 140 degrees.

This may be something that's found in influx or Grafana for cycle counts. i was hoping to manage this aspect in node red though.

Can you make a graph of your cycles? Like 10 consecutive cycles to make more educated guess about what kind of edge cases may come into play..

Please see pic. This is the cycle.

To accomplish something similar, I use the "Rising Edge" and "Falling Edge" nodes to alert for unexpected temperatures in some small walk-in freezers and coolers. I'm taking a temperature reading every 5 minutes via MQTT and averaging the last 5 readings (to allow for temperature fluctuations due to defrost cycles, door open for several minutes due to restocking, etc.). If that average rises above or below my setpoints, the "Edge" nodes trigger a "Change" node that formats a message that is then passed to the "SMS" node which sends a txt message to the owner and the manager. A second message is sent once the temperature re-enters the desired range.

Thanks Nokomis, that's a great take on it. Rather then looking for a temp point I can look for a rise over time and have try a count based on that.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.