10

How do I write an Arduino sketch and an Android application to talk to each other over a standard USB cable?

sachleen
  • 7,565
  • 5
  • 40
  • 57
David Cary
  • 1,122
  • 8
  • 23

5 Answers5

6

Android devices usually don't have a USB host: they expect to be connected to some smarter device like your computer. Same goes with Arduino. For this reason Arduino made the Mega ADK (that means Accessory Development Kit).

Mega ADK and Due act as USB hosts and can be connected directly to your Android phone. If you already have a board, another option is to get a USB host shield to add USB host capababilities.

Your sketch will tell the phone what kind of accessory application it is and your phone will download the appropriate application from the store.

There is a book about connecting Arduino to Android.

Federico Fissore
  • 1,281
  • 7
  • 10
3

You never mentioned your tablet model... or Arduino model

There are some tablets designed to work with USB flash drives and printers. This is called OTG (on the go.

You need:

  • A tablet supporting OTG
  • An OTG adapter that fits into your tablets USB slot and is compatible
  • The Arduino Uno Communicator App
  • Arduino Uno (or clone) [Note: It says that it works with Atmega16U2 or Atmega8U2 programmed as a USB-to-serial converter so I would assume that that would cover a few boards more than the Uno.)

Another alternitive is to look into Bluetooth (Note: I just picked a random link but there are hundreds of similar BT adapters)

Anonymous Penguin
  • 6,365
  • 10
  • 34
  • 62
2

The USB protocol requires one end to be a "host" and the other end to be a "peripheral", and it doesn't work if the devices at both ends of the cable are "peripherals". Alas, most Arduinos and many early Android devices are "peripherals", so connecting such devices with a standard USB cable doesn't work.

Some modern Android devices support "OTG", so in theory one could make the Android end of the cable the "host". Has anyone gotten this to work?

Another approach is to somehow make the Arduino end of the cable the "host", and the Android end of the cable the "peripheral". That's the approach taken by

  • Microbridge (a) (b)
  • The IOIO board (a) (b)
  • The Android Accessory Development Kit (ADK) (a) (b) (c)

(The Amarino (a) and Cellbots (a) (b) take yet another completely different approach).

David Cary
  • 1,122
  • 8
  • 23
2

Processing is a great place to get started with device to device communication.

The interface and language are very similar to Arduino and there are many examples to get you started.

http://playground.arduino.cc/Interfacing/Processing

80HD
  • 135
  • 2
0

You can connect Android and Arduino with usb and use the easy tool App inventor 2 for android

Did you try this new application : https://play.google.com/store/apps/details?id=bp.usbbridge.appinvDemo and full version : https://play.google.com/store/apps/details?id=bp.usbbridge.appinv

Find Videos about Explications : USB OTG Bridge Serial UART for APP Inventor 2 and ARDUBLOCK on youtube

Artsduson
  • 21
  • 1