Thinger esp8266 and webserver running together


hi, ive made a few projects using thinger now… cool system!!

I am using the wifimanager setup and it all works great…

couple of things…

when the ESP8266 starts, in my setup() I’m calling mDNS to start… but because I don’t have an IP Address by then (its like TCP hasn’t quite loaded) when I check… It doesn’t have the IP yet - just get

Ive had to include mDNS in Setup() and then have a check in the loop say after 10 seconds, then start mDNS… I also have an IP address by this stage too…

other thing… I also want to run a webserver from this esp8266 so I can configure certain things locally by browsing to it. ive done web server stuff before on ESP8266 but when I include say:

ESP8266WebServer server(80);

and then in my Setup call server.begin(); this messes with the thinger platform startup - thinger wont connect as it says its missing the deviceid, key etc… if I remove the server.begin() from setup, it works properly.
I tried similar approach of say waiting 10 seconds until thinger has finished starting and then in the loop, start the web server… but then I cant talk to the device via thinger anymore…

what would be the best way to use thinger like I have been but also be able to start a web server and respond to requests as well?


Hi @paulobriennz

thanks for your nice feedback! :wink:

Regarding your question, the device will try to connect to your WiFi in the loop, inside the thing.handle() function. This is necessary as the device may lost connectivity with WiFi, and it is necessary to handle the reconnection inside the loop. Then, if you need to initialize mDNS, it can be done after the thing.handle() function, where the device should have an IP Address. (Be sure to not initialize the mDNS in every loop iteration).

Regarding the Webserver, it should work by calling the server.begin() in the setup and then just calling server.handleClient() after the thing.handle(). However, you have mentioned that you are using WifiManager Setup, which also initializes a web server, so I think they may be trying to open the same port. Can you try opening your web server in a different port? i.e. 8080?