How to set a target temperature to control a heater

I want to maintain water temperature using an ESP8266 (Arduino-like)

I have a temperature sensor (ds1820) working, which measures the current temperature and a relay to switch a heater on and off.

I use one trigger to switch the heater on when the water temp falls below TARGET TEMP and another trigger to switch the heater off once the temperature rises above TARGET TEMP +1 degree celsius.

My issue is; how to have a widget on my dashboard where I can set the TARGET TEMP and then pass that value to the triggers.

So far I’ve read to use a custom slider widget, set to PWM, on a virtual pin. The code behind this widget reads the slider value and stores it in a variable.
The widget created this code:

#define PWM_VIRTUAL_PIN 1
#define PWM_DIGITAL_PIN 3 (don’t think I need this?)

CAYENNE__IN(PWM_VIRTUAL_PIN)
{
int currentValue = getValue.asInt(); // 0 to 1023
analogWrite(PWM_DIGITAL_PIN, currentValue / 4); // must be from 0 to 255 (what does this part do??)
}

But as a newbie, I don’t know what next!

How do I pass the value in that variable to the triggers?

Please write slowly as I cannot read fast.

1 Like

Hello, I like your idea but I am not sure that this is possible right now with Cayenne…
I think that if you hardcore your logic to turn on/off bellow some $variable and then send values to this variable from the Cayenne dashboard will works!

@ognqn.chikov is right, currently there is no way to use a variable trigger, you must edit the trigger.