I'm trying to DIY something similar to a iHome but for my Android device. The first thing I need is to be able to transfer information (specifically, time, weather and notifications) from my Android to the RPi. Ideally, whenever I plug my Android device in, I can automatically, as a background app/task, send data to the RPi.

Although I am likely to have Wi-Fi, I cannot guarantee it (for example, my dorm has continuous Wi-Fi but my home has the Wi-Fi turned off nightly) and I don't have a unlimited data plan, so I would really like to use a USB transfer. My phone is rooted (and all future phones I intend to buy will be rooted immediately) if that makes any difference. What's the best way to do this?

  • One of the first thoughts I had reading your post was perhaps to harness "Tasker" ... see: play.google.com/store/apps/… This allows one to automate tasks on an Android device. – Kolban Feb 17 '16 at 5:10

You can create a wireless hotspot (make a wireless hotspot but turn off data or use ES file explorer -> net manager -> create wireless hotpot or something like that if you don't have that option in settings) and make the Raspberry Pi join that network and transfer data that way. To find the IP address of the Android device hosting the hotspot ping google.com (you should not be able to reach it if data is off) and you should see something like

    From 192.168.x.x: icmp_seq=1 Destination Net Unreachable

The IP address after "From" is the IP address of the device and you can use that to hopefully send packets containing data (I could be wrong be I think I've used this before successfully. Honestly I've forgotten).

As for the plug in part, you can make a script to trigger the start of the program when plugged in. Hope this can help. If you put up more details I might be able to help you a bit more on the exact way to do this.


Assuming you don't want to make a hotspot on the pi or the phone, and don't want to use otg, bluetooth, etc;

The phone can't directly push to the rpi via usb because it's the client, but you can have the rpi pull from the phone if you want.

adb shell date
adb shell dumpsys notification

weather will depend on the build of Android you are using. or you can craft an app on each side to use a custom API over forwarded port.

adb forward tcp:6666 tcp:6666

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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