-->
Page 3 of 4

Re: How to stabilize sensor readings?

PostPosted: Wed Apr 04, 2018 1:38 pm
by Zim
a solution was to turn the ESP wifi off during getting a sensor reading and then reconnect AFTER the sensor reading has been taken


Cool. How did you disable and reinstate the wifi with scripting in basic?
Thanks

Re: How to stabilize sensor readings?

PostPosted: Tue Apr 10, 2018 1:28 am
by treelike
Zim wrote:Cool. How did you disable and reinstate the wifi with scripting in basic?
Thanks

Hi, sorry did not see your reply until now...
This is the script I used (with the password and name removed)

dht.setup(22,2)
[loopy]
wifioff
delay 5000
td = dht.temp()
hd = dht.hum()
wifi.connect("name","password")
p = "192.168.1.68/weather/temphum.php?TEMPDHT=" & td & "&" & "HUMDHT=" & hd
Bla = wget(p)
goto [loopy]

The delay bit is obviously adjustable and probably could go anywhere. Turning off the wifi is easy with wifioff and reconnecting is also pretty easy with wifi.connect("name","password").

A potential problem is if you make a programming error and it gets stuck in wifi off (as I did when I misspelled the router name in wifi.connect). This means you can't fix the problem from the browser because the esp is, well, offline! You can reset the ESP but if you've got it set up to auto run the program then it will turn the wifi off before you get a chance to reprogram it. There's always a way to fix it though, even if worst case it means connecting it back to the computer port and even reinstalling ESP basic.

Re: How to stabilize sensor readings?

PostPosted: Tue Apr 10, 2018 1:50 pm
by Zim
Treelike, Thanks for your responce. I'll give it a wurl.

Re: How to stabilize sensor readings?

PostPosted: Tue Apr 10, 2018 11:49 pm
by treelike
Zim wrote:Treelike, Thanks for your responce. I'll give it a wurl.

No problem at all. I would be interested to hear if it makes your temp readings more stable too.