Controlling an Arduino with Android

Post on 15-Jan-2015

2.238 views 4 download

Tags:

description

A summary of my work on an Android controller for specially programmed Arduino boards. It walks through the resources, methods, and trade-offs of the process.

Transcript of Controlling an Arduino with Android

Android Communications with Arduino

Two AspectsArduino:● Receiving

commands● Switching pins

on/off

Android:● Send commands

Arduino Equipment● Arduino card(s)● Arduino WiFi shield(s)● USB a-b cable(s)

o for power and program uploads

Android Equipment● Android tablet/phone● Android stock USB cable

o for program uploads

Arduino Software● Arduino IDE

o version 1.0.5o for Windows, Mac, and Linux

Android Software IThere is a choice to be made here:● Android Developer Tools (ADT)

o more accessible to beginnerso older

● Android Studioo more powerfulo unstable

Android Software II● Portable Wi-Fi hotspot Free

o Creates wireless hotspot Local, no satellite

o an app for the Android deviceo by Core Technologyo available on Google Play

Arduino Programming● C syntax● Very limited● Extended with C++

libraries

Android Programming● Java programming language● Relatively simple● Intimidating for beginners

Android: It’s just Java● Android is just an

interface.● This code can be

used wherever Java is supported.

Network● This is not programmed● The Android device is the router● The Arduino cards are assigned IP

addresses● Everything over a hotspot

o Portable Wi-Fi hotspot Free

Hotspot Pros● Simple● Leave the job up to another app

Hotspot Cons● Credentials are hard-coded for Arduino

cardso change source code for new networks

● Not as reliable as other protocols● Extremely roundabout● Dependent on another app

UDP● User Datagram

Protocol● One-way

communication● Used for sending

commands

Network: The Right Way● Bluetooth● mDNS - multicast Domain Name System

o Used by Google Chromecast

Final Arduino to App Logic1. Start Portable Wi-Fi hotspot Free on host

Android2. Turn on Arduino boards3. Turn on Android app4. Wait for Arduino boards to connect5. Send commands

Final Thoughts● Arduino boards are simple to program● Android programming is the hard part● The networking portion can be vastly

improved

Fork it on GitHub!The projects can be found here:● Arduino code -

https://github.com/pori/arduino-udp-client● Android code -

https://github.com/pori/ArduinoControllerExample

Useful Resources● Arduino website for downloads and tutorials - http://arduino.cc/● Android development (choose one):

o Android Developer Tools - http://developer.android.com/sdk/index.htmlo Android Studio - https://developer.android.com/sdk/installing/studio.html

● Android source code - https://github.com/pori/ArduinoControllerExample● Arduino source code - https://github.com/pori/arduino-udp-client