General area when it fits no where else

Moderator: Mmiscool

User avatar
By Zim
#75144
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
User avatar
By treelike
#75247
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.