Arduino Stack Exchange is a question and answer site for developers of open-source hardware and software that is compatible with Arduino. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am coding an application in Android Studio that uses analog inputs from an arduino. I am trying to send analog input from an Arduino Pro mini to an Android App. However, I cannot connect straight to the phone (BT and USB are not an option). The method I've thought of is to connect both the phone and Arduino to PC and read the Analog input using Android Studio and Use my phone to run the application instead of an emulator. Would this work in real time.

Is it possible to have the Android Studio run the app and the app still reads information from the Arduino real time? The application reacts to analog inputs from the Arduino. So I need to find a way to access the arduino in android studio and run the app through android studio in place of its emulator.

The other idea I had was to set up a web page where the arduino would print the analog output and the Application could reference the webpage but I feel that is not really viable here.

I can't find any sources so if anyone has a clue please help me. Thank You!

share|improve this question
    
The main question here is: Why. (Why on earth would you want to do this) Another question is: What do you consider real-time? Do you want the values once a second (or once a millisecond, or once 100ms)? Howmany jitter is allowed (like 10% above or below)? – Paul Apr 1 at 7:19
    
There is no such thing as "realtime" on the arduino, connected via a stone age type serial connection with tons of OS overhead and script languages in between. – ansi_lumen Apr 1 at 17:08

You say BT and USB are not an option, but don't mention wifi, so...

Perhaps you could write a program on the PC which talks to the Arduino on the serial port, and which listens on a (network) socket for the phone. It passes data from the serial port to the socket, and from the socket to the serial port.

The Arduino outputs its data to the serial port as normal.

The phone opens a socket to the PC and is plumbed through to the Arduino's serial port.

share|improve this answer

Android studio has nothing to do with this, but the adb tool in the underlying Android SDK might.

If you have a PC program collecting data from the arduino, you can set up an adb port forward to allow that to connect to a socket served by your app, without needing an ordinary network.

You can also use adb to fire various android type communications such as Intents, but this introduces more lag as one or more programs have to launch for each distinct send done thus way.

It is also possible to internally modify many Android devices (moreso tablets than phones) to interact with an add-on MCU though you typically need root. And there are USB options, but you ruled those out.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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