Introduction: Use Your Android Phone Sensors on the Arduino !

Picture of Use Your Android Phone Sensors on the Arduino !

Hello, this is my very first step-by-step instructable, and today, we're going to learn how the sensors in your android smartphone can communicate with your arduino.
In modern smartphones, there are a lot of useful sensors for an ingenious arduino project. I have a motorola DEFY, for example and it has (at least) 6 sensors :
- light sensor
- proximity sensor
- aGPS (assisted gps)
- compass/magnetometer
- accelerometer
- orientation sensor
This instructable's purpose is to get you started using these sensors from your arduino. For this, we're going to use an application that was made for that single purpose : Amarino 2.0 . This app was first started by Bonifaz Kaufmann during his visit at the High-Low Tech Group in 2009 at the MIT Media Lab in Cambridge, USA and further developed at the University of Klagenfurt in Austria.

The overall cost of this project, considering you already have an arduino and an android smartphone, can be pretty low (it cost me about 12$).

If you liked this instructable, please rate it !

Step 1: Required Parts/Tools

Picture of Required Parts/Tools

Required tools :

- solder iron with fine tip
- tiny solder wire
- good magnifying glass
- "Third hand" helping tool
- good soldering skills

Required parts :

- Arduino
- Android smartphone
- Bluetooth serial adapter (not needed if you happen to have an arduino BT)
- 10 and 20 kOhm resistors 
- Breadboard
- Standard servo motor
- jumper wires and/or small wires

Since the ArduinoBT has Bluetooth functionality built-in, setup is much easier (no soldering, risks of messing up bt adapter, etc...) but since it costs pretty much, I went the cheap way, and bought a bluetooth to serial adapter from ebay.

Okay, so where do you buy those parts/components...

- Arduino : you can get this at sparkfun : ( ), from ebay or you can check the arduino website for other distributors ( )

- Android smartphone (I guess you already have that...)

- Bluetooth serial adapter : You can get this from sparkfun too, with a breakout board ( ). These don't need level shifting so if you buy this product, you don't need to buy the resistors. You can also get it from ebay, like I did, but they are more complex to set up and documentation isn't always accurate (mine was wrong on the default baud rate, for example) Here's the link to the one I bought : Bluetooth adapter.

- 10kOhm and 20kOhm resistors : these are needed to shift the 5v from the arduino serial pin to the 3.3v on the bluetooth adapter. You can get these at your local electronics shop.

- Breadboard : Not really necessary, but it is much easier (and cleaner) to wire the voltage divider on a breadboard, than to solder it and have wires everywhere. The breadboard isn't required if you choose to get the arduino BT or the bluetooth module from sparkfun. You can get a breadboard on ebay or again at

- Jumper wires/small wires : you can get this from sparkfun too, but you can also salvage small wires from old electronics to keep the costs down.

- Servo motor : Not really required, but used in this instructable for an example with the accelerometer sensor. I'm using the futaba s3003. You can get this at your local hobby shop, ebay, or sparkfun  .

Now It's the time to choose :
- you can go the pretty expensive, but also pretty easy way (no soldering) : go get an Arduino BT . (more than 100$)
- you can go the less expensive way, but less easier (a little soldering but no level shifting) : get a bluesmirf silver breakout board from sparkfun (approx. 40$)
- you can go the cheapest and hardest way (soldering AND level shifting required) : get a bluetooth module from ebay (less than 10$). 

In this instructable,I'm going to get you started with the Bluetooth module from eBay.

So make your choice, get the parts/tools, and head to Step 2. 

Step 2: Solder the Bluetooth Adapter

Picture of Solder the Bluetooth Adapter

We are going to solder the necessary wires on the Bluetooth module :

- Grab the small wires
- Strip them a little bit
- Tin them
- Use the third hand tool to keep into place the Bluetooth module
- Solder carefully the four wires as shown in the photos (Tx, Rx, 3.3v, GND)

Let the Bluetooth module cool down a bit, and head over to the third step : The level shifter

Step 3: The Level Shifter

Picture of The Level Shifter

Note : If you bought a bluetooth module from sparkfun , skip this step, and head to step four.

