I am doing a project where a Raspberry pi zero collects some data from a sensor and displays it through a self hosted web server.

Now,the usual way you access a webpage in a raspberry is to just type its IP in a web browser, right? But the process of discovering the IP assigned to a raspberry from an android phone with its wifi hotspot enabled or usb modem is not an easy task for most users and usually requires downloading third party not so trustworthy apps. And in most cases the raspberry will be used in the field with no access to a monitor to just check the IP displayed on the terminal at boot.

Is there any way I, as the developer, can make it easier to find and connect to the raspberry from a phone that is sharing its internet with it?

EDIT: Also, before considering setting an static IP. In my exprerience so far different phones create a different networks when sharing their connections, one will be 192.168.133.X for example, while other will be 10.42.0.Y or 192.168.120.Z. Dealing with those changes in the network aspect of the IP make it so I don't know whether a static IP is even possible.

  • The Raspberry Pi with Raspberry OS has DNS resolving and mDNS enabled to to address it by network name. So your question is mainly a question how can android use this. Maybe android.stackexchange.com is a better place to ask?
    – Ingo
    Oct 9, 2020 at 17:30

2 Answers 2


Two technologies that are supposed to help with this are mDNS and DNS-SD. mDNS allows you to give your server a .local name on your LAN without having to set up a full DNS server, and DNS-SD (Service Discovery) allows you to advertise services on your LAN so they can be discovered by apps on other devices. Raspberry Pi OS and lots of other Linux distributions come with Avahi, which supports both services, and the Apple version is called Bonjour. Assuming you have Avahi running, your RPi should already respond to an address like raspberrypi.local typed in a compatible web browser.

You can get it to advertise its web server by placing something like this in /etc/avahi/services/http.service:

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
  <name replace-wildcards="yes">My data server on %h</name>

Edit the server port and name (%h expands to the hostname) to match your application. Once Avahi is reloaded (sudo systemctl restart avahi-daemon.service), it should start advertising your server on the local network.

The bad news is that while the above all works for iOS and later versions of Win10, Android doesn't natively support mDNS/DNS-SD. Unfortunately typing the local hostname doesn't work in the browser, and you need a third-party app that understands DNS-SD to listen out for the advertisements. I use a free, bare-bones app called Service Browser, which lists all the services advertised on my LAN, shows you the IP addresses and ports, and lets you open them up.

I understand that this doesn't sound ideal for your application, but until Android/Chrome implements mDNS, I'm not sure that you will be able to come up with an app-free solution. That said, the DNS-SD protocol is simple enough you might consider implementing it in your own app.


In many public places, when you connect to their 'free' wifi network, you often get routed to a sign up/conditions page... use the same tech...

Make the pi an access point...

Anyone wanting to read the data just needs to join the Pi's network and have the data blasted at them.

I don't know precise details of the protocol to do this (it will be out there somewhere...) I guess the access point/server just routes all traffic (regardless of IP address) to itself.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.