简体   繁体   中英

Communication between App inventor 2 and Raspberry pi via usb?

I plan to create an android app that can take pictures and send them to a Raspberri pi 2.

Even if I can use a Raspberri pi 3 or connect a bluetooth usb or wifi, I prefer to have a communication via usb only.

What is the best option for a simple html, css and js based application like App inventor?

I tried some app supposed to communicate by OTG cable but not working, may be my phone (chinese one) is not compatible.

I was thinking connecting rj45 to android, but look complicated.

I know most people will use wifi but for special projects we may need to communicate via usb. I've finally found, for those who are looking, here are the steps:

  1. ssh on the raspberry pi or use screen and then:
    Make the ip static :

    sudo nano /etc/network/interfaces
    add:

     allow-hotplug usb0 iface usb0 inet static address 192.168.42.75 netmask 255.255.255.0 network 192.168.42.0 broadcast 192.168.42.255 gateway 192.168.42.1

    And/Or: ............// for me work with both
    sudo nano /etc/dhcpcd.conf
    add:

     interface usb0 static ip_address=192.168.42.75/24 static routers=192.168.42.1 static domain_name_servers=192.168.42.1

    Replace the IP address (change 75) with a free IP address between the range 2-254.

  2. Reboot and connect the Pi to the Android phone.

  3. On the phone activate USB Tethering :
    Settings> Network & Internet > Tethering & Mobile Hotspot

  4. Use SSH_CLIENT extension in App Inventor to send your commands:
    https://github.com/aluis-rcastro/AI2_ANDROID_SSH_CLIENT_EXTENSION

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM