Controlling an Arduino with Android

19
Android Communications with Arduino

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

Page 1: Controlling an Arduino with Android

Android Communications with Arduino

Page 2: Controlling an Arduino with Android

Two AspectsArduino:● Receiving

commands● Switching pins

on/off

Android:● Send commands

Page 3: Controlling an Arduino with Android

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

o for power and program uploads

Page 4: Controlling an Arduino with Android

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

o for program uploads

Page 5: Controlling an Arduino with Android

Arduino Software● Arduino IDE

o version 1.0.5o for Windows, Mac, and Linux

Page 6: Controlling an Arduino with Android

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

Page 7: Controlling an Arduino with Android

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

Page 8: Controlling an Arduino with Android

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

libraries

Page 9: Controlling an Arduino with Android

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

Page 10: Controlling an Arduino with Android

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

interface.● This code can be

used wherever Java is supported.

Page 11: Controlling an Arduino with Android

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

Page 12: Controlling an Arduino with Android

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

Page 13: Controlling an Arduino with Android

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

Page 14: Controlling an Arduino with Android

UDP● User Datagram

Protocol● One-way

communication● Used for sending

commands

Page 15: Controlling an Arduino with Android

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

o Used by Google Chromecast

Page 16: Controlling an Arduino with Android

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

Page 17: Controlling an Arduino with Android

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

improved

Page 18: Controlling an Arduino with Android

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

Page 19: Controlling an Arduino with Android

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