Hardware Reference
In-Depth Information
Native Application Interfaces
If you don't want to use the browser, you can build your
own application on the phone to interact with the micro-
controller via Bluetooth, network, SMS, or USB. You'll see
an example of this using Processing for Android later in the
chapter. The advantage of building a dedicated app is that
you have complete control over what happens. The disad-
vantage is the challenge of learning a new programming
environment, as well as the limitation of not being able to
use your program on a phone with a different operating
system. Because most phone operating systems don't
allow the browser to access the communications hardware
of the phone directly, you have to build an app if you plan
to use local connections like Bluetooth or USB.
There are a few possible system arrangements afforded
by these capabilities and the kinds of things you might
want to make. Figure 10-2 shows the four most common
arrangements.
Three of the four options shown use wireless links. Current
mobile phones don't make it easy to make a wired serial
link to external devices, though that is beginning to
change. So, for most applications, a wireless link is the
better option. It's not often that you'd prefer your phone
be tethered to your project.
Start with What Happens
By now this should be a common theme to you: start with
what you want people to do with the thing you're building,
and design whatever makes that easiest to do. Are you
making a system where your users have real-time interac-
tive control over a nearby model helicopter or boat? Are
they controlling a remote device like their home thermo-
stat while on vacation? Consider how tight an interactive
coupling you need. Do you need real-time interaction like
you saw in Chapter 5, or will updates every few seconds or
minutes be enough? And what about the distance between
the devices—do you need to be able to communicate at
long range, or will a local connection like Bluetooth or USB
suffice? If it's a remote connection, how will your users
know what happened on the other side? Can they see the
result? Do they get an email or SMS message telling them
about it? Evaluate whether you need a wired or wireless
connection, based on how the people need to move and
manipulate the devices involved. Consider what networks
are available where you plan to use your system. Got WiFi?
Got mobile networks? Got Ethernet? Can you create a
local network between the two devices using Bluetooth or
WiFi?
SMS and Email Interfaces
Not every project requires real-time interaction between
your phone and the thing you're building. If you just want
to get occasional updates from remote sensors, or you
want to start a remote process that can then run by itself—
like turning on a sprinkler or controlling your house lights
via a remote timer—SMS or email might be useful. You
can make a microcontroller application that can receive
SMS messages using a GPRS modem, or you can write a
networked server that checks email and sends messages
to an Internet-connected microcontroller when it gets a
particular email message. The advantage of this method is
that you can control remote things using applications that
are already on your phone, email, and SMS.
Voice Interfaces
Don't forget the phone's original purpose: two-way com-
munication of sound over distance. Voice interfaces for
networked devices can be simple and fun. Telephony
gateways like Asterisk and Twilio allow you to use voice
calls to generate networked actions.
Browser Interfaces
If you want to control an existing networked device from a
mobile phone, the easiest thing to do is to give the device
an Internet connection and control it from your phone's
browser. You don't have to learn anything specific to a par-
ticular phone operating system to do this—you just need
to be able to make an HTTP connection between them.
Make the microcontroller a simple server like you saw in
Project 6, Hello Internet!, and you're done.
Phone As Gateway
Not all applications in this area involve control of a remote
device from the phone. Sometimes you just want to use
the mobile phone as a network connection for sensors
on your body or near you. In these cases, you'll make a
local connection from the microcontroller to the phone,
most likely over Bluetooth or USB, and then send the data
from those sensors to a remote server. In these cases,
you probably don't need to build a complex application—
you just need to make the connection between the two
devices, and between the phone and the network.
 
Search WWH ::




Custom Search