Since the Arduino's serial output (Tx pin) is 5-volt logic, if we connect it directly to the Rx pin of the Bluetooth module - which is using 3.3-volt logic -  it will fry the Bluetooth chip. Fortunately, the Arduino supports 3.3-volt logic in reception (Rx pin), so no complex circuit is needed. All we have to build is a simple voltage divider :

- take your breadboard
- grab the resistors and some jumper wires
- connect one end of the 20k resistor to the ground
- connect the other end of the 20k to the 10k resistor
- connect these two ends to the Rx pin of the Bluetooth module
- connect the last end of the 10k resistor to the Tx pin of the Arduino (pin 1)
- check the photos to see if you've wired it correctly
- you're done

Now, head over to step 4 : Wiring everything

Step 4: Wiring Everything Else

Picture of Wiring Everything Else

So now that you've got your nice level shifter wired up, It's time to wire everything else :

- Connect the Bluetooth module's Tx pin to the Arduino's Rx pin (pin 0)
- Connect the Bluetooth module's 3.3v pin to the 3.3v supply on the Arduino (labeled 3V3)
- Connect the Bluetooth module's GND pin to one of the Arduino's GND pins
- Grab the servo and some other jumper wires
- Connect the servo's Red pin to the Arduino's 5v supply (labeled 5V, next to the 3V3)
- Connect the servo's Black pin one of the Arduino's GND pins
- Connect the servo's White/Yellow pin to Arduino pin 11
- Check the photo
- You're done !

Now the fifth step : The software setup

Step 5: Software Setup

Picture of Software Setup

Now that we've done the physical setup, it's time to work on the software side.

I've made some screen captures to help you out.

- Take your Android phone
- Install ES file explorer from the android market (any other file browser will do)
- Download the Amarino application
- Download the Amarino plugins
- Put those two files on your smartphone's SD/microSD card.
- Install Amarino and Amarino plugins
- Pair your bluetooth module
- Open the Amarino application
- Add the newly paired device
- Try to connect. If It connects, then good job !
- You're done with the android-side setup. Now onto the Arduino IDE :

- Download the Amarino library:
Amarino arduino library(updated)
Amarino Arduino Library(old)
- Extract it in your libraries folder :     arduino_install_dir/libraries/extract_meetandroid.zip_here
- Restart the Arduino IDE
- If everything went well, you can find the library under "Sketch->Import library"

Head to step 6 for the first example.

Step 6: First Example - the Compass Sensor

Picture of First Example - the Compass Sensor

So everything is working, but why stay there ? The MeetAndroid arduino library is provided with some examples. Here's one using the compass sensor on the smartphone to blink a led on the arduino faster or slower depending on the phone's magnetic orientation. 

- Download the zip file here :  . 
- Extract it in your arduino skecthbook directory
- Restart the arduino IDE
- Open the Arduino IDE
- Open "File->Sketchbook->Compass_Led"
- IMPORTANT : disconnect the bluetooth module's GND pin EACH TIME you want to upload a new sketch to your Arduino.
- Upload the sketch
- Plug the GND pin back in

- Now on the Android side : (again, check the screen captures)
- Open Amarino2.0
- Connect to the bluetooth module
- Add a new compass event.
- Turn your phone... and Whoa ! the led blinks faster or slower.

Now if you want a more advanced example, using the accelerometer and the servo, head to the final step !

Step 7: Last Example - the Accelerometer

Picture of Last Example - the Accelerometer
Dealing with the accelerometer sensor isn't as easy as with the compass sensor. With the accelerometer, we're dealing with an array of floats for each axis. We're going to use another method to access these values. 

- Open "File->Sketchbook->Amarino_servo"
- Upload to the board (remember to disconnect the GND pin while uploading)
- Open the amarino2.0 app
- Remove the compass event
- Add an Accelerometer event
- Connect to the bluetooth module
- Let the magic begin !

You should get something like this :

Step 8: End

Picture of End

So thanks for following this instructable ! If you have questions/comments, please leave a comment ! I would also really like to thank the guys that made the Amarino application, which is very useful. Visit !

The next instructable is going to be about installing and using sl4a and python on android, with again, examples with the Arduino.

Now, get creative !


ZoubirS (author)2017-03-26

Excellent !

jerrymonkey123 (author)2017-02-02 App that is better?

a1r (author)jerrymonkey1232017-02-02

