If statment issue with WIFI

Greetings
I am using a Node MCU unit and newest IDE
The attached sketch reads time, temp and is trying to take a 12 volt battery reading 6 times a day.
I am having problems with my if statements in line 170-187
Most of the time, my if statements are not capturing the value. I say most because, one in awhile one value may appear, but that is rare. This occurs whether I am manually updating the webpage or if auto refresh is set to something like 45 seconds.

Looking for suggestions, please.
Thanks for any ideas.

WORKING_outhouse_wifi_channel_14_Jan_22.ino.ino (7.4 KB)

What’s happening if ‘f’ is 14.95. Why not make the last line if(f < 15.0)…

What’s happening if the temp is between 30.0 and 85.0.
You have no feedback there.

You will get more responses if you read the “How to post” sticky, and post your code inline.
Leo…

When testing ranges of values, especially with floating point numbers, using if() else if()... is useful. e.g.

if( f > 85 )
{
   // above 85
}else if ( f > 30 )
{
   // between 85 and 30
}else
{
   // 30 and below
}

This way you can cover all possible values of 'f'

Yours,

When having problems with if not apparently working it is useful to print the value(s) being tested before doing so. That way you can see what value(s) are being tested and if the code ever reaches that point in the program.

Thanks for the comments. But, I think I may not have explained, well enough, my issue. It appears that the if statements don't always capture the temperature value. I understand that this is a WIFI operation. I can run this sketch without WFI, via serial, and everything is fine..all six fields (times) are populated. So, I assume that here is a Refresh issue. I don't have enough battery power to run the refresh all the time and I can't seem to find a way to populate the if statement result.

Thanks for any ideas.

Doug

seymourmtn: It appears that the if statements don't always capture the temperature value.

The problem is that sentence does not make any sense. If statements don't "capture values".

So you will have to try and explain the problem more simply.

What do you think your 'if statements' should be doing ?

Yours, TonyWilk

Tony The if stAtement checks for a time. If the time matches, the temperature value is set to a new variable i.e. Line 11 When the pages is refreshed, there are six time slots that I would like populated, from the six if statements. This isn't happening.

Hope this helps and thanks for the reply

seymourmtn: The if stAtement checks for a time. If the time matches, the temperature value is set to a new variable i.e. Line 11

Ah... THOSE 'if statements' on lines 179 to 195 !

Well, they are inside your while( client.connected())

Is your client always connected ?

Yours, TonyWilk

No, I don't wNt it to be a,ways connected. Do I need to move the if statements? Thanks....

seymourmtn: No, I don't wNt it to be a,ways connected. Do I need to move the if statements?

Well, yeh.

You'll have to move a whole bunch of stuff up to the top of loop(), before WiFiClient...

Everything that reads the clock, the temperature, humidity, battery info, and your 'if( time )' statements. otherwise it will only happen when the client connects.

Yours, TonyWilk

Thanks much. Will make the mistake Es and key you know!