Hi,
Most (all) sketches I seen rely on printing the IP Address to the serial monitor (e.g. Serial.println(WiFi.localIP());).
However, I ‘m trying to figure out how a user can know the IP Address to put into the browser without any connection to IDE. In other words, if I hand someone a camera they will be able to connect. My thoughts were to use mDNS and setup a name corresponding to IP Address but haven’t got that working yet (using Android).
Ideally what I would like is for the android user to access the ESP32 Hotspot, type in the browser something like http://myEsp and the webpage launches?
I’m open to any suggestions and any help is appreciated.
Thanks
Pat
Hello Pat, you are exactly on the right path. For example you can use mDNS which would look something like: http://myesp.local There’s an example in the Arduino:
However, if your ESP is set as an Access Point, you can set the default IP address will always be: 192.168.4.1
Hi Rui,
Thanks. Your suggestions were a big help. Here’s my findings that I’m posting as it may be of value to others.
Using ESP as an Access Point (i.e. where the ESP publishes a hotspot) worked great but of course your device then has no internet access…so a great option for communicating between a device and esp but not so good if you want to access the ‘outside’ world.
mDNS worked perfectly but not on Android…apparently this is a known restriction.
So leaves me with two options….
1. have a small display to show the IP Address assigned to the ESP Server (not ideal)
2. Use a static IP Address.
I went with the static IP Address option for now and this worked fine.
My intention is that each user connects to the esp using their smartphone hotspot. I’m not a network guru but, in theory, if there are multiple devices with the same static IP Address but on their own hotspots then this should be fine(?).
Anyway, Rui, I hope that makes sense and thanks again.
Regards
Pat
I’ve looked at the example and it appears to be about RESOLVING and IP from a mDNS. I’d like to do the opposite, broadcast the ESP name and IP. Also, I already have a server running on port 80.
It would seem this is a very useful feature which others might enjoy.
Barry
After trying a few things, I got this to work.
#include \”ESPmDNS.h\”
if(!MDNS.begin(\”abc\”)) {
Serial.println(\”Error starting mDNS\”);
return;
}
Note that the browswer URL should be http://abc If you enter just \”abc\” the browser wants to google it.
The lib I used was:
https://github.com/utkarshchauhan021/ESPmDNS
^^^ corrected link.