Yeah this instructable is quite old there are much better (and easier to use) apps available now ;)

BlaineN2 (author)2016-01-14

For the blind person I will have distance sensor info and acceleramoter will indicate he will hit wall too soon but how do i get the android to vibrate or beep. I need a signal to be sent to android because will be sending devices where need to keep cost of components as low as possible. Any help would be appreciated.

bome (author)2015-10-22

Thank you for that great tutorial! I am working on a little game and I was wondering if it would be possible to connect multiple android phones via bluetooth to arduino at the same time..

Thank you!

AkshayW (author)2015-06-16

Can the above instructable be used to send data from more than one sensor at the same time?how?

a1r (author)AkshayW2015-06-16

Yes! Have a look at the examples included in the Amarino library. The procedure is :
Add a sensor in the amarino app (the + icon), and choose an identifier for the sensor (usually a letter 'A' or 'C' etc...)

Add a event object with the same letter id in the arduino code

Repeat for each sensor you want to add (light, magnetic, accel etc)

Boom ! Multiple sensors


AkshayW (author)a1r2015-06-17

thank you john

vipulnathani (author)2015-04-22

it is nice concept but i want to do my android mobile GPS interface with arduino using Bluetooth module device so please give me suggestion or tell me how it is possible?

berto.brambila.7 (author)2015-04-02

excellent article.

man, people like you makes me fell proud of been human, thanks!!

mark.g.perkins.1 (author)2014-12-05

Hi this is really useful XD, a mate used this an iphone with a bluetooth connection in the same way for a glider but the communication between the code, instumentation and servos were too slow, can the android phone be connected with a direct cable instead of wireless communication with the arduino?

a1r (author)mark.g.perkins.12014-12-05

You're looking for this :
But you'll have to write some java code for the android phone or use one of the many apps available on the android market (just search ioio on play store)

luiznac (author)2014-11-09

Is there a way to send data through the USB port instead bluetooth?

sibilkoloft (author)2014-10-30

Great Project.

Is there any way to use my Android Amarino App data of accelerometer or orientation sensor to control the RGB hex?

a1r (author)sibilkoloft2014-10-30

Try to combine the servo example and the multicolorlamp one. (I just replied to your PM btw)

mrakuaku (author)2014-04-07

To get the Servo example to work I had to change " int pos = 0; " with just "int pos;" ... otherwise the servo just went to it's mid point position and stayed there. Thanks for the tutorial though, it was helpful! :)

XZ3R0 (author)2013-12-04

Would this work with the BLE Shield made by RedBearLab?

naumansm (author)2013-01-11


that was the problem. I did manage to get an app that can 'discover' Class 0 devices..and I was able to pair the device to my phone. But, Amarino still tries to find new devices...and doesn't see the already paired Bluetooth device. So it doesn't connect. Any ideas ?


pelementmaker (author)naumansm2013-09-12

Having the same problem as you describe. Did you figure out a way to connect the jy-mcu to your phone? What app did you use to make your phone find and pair with the jy-mcu?

fvelasquez2 (author)2013-08-21

Hi, i am going to build a quad copter controlled by an an arduino one and i would like to use my phone's sensors. do you know how fast can the data be transmitted, what is the delay it has? it has to read and send data many times per second to work stabilizing the quad copter. thank you for this awsome tutorial

a1r (author)fvelasquez22013-08-22

Actually you can, BUT imagine the quadricopter falls into a pool or something: you won't have your phone anymore. If you want cheap sensors, check out this page ( There's also a good community working on these softwares too:

The "smartphone on quadricopter" thing is a bad idea, trust me

atsaturyan (author)2013-08-19

Hi, can I use HC06 Serial Bluetooth module?

a1r (author)atsaturyan2013-08-20


sunand c s (author)2013-04-26

hi i am doing a project on android car.i.e controlling a toy car with mobile phones accelerometer.i am using AUBTM-20 bluetooth module and atmega8 microcontroller.i am able to pair my phone with this bluetooth module.but i am not getting any signal at the controller output.could you please help e-mail id is

donmatito (author)2013-03-12

J'adore vos projets. A1R est toujours actif ?

a1r (author)donmatito2013-03-14

Ouaip ! Bon je l'ai un peu delaissé l'année derniere mais la je travaille sur un nouveau projet (donc un nouveau instructable) avec un pote...

