Current News

Moderator: Mmiscool

User avatar
By ilc
#48897 OK, this may well be another one of my errors, but I can't get the following code to work properly (v3 a5). I'm trying to set up a page with three text boxes, and update the time, temperature and humidity every 10 seconds. The time updates, but not the humidity or temperature (except for when I exit.)

Code: Select allmemclear
dht.setup(22, D1)

textbox CurrTime
textbox CurrTemp
textbox CurrHum
button "Exit", [EndProg]

Timer 10000, [test]
wait

[test]
CurrTime = time("hour:min:sec")
CurrTemp = dht.temp()
CurrHum = dht.hum()
'serialprintln CurrTime & " " & CurrTemp & "C " & CurrHum & "%"
wait

[EndProg]
end


As I understand websockets the text boxes should update automatically as the variables change. The serialprintln confirms that the variables are being updated. Have I made another noobs mistake or is this another "gotcha!"?

I'm also getting occasional "0" readings for temp and humidity, I'm presuming this is a graceful recovery from a communication error with the DHT (I'm using a 10K pullup.)

Thanks for any help, regards,

Ian
User avatar
By forlotto
#48900 Note this is just logical and personal opinion:
10 seconds to me is a bit extreme for temperature ... I really don't think no one needs to know that much data about temps I've stated this usually even weather guys that deal with temps deal in intervals of 10 minutes now for indoor thermostats and such I could see a possible need for tighter numbers but ... 10 seconds is over kill of the hardware we are using I believe.

Have you attempted longer delays to see if it provides a remedy to the issue.

I am curious what is it that you have all attempted while I am short on a to the point answer on this one it may require some reading of the docs and the forums for me as well as yourself to come to a solution?

I personally would try delays between the fetching of the data to prevent any collisions... You may be able to check every 10 seconds but I assure you it is overkill I would stick to something like a minute if you are real data intense.
User avatar
By ilc
#48903 Thanks forlotto for your input.

The 10 second interval was purely for testing, so I wouldn't have to wait so long for the numbers to update. The DHT22 (AM2302) docs indicate updates up to 0.5 Hz should be OK.

As for what I've done, well it's taken me all morning to get this far, trying different code, debugging with serialprint, reflashing different units, reading the ESP2322Basic docs, searching the forums, googling other sources, and consulting data sheets.

I only post questions to this forum when I've spent considerable time and exhausted my own means of finding a solution. The main problem I have here is that the code partially works, and have concluded that there is some undocumented nuance that I can't find. Why is one text box updating and the other two not, when I have confirmed that all the variables are changing? I see similar issues crop up frequently on this forum, and a quick 30 second reply from an experienced user clarifies the situation.