How to add slider in blynk to control temperature setpoint


although in the serial monitor show “Failed to read from DHT sensor” , the gauge widget in blynk are showing the temp and humid value correctly. When I slide the slider value below room temp, the relay ON and slide value above room temp the relay went OFF.

p/s: i detected another problem. When put the setpoint into 30 and the room temp went from 29 to 33 (i put at my laptop fan to heat it up), the relay did went ON but when the relay wont went OFF although the room temp went below the setpoint.



Finally some progress.

I will take a look at this.


@Costas thank you very much sir


From your OP I thought you would only need a couple of lines of code and a few minutes of my time. How wrong was I :slight_smile:


@Costas Iam very grateful and appreciate the help you had given to me


it seem that the relay doesn’t response if the temperature changes up and down. It only response only if i move the slider


I coded it that way based on your OP request for slider setting of setpoint. As you have found the sketch is not very practical and needs to be expanded.

From what you have hopefully learnt so far how would you go about resolving this issue?

You don’t have to provide code, just a possible way of implementing a “fix”.


maybe i should add more if statement?


I was looking for a bit more detail than this :slight_smile:

The things you have to consider:

You don’t want the relay going on and off repeatedly when the temperature is around setpoint.

Personally I don’t like code that repeatedly turns a relay on when it’s already on or off when it’s already off. I guess practically this is not really a problem but it’s bad form to repeat a process that’s not actually required.

You need to be thinking about additional timed functions to decide what state the relay should be at, but not at 2 to 5 second intervals.


so relay should response after the sendsensor time interval?


No, much longer than that interval.


should i put the code like this? timer.setInterval(10000L, relaystatuschanged);


Personally I am thinking of 60s or greater for any relay activation. You don’t want click, click, click…


I just figured out how to manually control the relay using button in blynk, but still i had no idea to write code for the relay time interval.