naumansm (author)2013-01-10

Hi Guys,

Hope someone can help me. I am trying to pair my Android phone to a JY-MCU bluetooth module I bought from dealextreme. My phone can't find the device when it does a search (it finds other peoples laptops, etc. in my building but not the bluetooth device next to it).

I did try another non-Android old phone and it is able to both see and pair with the bluetooth module. Could this be a Baud rate issue ? Or an Android software issue ?
The Android phone can also detect my older non-Andriod phone and successfully pair with it also.

I think it has something to do with bug in the BroadComm bluetooth stack that is used by most Android phone manufacturers (LG, HTC, Samsung are affected, but not the Google Nexus phones) that prevents discovery to this and all other bluetooth devices that report their Class of Device (CoD) code as 0×00.

Do you guys have any suggestions ?
Kind regards,

naumansm (author)2013-01-10

Hi Guys,

Hope someone can help me. I am trying to pair my Android phone to a JY-MCU bluetooth module I bought from dealextreme. My phone can't find the device when it does a search (it finds other peoples laptops, etc. in my building but not the bluetooth device next to it).

I did try another non-Android old phone and it is able to both see and pair with the bluetooth module. Could this be a Baud rate issue ? Or an Android software issue ?
The Android phone can also detect my older non-Andriod phone and successfully pair with it also.

Kind regards,

nickygiscool (author)2012-12-24

Hi again! could you write a code that can control two servos for the X and Y axis as i am new to arduino.

nickygiscool (author)2012-12-19

Hi, when i try to upload the code to my arduino i just get this error, please help!

In file included from Amarino_Servo.cpp:2:
C:\Users\Sally\Documents\Arduino\arduino-1.0.1-windows (2)\arduino-1.0.1\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
C:\Users\Sally\Documents\Arduino\arduino-1.0.1-windows (2)\arduino-1.0.1\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'

a1r (author)nickygiscool2012-12-20

Use an older version of Arduino IDE, something like 0.27 or older (the MeetAndroid library hasn't been updated for a while)

fckingdavai (author)2012-12-04

I am trying to upload the sketch on my arduino but i have some errors. I have put the meetamarino library and i get this error from my arduino IDE(arduino 1.0.2):

Compass_Led:10: error: 'MeetAndroid' does not name a type
Compass_Led:13: error: 'MeetAndroid' does not name a type
Compass_Led.ino: In function 'void loop()':
Compass_Led:40: error: 'meetAndroid' was not declared in this scope
Compass_Led.ino: In function 'void compass(byte, byte)':
Compass_Led:53: error: 'meetAndroid' was not declared in this scope

What arduino IDE did u use on this tutorial?
pls help me :)

a1r (author)fckingdavai2012-12-07

Yep, the meetandroid library hasn't been updated to work with the newest arduino versions. Try using an older version, like 0.27 something like that. Cheers

fckingdavai (author)2012-10-04

Arduino Uno is compatible with this kind of project?

I saw in your video, that the car is standing on the Arduino. Is it possible to change your project in the way that the car will move on the road? i mean instead of using bluetooth to connect to the smartphone, we can make the connection between the arduino, rc car and the smartphone through wireless?

fckingdavai (author)2012-10-03

I like your instructable, its very good and i rate it.
I whant to go through this tutorial, and i don t really know what arduino microcontroller shoud i buy(i am not looking for a cheap one).

From what i understant from your tutorial, and from the other comments i understood that i can use a Arduino BT and no bluetooth adapter, or an arduino duemilanove with bluetooth adapter. Pls corect me if i am wrong.

I whanna know if i can use some other arduino board +/- bluetooth adapter.

A quick reply whoud be great.

fckingdavai (author)2012-10-02

I whann buy this arduino duemilanove. Is there a difference between a chipset atmega128 and a atmega328?
I mean that if this arduino has an atmega 128, and i buy an arduino with a chipset atmega328(or any kind of chipset other than the atmega128) does this project will work?

pls reply :), sorry of my english is bad

a1r (author)fckingdavai2012-10-02

Of course ! As long as it's an Arduino, there will be no problems man

merlin13 (author)2012-09-22

