Android Things - How do I connect to my Raspberry Pi when I don't know the IP address
Asked Answered
G

7

16

I have successfully managed to install the Android Things Dev Preview onto my Raspberry Pi.

I have a problem though. When I first started installing my own applications I was able to connect to the Raspberry Pi through Ethernet, because it displayed the IP address on the TV when I booted up the Raspberry Pi.

Now because I have the Raspberry Pi already running an application, when I boot it up, it is automatically booting into my application without showing the initial screen with the IP address (and I forgot my IP address πŸ€”).

Is there an easy way to get the IP address of the Raspberry Pi, or connect to it when I don't know the IP address? Even a command to get a list of all available ADB devices on the network would help.

It would be great if when connected to a certain Wi-Fi, you could run something like:

adb network devices

Which could give a list of ADB devices on the network you are on.

Girandole answered 6/1, 2017 at 6:15 Comment(4)
What I do is connect my Pi running Things via serial cable, and then use Minicom to get into its shell from the connected computer. Then run ifconfig. – Rein
Android Things: Connect to Raspberry Pi 3 (see What if I have neither display nor Ethernet cable? section in particular) – Skied
just FYI "adb devices" is a valid command. – Cat
I can't find IP address of Raspberry Pie either any of the ways defined here. I also have the same question as @Girandole have. – Halpin
G
23

The Raspberry PI Automatically broadcasts Android.local and should resolve to the IP address assigned to your Pi on port 5555. Running the following:

adb connect Android.local

The command above is effectively the same as running:

adb connect <ip-address>:5555

Note: This will only work if your host platform supports multicast DNS service discovery.

This information was found in the documentation here by step 7 https://developer.android.com/things/hardware/raspberrypi.html

Girandole answered 6/1, 2017 at 6:15 Comment(2)
I'm very curious to know what will be broadcast when there's multiple devices – Felony
@Girandole I tried adb connect Android.local but got the following error. unable to connect to Android.local:5555: nodename nor servname provided, or not known. However the connection was successful when I attempted to run adb connect <ip-address>. Any clue to know why Android.local didn't work for me? – Doughy
E
12

You can scan your network for points with ports 5555/5554 open, for example,

nmap -p 5555,5554 192.168.0.2-100

will scan in range 2-100 for any IP addresses with those ports open.

Emanation answered 6/1, 2017 at 7:22 Comment(1)
Thanks, this also works! This works for all types of Android devices, not just the raspberry PI 😬 – Girandole
C
4

Or you can check in your router which devices are connected

Corpse answered 6/1, 2017 at 8:17 Comment(0)
F
4

On OS X you can scan for all devices that publish itself as Android.local

dns-sd -Q Android.local

I believe you need Bonjour on Windows/Linux to get something similar, but I'm still not familiar with them.

After figuring out the correct IP for the desired device you can connect as usual:

adb connect <ip-address>:5555
Felony answered 31/1, 2017 at 4:4 Comment(0)
P
3

If multicast DNS is not supported on host platform and you have access to your router, you can simply log into it and view the list of connected devices. You will be able to view all the devices no matter if mDNS is available or if there are any ports opened on the device (or if you don't know which port is opened).

Probe answered 6/1, 2017 at 7:29 Comment(0)
C
3

The easiest way how to get to the initial screen with IP address from your application is to connect a USB keyboard to your Raspberry Pi then pressing escape key once :)

Calie answered 14/2, 2017 at 14:41 Comment(0)
I
3

I had the very same problem recently and the easiest way in my opinion is that to just install a simple app on your phone (in my case Fing) that shows all the connected devices to your local connection including th RPI with their ip address. So then you are good to go!

Ideal answered 5/11, 2017 at 9:22 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.