2
\$\begingroup\$

I want to control a simple Light on an Arduino from my Android. The Arduino I have down pat, no problem. However without using Bluetooth on my Android, whats the simplest way to actually connect it (or use some sort of app) to control an LED.

I have Option A: Set up a Server on my Arduino, with a website that allows me to click on buttons or something to change lighting options.

or Option B: Sending Serial Data from my Android to my Arduino Wirelessly?

Which would probably be the easier option? Is option A even viable or not really? I don't really know the "hosting" capabilities of an Arduino, but if the Arduino is on the same Wi-Fi as the Android phone I'm using, it shouldn't have any issues receiving information (from clicking on buttons on the Arduino "webpage" correct?)

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Out of interest, can I ask why Bluetooth isn't a desirable option? I've got a bluetooth link from my Android to a PIC up in under a day before \$\endgroup\$ Commented Jan 31, 2013 at 9:40

3 Answers 3

7
\$\begingroup\$

Option A is feasible, but non-trivial.

Option B: Without using Bluetooth, there isn't any ready wireless radio serial output that any Android phones have, to my knowledge.

There is an option C, if the requirement is relatively close range, and purely for hobby experimentation:

  • Programmatically generate a ~ 19-20 KHz audio output from the Android's speaker, at maximum volume - Most adults can not hear such a frequency, but my android phones can all emit up to 22.1 KHz successfully.
  • Implement a basic electret microphone --> preamplifier --> narrow bandpass filter --> peak detector using op-amps, with the pass-band at the frequency of interest.
  • Use an Arduino ADC pin to sense signal from the above module.

Some simple enhancements:

  • Use two different frequencies, such as 18 KHz and 20 KHz, pulsed alternately, and detect for such an alternating sound input at the Arduino end. This will avoid spurious false-positives.
  • Use a slightly wider band and skip the peak detector, use the Arduino to sample and process the incoming audio signal to detect specific frequencies received. This latter adds the flexibility of changing design frequencies or achieving more complex signaling through Dual-tone-multi-frequency (DTMF) protocols, similar to touch tone phone dialing, or Frequency Shift Keying as used in old dial-up telephone line modems.

There are several Android apps which use such sound signaling for various purposes. Also, this slideshow proposes a similar mechanism, for transfer of data between Android phones using sound.


UPDATE: This question about Infrared audio transmission / reception between mobile phones, brings up an interesting Option D, that of using an infrared transmitter connected to the audio out of the transmitting cellphone, and using a standard infrared sensor as a receptor on the Arduino. The rest of the mechanism remains as in Option C, with the preamplifier, band-pass filter and so on.

\$\endgroup\$
7
  • \$\begingroup\$ What about using an access point or wi-fi? couldn't that also be feasible. Like sending a serial data over wi-fi that is. \$\endgroup\$
    – user3073
    Commented Jan 31, 2013 at 7:02
  • 1
    \$\begingroup\$ @Sauron WiFi is not a serial data medium, it is a non-trivial networking layer, as used for local area networks. The challenges will be in getting from the WiFi layer, up through to an application layer protocol for serial data send and also receive. \$\endgroup\$ Commented Jan 31, 2013 at 7:10
  • \$\begingroup\$ Option A IS Wifi/Access Point. \$\endgroup\$
    – Passerby
    Commented Jan 31, 2013 at 8:35
  • \$\begingroup\$ @Passerby Yes: It is feasible but non-trivial - and it certainly isn't out of the box ready for serial communications. \$\endgroup\$ Commented Jan 31, 2013 at 8:44
  • \$\begingroup\$ While not serial, the Arduino Web Server example makes it trivial for simple gpio control. \$\endgroup\$
    – Passerby
    Commented Jan 31, 2013 at 15:27
2
\$\begingroup\$

Here are some resources for

Option A: Webduino

  1. https://github.com/sirleech/Webduino (my recommendation)
  2. http://mpflaga.github.com/Sparkfun-MP3-Player-Shield-Arduino-Library/_web_player_8ino_source.html

Option C: SoftModem

  1. http://code.google.com/p/hijack-main/
  2. http://code.google.com/p/arms22/downloads/detail?name=SoftModem-004.zip

The Softmodem is neat, I have gotten the shield but have not yet tried it. As I then also need to write the phone APP.

Where I recently wrote option A.2 for Arduino Web based MP3 player.

In your case I would recommend A.1. I have tried it out and its examples got me to do what you want real quick. Being web based you don't need to worry about writing a phone app. And webduino supports JSON. For web pages to auto discover the available controls and such. Where it used a lot of Arduino memory and I could not combine it with my MP3 player as the SdCard library combined exceeded an UNO memory limit.

Option B, is simpler on the Arduino Side But there is not alot out there on getting it connected to the phone's usb. And on the Phone you could use a TTY or terminal emulator to talk to the phone.

Option D, not many phones have IR on them.

Option E, NFC (Near Field Communications) shields similar to RFID, but are bidirectional and can send/receive packets. Also have the issue of only a few phones have them.

All the options other than A end up requiring an APP on the phone. And then you have deal with Android vs iPhone.

\$\endgroup\$
1
  • \$\begingroup\$ The Option D mentioned in my answer refers to a simple external IR device connected to the audio jack - which is discussed in the question & answer I linked to. The expectation is not that the phone itself supports IR or IrDA, those days are gone or fading fast :-) \$\endgroup\$ Commented Jan 31, 2013 at 21:30
1
\$\begingroup\$

Aside from Anindo's good answer (and genius sound idea) Option A is viable. Done all the time. For complete wireless, you can go with a WIFI shield (and battery for the arduino). Or you can use a Ethernet shield to plug into an existing router. Both of these require server code on the arduino to control the shield and receive the data from your Android phone or device.

Example: Arduino Wifi Web Server Pretty much drop in and go.

The other option is modifying your router so it is the server, connecting to your Arduino through a serial connection.

Last option, is having your computer act as the server, and connecting your Arduino to your computer.

All viable, and all routinely done.

\$\endgroup\$
1
  • \$\begingroup\$ I feel like I may prefer using the Arduino as a Web Server the easiest IMO. I would just be able to access the IP on my phone then (assuming it was on the same wifi). \$\endgroup\$
    – user3073
    Commented Jan 31, 2013 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.