Awesome instructable, thank you so much for all the work and the details. I got the cheaper BT module and all the steps worked great! Just one thing: the Test app in the Amarino examples is set to 57600 baud - I used it as is and nothing worked. Thought I messed up something till I decided to change it to 9600 and all worked great. It looks to me that 9600 is the default setting - is there a way to change it? Thanks again for this awesome project!

Joxson (author)2011-05-23

Just LOVE this!
Today i recived my BT module, going to solder it later, but now in trying to think about the code.

My goal is to make a rc car that you controll by tilting:)
How do I change the code to get the arduino to react when I tilt the phone another way?
Witch variable should I change??

P.s. Sorry for bad english(I'm Swedish)

arruldd (author)Joxson2012-08-19

Did you succeed ?

Joxson (author)arruldd2012-08-21

yes i did:)
It was very easy:)

a1r (author)arruldd2012-08-19

Man, dont waste your time. Check out my second instructable it's exactly what you want to do.

Mr.What (author)2012-05-28

Which of the white, orange, red, and yellow wires are for Tx, Rx, 3.3v, and GND respectively. Assuming that we are taking about the Tx, and RX for the BlueTooth module (not Tx, Rx for the other side)

I believe that this is the same BT module you can get for $6 ish at ( ?). Look for datasheets on EGBT-046S and RF-0417C

a1r (author)Mr.What2012-06-01

Yup, you're right, I've swapped the ebay module with the one from DX and the car worked great !

HSS1978 (author)2012-04-21

Hello, i new in this things.

When i'm installing the amarino arduino library it gives a "Deprecated file" and asks if i want to download the latest version and i download it.

When i try to run the compass_led.pde it gives me a error:

------D:\Programas\arduino-1.0\libraries\MeetAndroid/MeetAndroid.h:104: error: conflicting return type specified for 'virtual void MeetAndroid::write(uint8_t)'
D:\Programas\arduino-1.0\hardware\arduino\cores\arduino/Print.h:48: error: overriding 'virtual size_t Print::write(uint8_t)'--------


syanikog (author)HSS19782012-05-10

I am having the same problem as HSS 1978. I am trying to complete the tutorial with the RN-42 breakout bluetooth module from sparkfun with an arduino uno. I have no problem uploading the servo sketch without anything plugged into the arduino, but when i am configuring the sketch with just the GND pin (from module) disconnected i get the error. Serial port 'COM5' already in use. Try quiting any programs that may be using it.
at Serial port 'COM5' already in use. Try quiting any programs that may be using it.

any ideas? could it be because i am using an uno instead of a duemilanov?

a1r (author)syanikog2012-05-11

Seems like a serial port problem: disconnect the Arduino, write down all the serial ports available (in Tools --> Serial Port), reconnect the Arduino and select the Serial port that has just appeared in the list.

syanikog (author)a1r2012-05-17

I got it working, thanks for the help. It was a serial port problem, I was on the right port, but my bluesmirf module wasn't at the correct baud rate. I had to switch both to 115200 for it to work. Also I get the error:
' avrdude: stk500_getsync(): not in sync: resp=0x00'
if I try to upload with the Rx Tx pins connected to my UNO. I simply uploaded then connected the module and everything worked fine.
Thanks for the great tutorial!

bwrussell (author)2012-02-29

Glad I stumbled on this page before my BT module showed up for a different project, probably would have cooked it with 5 V. Thanks!

mkhanbag (author)2012-02-23


Please help me with the bluetooth module, i want to change the baud rate and the pairing info, i used a usb to ttl adapter, connected TX, RX of USB to ttl to RX, TX of Bluetooth Module respectively and applied 3.7V to the Bluetooth module(made sure that its not in paired mode, Led flashing) - The problem i have is, as soon as i open session - hyper-terminal or putty or any com tool, the BT module is contentiously sending non stop 'Y' kind of characters

This is what i bought off ebay : "NEW Serial Bluetooth RF Transceiver Module RS232 Master + backplane 4 pin TTL"
Item No: 110805911219

I tried going through all the google searches but no vail, please help. Thanks in advance, Khan

About This Instructable




Bio: My name is Jonathan Rico, I'm 18 and I live in France.I'm in my first year of an electronics degree. And, the ... More »
More by a1r:WiFi Stunt CarNunchuk-controlled HelicopterAndroid RC Car
Add instructable to: