As I said, you can share the 'currentTime' variable.
Jay_Swan:
I have change names for some timers but I am not comprehending why it is going erratic like that
What do you mean by 'erratic'? Does the code not work? If so describe what you expect and describe what actually happens.
Maybe compare the two code parts
if (startdataTime == 0)
{
startdataTime = currentdataTime;
...
...
versus
if (startcycleTime == 0)
{
currentcycleTime = startcycleTime;
...
...
Do you see a difference ![]()
I also think that you have the 'else if' in the wrong place (both for the dht reading and the relay control). Currently the 'else if' is not the alternative for 'if(startTime == 0)'. Have a close look at the code I presented and compare it with your code.
My code (stripped)
// if delay not started, start delay and read dht
if (startTime == 0)
{
...
...
}
// if delay lapsed
else if (currentTime - startTime > 5000)
{
...
...
}
your other code
...
...
}
Your code (stripped) for the relay (same problem for the dht)
if (startcycleTime == 0)
{
...
...
if (t <= 28)
{
...
...
}
else if (currentcycleTime - startcycleTime > 300000)
{
...
...
}
}
Hope you understand what I'm pointing at; if not, ask.