I have a Raspberry Pi with running custom server not connected to the internet (offline system).
I would like to connect Android device via USB cable to rPi and communicate with it.
As Raspberry Pi is not connected to the internet, it doesn't have IP address (given via DHCP).
How can I communicate with rPi using Android device connected via USB?
Maybe local DHCP server?
Thanks
The RaspController is an Android application that is used to manage the Raspberry Pi device from any android device either from a mobile phone or a tablet. We can not only control the power of the Raspberry device from this application but can also control the GPIO pins and access command line.
After installing the application on your phone, you have to connect the Raspberry Pi to Android via the video capture card and open the USB camera app. Then select a suitable resolution, and you can even make the display into full screen. While running this setup, the touch on the phone works perfectly fine.
Follow this link. You just have to configure the RPi for it once and you are good to go.
What this does:
Allows you to use your Android device as keyboard input and terminal display for your Raspberry Pi
Allows you to tether your Raspberry PI to your Android device's WiFi (3G untested, but should work).
Background:
I love the idea of a truly portable Raspberry Pi box. I wanted to make one, but I don't have a compatible WiFi dongle, nor do I have a wireless keyboard and mouse. Even if I did all of these things, I'd like to save myself the extra USB port by having both my network and input go over the same port. I guess the next thing to do after this would be to set up some sort of VNC server and connect to the Pi's GUI via the Droid.
My Build:
- Raspberry Pi v2 (Linux raspberrypi 3.1.9+ #125 PREEMPT)
- Asus Transformer Prime (Android 4.1.1. Jelly Bean)
- Yoobao "Long March" -11200mA 1A / 2A battery (good for 10+ hours!)
- VX ConnectBot terminal emulator (Free in the Google Play store)
- Hackers Keyboard - because I like tab complete (Free in the Google Play store)
Assumptions:
- Your PI is configured to run SSHd on startup
- You are using the default Pi username / password
- Your Android device has internet connectivity via WiFi/3G and it is enabled
How to do it:
Add the following to /etc/network/interfaces
iface usb0 inet static address 192.168.42.42 netmask 255.255.255.0 network 192.168.42.0 broadcast 192.168.42.255
Power down your Pi
Connect your Android device to your Pi via it's USB data cable
Power up your Pi... wait about a minute.
On your Android device, go to Settings / Wireless & Networks / More / Tethering & Portable Hotspot... click "USB tethering"
Start up VX ConnectBot and SSH "[email protected]"
Keep hitting return until it asks you for your password. Enter it.
Congratulations - you should now have terminal access to your Pi with a software keyboard... kinda. Mine seems to disconnect the session every minute or so - very annoying.
Now to set up routing so that your Pi can see the world via your Android device.
Root yourself up
sudo su -
Check to see which IP address that your Android device is using
arp -a
Mine is 192.168.42.129
Add a default route pointing all traffic from your Pi out to your Android device. It's worth noting that this static route is temporary and will not survive rebooting your Pi. I've left it like this because I don't know if Android likes to change it's tether gateway address very often. If you've gotten this far, I'll assume you can figure out how to make a static route permanent if need be :)
route add default gw 192.168.42.129 usb0
Test it!
ping http://www.google.com
Setting a static ip won't work (always the dhcp that sets one). On the phone, you can see how to retrieve the IP address here : How to get the system ip address after usb tethering of android phone?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With