Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create an Android app to control Arduino over Wi-Fi?

I have an Arduino Mega board. I've connected the WiFly module to it and established connection with my Android phone. Now I want to make a simple app for my Android, where I press a button and the LED on the Arduino board turns on.

In fact, I've already made an app (in Eclipse) with a button, and if I press it, I get a toast message saying the button is pressed. Now, how do I implement the Wi-Fi functionality to it and enable it to light up the Arduino's LED?

like image 737
Anish Avatar asked Mar 23 '12 00:03

Anish


1 Answers

It really depends on the types of inputs the Arduino board is expecting. What do the Arduino documentation say about communication over a Wi-Fi connection? I imagine reading those would be a good place to start.

It looks like you communicate with the Arduino via HTTP. This makes things really easy. One quick way you might do this (I haven't tested this) is to do something like the following:

URL url = new URL(arduinoCommandURl);
InputStream is = new InputStreamReader(url.openStream(), "UTF-8"));
is.read();
like image 121
slayton Avatar answered Oct 04 '22 07:10

slayton