Introduction: Android and Arduino: Location Object in Area

What you need:

1. Any Arduino microcontroler I used mega.

2. Bluetooth receiver/transmitter, I used HC-05, easy find on ebay or other web shops.

3. GPS receiver EM-406A, but I guess you can find something similar or simple on web shops.

4. LED.

5. Any Resistor from 330 to 560 ohm is good.

6. Android studio,

7. Arduino,

8. Some knowledge in programming java, c++.

9. Working Android device with Bluetooth and GPS.

Step 1: Wiring

Do wiring like in the picture.

Just keep in mind your modules could have different VCC voltage levels, my Bluetooth module had 3,3V and GPS module had 5V, but if you use different modules or they could be updated, check datasheet before connecting because wrong level could damage your modules.

Step 2: Pairing Your Device With Bluetooth Module

After wiring
is done power the arduino, you should see red led lighting on GPS module this means it's working but can't get position values, if you go outside GPS module led will blink green it's means it's getting position values.

Next pair Bluetooth module with your Arduino device, if you don't know how to do it just google it. When it's done in your Android device paired dvices list you should see HC-05 device with MAC addres numbers like this 00:12:11:13:16:57, write them becouse you will need this in next step.

Step 3: Android App

Do steps like in this tutotial

Test it and if app is working, lets replace some code. Firs replace activity_maps.xml code, don't just copy paste all code it will get you errors, do it peace by peace. Replace fragment layout with RelativeLayout, and add in it fragment layout like in my code, just keep all layout parameters your, don't copy from my code liek tools:context, android:id=, android:name=". Now copy paste buttons layouts like in my code. Now you can test it if it shows buttons great if not just go to activity_maps.xml and select Design tab and correct buttons position by hand.In AndroidManifest just copy and paste permissions. In copy and paste code carefully peace by peace and read comments, don't forget to replace Mac address 00:12:11:13:16:57 with your Bluetooth device Mac address.Test it if you don't get errors, you good to go for next and last step.

Step 4: Arduino Coding

Now you need to uploud arduino code to your arduino, before doing it you should get TinyGPS library: google how toadd it.

Read code comments, because you may need to do some adjustments and if you using different board you also need change some variables of serial. So before uploading complete code disconnect GPS module TX wire from arduino pin 0, after code uploads connect it again, and you good to go.