• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

Acessing webserver without knowing IP Address

Q&A Forum › Category: ESP32 › Acessing webserver without knowing IP Address
0 Vote Up Vote Down
Pat McKay asked 5 years ago

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

6 Answers
0 Vote Up Vote Down
Rui Santos Staff answered 5 years ago

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:

0 Vote Up Vote Down
Rui Santos Staff answered 5 years ago

However, if your ESP is set as an Access Point, you can set the default IP address will always be: 192.168.4.1

0 Vote Up Vote Down
Pat McKay answered 5 years ago

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

0 Vote Up Vote Down
Barry answered 2 years ago

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

0 Vote Up Vote Down
Barry answered 2 years ago

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.

 

0 Vote Up Vote Down
Sara Santos Staff answered 2 years ago

Hi.
I’m sorry for taking so long to get back to you.
I’ve seen you already solved your issue.
 
Thank you so much for sharing the solution.
 
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025
  • [eBook Updated] Learn ESP32 with Arduino IDE eBook – Version 3.2 April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.