Difference between revisions of "S14: Location Tracker"

From Embedded Systems Learning Academy
Jump to: navigation, search
(Locator Beacon)
(Project Source Code)
 
(9 intermediate revisions by one other user not shown)
Line 1: Line 1:
=== Grading Criteria ===
+
== Location Tracker ==
<font color="green">
 
*  How well is Software & Hardware Design described?
 
*  How well can this report be used to reproduce this project?
 
*  Code Quality
 
*  Overall Report Quality:
 
**  Software Block Diagrams
 
**  Hardware Block Diagrams
 
**:  Schematic Quality
 
**  Quality of technical challenges and solutions adopted.
 
</font>
 
 
 
== Project Title ==
 
  
 
== Abstract ==
 
== Abstract ==
Line 26: Line 14:
 
* Map location of Android phone and target
 
* Map location of Android phone and target
 
* Retrieve and draw driving/walking path from source to target
 
* Retrieve and draw driving/walking path from source to target
 
  
 
=== Team Members & Responsibilities ===
 
=== Team Members & Responsibilities ===
 
*  Arpit Amin
 
*  Arpit Amin
**  GPS: communication and data parsing
+
**  GPS: Communication and data parsing
 
*  Caleb Chow
 
*  Caleb Chow
**  Android application: SMS message handling, Google Map API and UI
+
**  Android application: SMS message handling, Google Maps API, and UI
Cynthia Ho
+
Sin Yu Ho
**  SMS: multitasking design to handle SIM900 and GPS modules
+
**  SMS: Multitasking design to handle SIM900 and GPS modules
 
*  Abraham Ruiz
 
*  Abraham Ruiz
**  Android application: Source to destination path algorithms and Google Map API
+
**  Android application: Source to destination path algorithms and Google Maps API
  
 
== Schedule ==
 
== Schedule ==
  
{| class="wikitable"
+
{| class="wikitable" style="margin: 1em auto 1em auto;"
 
|-
 
|-
 
! scope="col"| Week#
 
! scope="col"| Week#
Line 138: Line 125:
  
 
== Parts List & Cost ==
 
== Parts List & Cost ==
{| class="wikitable"
+
{| class="wikitable" style="margin: 1em auto 1em auto;"
 
|-
 
|-
 
! scope="col"| Part Name and Link
 
! scope="col"| Part Name and Link
 
! scope="col"| Price
 
! scope="col"| Price
 
|-
 
|-
! scope="row" |[http://www.elecfreaks.com/store/gprsgsm-moduleefcom-pro-p-450.html SIM900 GPRS/GSM module]
+
|align="center" |[http://www.elecfreaks.com/store/gprsgsm-moduleefcom-pro-p-450.html SIM900 GPRS/GSM module]
|$48
+
|align="center" |$48
 
|-
 
|-
! scope="row" |[http://www.dx.com/p/ublox-neo-6m-gps-module-w-eeprom-blue-green-251973?tc=USD&gclid=CMORweqXt74CFWYV7AodrSUAHQ Ublox NEO-6M GPS Module]
+
|align="center" |[http://www.dx.com/p/ublox-neo-6m-gps-module-w-eeprom-blue-green-251973?tc=USD&gclid=CMORweqXt74CFWYV7AodrSUAHQ Ublox NEO-6M GPS Module]
|$23
+
|align="center" |$23
 
|-
 
|-
! scope="row" |[http://www.amazon.com/gp/product/B00H963GT0/ref=oh_details_o07_s00_i00?ie=UTF8&psc=1 EasyAcc USB Power Bank DC 5V 2.1A, Output]
+
|align="center" |[http://www.amazon.com/gp/product/B00H963GT0/ref=oh_details_o07_s00_i00?ie=UTF8&psc=1 EasyAcc USB Power Bank DC 5V 2.1A, Output]
|$23
+
|align="center" |$23
 
|-
 
|-
! scope="row" |[http://prepaid-phones.t-mobile.com/sim-card Mini SIM card]  
+
|align="center" |[http://prepaid-phones.t-mobile.com/sim-card Mini SIM card]  
|$20  ($10 card + $10 T-Mobile prepaid service)
+
|align="center" |$20  ($10 card + $10 T-Mobile prepaid service)
 
|-
 
|-
! scope="row" |SJ One Board
+
|align="center" |SJ One Board
|$80
+
|align="center" |$80
 
|-
 
|-
 
|-
 
|-
! scope="row" |Total
+
!scope="row" |Total
|$194
+
!scope="row" |$194
 
|-
 
|-
 
|}
 
|}
Line 171: Line 158:
  
 
<center>
 
<center>
[[File:CmpE244_S14_T5_System_Block_Diagram.png|center|frame|Figure 1. System Block Diagram]]
+
[[File:CmpE244_S14_T5_System_Block_Diagram.png|center|thumb|650px|Figure 1. System Block Diagram]]
 
</center>
 
</center>
 +
  
 
<center>
 
<center>
[[File:CmpE244_S14_T5_Locator_Beacon.png|center|frame|Figure 2. Locator Beacon]]
+
[[File:CmpE244_S14_T5_Locator_Beacon.png|center|thumb|600px|Figure 2. Locator Beacon]]
 
</center>
 
</center>
  
 
=== Hardware Interface ===
 
=== Hardware Interface ===
 
The GPS module communicates using UART. The following table shows the hardware interface between the GPS module and SJ One board:
 
The GPS module communicates using UART. The following table shows the hardware interface between the GPS module and SJ One board:
{| class="wikitable"
+
{| class="wikitable" style="margin: 1em auto 1em auto;"
 
|-
 
|-
 
! SJ One Board
 
! SJ One Board
 
! GPS Module
 
! GPS Module
 
|-
 
|-
|
+
|align="center" |
 
VCC(3.3V)
 
VCC(3.3V)
|
+
|align="center" |
 
VCC (P1)
 
VCC (P1)
 
|-
 
|-
|
+
|align="center" |
 
Ground (GND)
 
Ground (GND)
|
+
|align="center" |
 
Ground (P4)
 
Ground (P4)
 
|-
 
|-
|
+
|align="center" |
 
UART2 RX (P2.9)
 
UART2 RX (P2.9)
|
+
|align="center" |
 
UART TX (P3)
 
UART TX (P3)
 
|}
 
|}
  
 
The SIM900 GPRS/GMS module also communicates using UART. The following table shows the pin connections:
 
The SIM900 GPRS/GMS module also communicates using UART. The following table shows the pin connections:
{| class="wikitable"
+
{| class="wikitable" style="margin: 1em auto 1em auto;"
 
|-
 
|-
 
! SJ One Board
 
! SJ One Board
Line 210: Line 198:
 
|
 
|
  
|
+
|align="center" |
 
VCC (P2)
 
VCC (P2)
|
+
|align="center" |
 
5V
 
5V
 
|-
 
|-
|
+
|align="center" |
 
Ground (GND)
 
Ground (GND)
|
+
|align="center" |
 
Ground (P1)
 
Ground (P1)
|
+
|align="center" |
 
Ground
 
Ground
 
|-
 
|-
|
+
|align="center" |
 
UART3 RX (P4.29)
 
UART3 RX (P4.29)
|
+
|align="center" |
 
UART TX (P3)
 
UART TX (P3)
 
|
 
|
 
|-
 
|-
|
+
|align="center" |
 
UART3 TX (P4.28)
 
UART3 TX (P4.28)
|
+
|align="center" |
 
UART RX (P4)
 
UART RX (P4)
 
|
 
|
 
|-
 
|-
|
+
|align="center" |
 
GPIO Output (P2.0)
 
GPIO Output (P2.0)
|
+
|align="center" |
 
Power (P5)
 
Power (P5)
 
|
 
|
 
|-
 
|-
|
+
|align="center" |
 
GPIO Output (P2.1)
 
GPIO Output (P2.1)
|
+
|align="center" |
 
Reset (P6)
 
Reset (P6)
 
|
 
|
Line 251: Line 239:
 
Figure 3 shows a schematic containing the pin connections of the GPS and GPRS/GSM module.
 
Figure 3 shows a schematic containing the pin connections of the GPS and GPRS/GSM module.
 
<center>
 
<center>
[[File:CmpE244_S14_T5_Locator_Beacon_Schematic.png|center|frame|Figure 3. Locator Beacon Schematic]]
+
[[File:CmpE244_S14_T5_Locator_Beacon_Schematic.png|center|thumb|500px|Figure 3. Locator Beacon Schematic]]
 
</center>
 
</center>
  
=== Software Design ===
+
=== Software Design and Implementation ===
 
==== Locator Beacon ====
 
==== Locator Beacon ====
 
The locator beacon is composed of four parts: a SJ One board, GPS and GPRS/GSM modules, and 5V 2.1A battery pack. On the SJ One board, the processor communicates with GPS and GPRS modules. Both modules have their own task. The following explains the features of each task and introduces a few main functions.
 
The locator beacon is composed of four parts: a SJ One board, GPS and GPRS/GSM modules, and 5V 2.1A battery pack. On the SJ One board, the processor communicates with GPS and GPRS modules. Both modules have their own task. The following explains the features of each task and introduces a few main functions.
Line 262: Line 250:
 
##calculate()- This function take the value from the run task and converts the NMEA data to the coordinates value so that Google Maps can understand the coordinates and display the location on the maps
 
##calculate()- This function take the value from the run task and converts the NMEA data to the coordinates value so that Google Maps can understand the coordinates and display the location on the maps
  
 +
Figure 4 shows the flowchart for the GPS task.
 +
<center>
 +
[[File:CmpE244_S14_T5_GPS_Task_Flowchart.png|center|thumb|650px|Figure 4. GPS Task Flowchart]]
 +
</center>
 
#GPRS/GSM Task - This task manages receiving and sending SMS messages. It sends a signal to the GPS task to obtain the current location, which is passed between the tasks using a queue. To communicate with GPRS module, UART 3 is used and its baud rate is set to 115200 bps. Then, the GPRS module is confirmed to be on by setting AT commands and getting a response. If GPRS module is not on, a reset signal and power signal are sent from SJSU One board.Then, SJSU One board turn off GPRS echo feature, and also setup the sending and receiving feature.   
 
#GPRS/GSM Task - This task manages receiving and sending SMS messages. It sends a signal to the GPS task to obtain the current location, which is passed between the tasks using a queue. To communicate with GPRS module, UART 3 is used and its baud rate is set to 115200 bps. Then, the GPRS module is confirmed to be on by setting AT commands and getting a response. If GPRS module is not on, a reset signal and power signal are sent from SJSU One board.Then, SJSU One board turn off GPRS echo feature, and also setup the sending and receiving feature.   
 
##init()  -  set baud rate, create binary semaphore and a queue to store message
 
##init()  -  set baud rate, create binary semaphore and a queue to store message
Line 272: Line 264:
 
##userRequest(char *senderNum, char * msg)  -  This checks the phone number with the authorized phone number. If it is an authorized phone number, it starts sending SMS or stop sending SMS according to the request
 
##userRequest(char *senderNum, char * msg)  -  This checks the phone number with the authorized phone number. If it is an authorized phone number, it starts sending SMS or stop sending SMS according to the request
  
Figure 4 shows the flowchart for the GPRS task.
+
Figure 5 shows the flowchart for the GPRS task.
 
<center>
 
<center>
[[File:CmpE244_S14_T5_GPRS_Task_Flowchart.png|center|frame|Figure 4. GPRS Task Flowchart]]
+
[[File:CmpE244_S14_T5_GPRS_Task_Flowchart.png|center|thumb|650px|Figure 5. GPRS Task Flowchart]]
 
</center>
 
</center>
  
Figure 5 shows the local variable that are used.
+
 
 +
Figure 6 shows the local variable that are used.
 
<center>
 
<center>
[[File:CmpE244_S14_T5_GPRS_Task_Local_Variables.png|center|frame|Figure 5. GPRS Task Local Variables]]
+
[[File:CmpE244_S14_T5_GPRS_Task_Local_Variables.png|center|thumb|225px|Figure 6. GPRS Task Local Variables]]
 
</center>
 
</center>
  
Line 299: Line 292:
 
#*Once a valid destination location is received, the location is displayed
 
#*Once a valid destination location is received, the location is displayed
 
#*It chooses between walking path mode or driving path mode based on distance to the destination
 
#*It chooses between walking path mode or driving path mode based on distance to the destination
#*The fastest route to the destination is retrieved using the API from the gdaplibrary library
+
#*The fastest route to the destination is retrieved using the API from the [https://github.com/akexorcist/Android-GoogleDirectionAndPlaceLibrary Google Direction and Place library]
 
#*A button is used to start and stop receiving GPS coordinates
 
#*A button is used to start and stop receiving GPS coordinates
 
#*A settings page can be accessed to configure the target name and phone number
 
#*A settings page can be accessed to configure the target name and phone number
 
Please note that in order to use Google Maps API v2. you need to get the an Android certificate and the Google Maps API key. Directions on how to get this credential can be found [https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key: here].
 
Please note that in order to use Google Maps API v2. you need to get the an Android certificate and the Google Maps API key. Directions on how to get this credential can be found [https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key: here].
  
Figure 6 shows the software architecture diagram of the Location Tracker android app.
+
Figure 7 shows the software architecture diagram of the Location Tracker android app.
 
<center>
 
<center>
[[File:CmpE244_S14_T5_Location_Tracker_App_Architecture.png|center|frame|Figure 6. Software Architecture Diagram for the Location Tracker App]]
+
[[File:CmpE244_S14_T5_Location_Tracker_App_Architecture.png|center|thumb|800px|Figure 7. Software Architecture Diagram for the Location Tracker App]]
 
</center>
 
</center>
  
=== Implementation ===
+
== Testing & Technical Challenges ==
This section includes implementation, but again, not the details, just the high levelFor example, you can list the steps it takes to communicate over a sensor, or the steps needed to write a page of memory onto SPI Flash. You can include sub-sections for each of your component implementation.
+
=== Android App ===
 +
In order to test this system. One student started to run the Android App from Campbell, CA and another student started to run the SJ One board from Sunnyvale. Clearly, the distance between the two student is more than 200 yards. Therefore, the Android will draw the Driving fastest route. When the user presses the “update” button, he/she will receive sms with the current latitude and longitude of the target. These message will never stop unless the user presses the “stop” buttonFigure 9  shows the screenshot of the app after pressing the update button; note that the app shows a path using freeway to the destination, and it prints its Latitude and Longitude. To protect the home location of our student, we “blind” the location of the destination. Figure 10 shows the screenshot of the app after pressing the stop button. This test shows that the android app is communicating with the SJ One Board using the GSM network and the SIM900 module. In addition, this test shows that the SJ One Board is communicating with the GPS module by requesting coordinate data.
 +
 
 +
<center>
 +
[[File:CmpE244_S14_T5_App_Home.png|center|thumb|400px|Figure 8. App Home Screen]]
 +
</center>
  
== Testing & Technical Challenges ==
 
Describe the challenges of your project.  What advise would you give yourself or someone else if your project can be started from scratch again?
 
Make a smooth transition to testing section and described what it took to test your project.
 
  
Include sub-sections that list out a problem and solution, such as:
+
<center>
 +
[[File:CmpE244_S14_T5_App_Started.png|center|thumb|400px|Figure 9. App Updating]]
 +
</center>
 +
 
 +
 
 +
<center>
 +
[[File:CmpE244_S14_T5_App_Ended.png|center|thumb|400px|Figure 10. App Stopped Updating]]
 +
</center>
 +
 
 +
 
 +
<center>
 +
[[File:CmpE244_S14_T5_App_Walking.png|center|thumb|400px|Figure 11. App Walking Path]]
 +
</center>
 +
 
 +
 
 +
<center>
 +
[[File:CmpE244_S14_T5_App_Settings.png|center|thumb|400px|Figure 12. App Settings]]
 +
</center>
 +
 
 +
Please note that if you do not press the “stop” button, the SJ One Board will continuously send sms to the android app. Therefore, surcharge will apply by your cell phone carrier.
 +
 
 +
==== Fastest Walking/Driving Path ====
 +
One of the technical challenge in this project was to find the fastest driving in the android app. Google Maps Android API v2 does not provide any API to draw a path between the source and destination; as a result, the [https://github.com/akexorcist/Android-GoogleDirectionAndPlaceLibrary Google Direction and Place library] was used. This library is not included in the Android source code, so the documentation is vague.
 +
 
 +
=== Locator Beacon ===
 +
==== SMS Messaging ====
 +
This part of the project requires to send and receive SMS message. One of the technical challenge is the GSM network. During this development, a prepaid card is used. A prepaid card is required to activate daily by a normal cell phone. Also, the received buffer in SIM900 module can only store sender information and the first character in SMS message body. Therefore, the locator beacon receives one character ‘Y’ to start sending latitude and longitude data, or character ‘N’ to stop sending coordinate.
  
=== My Issue #1 ===
+
==== GPS ====
Discuss the issue and resolution.
+
After interfacing the GPS module with SJOne board the data received from the module was zero for both latitude and longitude. As the GPS module schematics showed different baud rate, we tried all the baud rate to check on which baud rate the data is received. After testing multiple time we decided to test in open field. In open field we started getting data at 9600 bps. The problem we faced here was that this GPS module was not for indoor usage. If the building is made of concrete and iron, then this GPS module won’t receive any data. For this GPS module, we had to be outside the building all the time since this GPS module was specifically designed for RC airplanes.
  
 
== Conclusion ==
 
== Conclusion ==
Conclude your project here. You can recap your testing and problems. You should address the "so what" part here to indicate what you ultimately learnt from this project. How has this project increased your knowledge?
+
The Location Tracker is designed to keep track of where someone or something is. It brings together a microcontroller, GPS module, GPRS/GSM module, and Android phone to create a system capable of helping locate an object. The main objective of this project was to allow an Android phone to receive GPS coordinates of the object being tracked. This was accomplished by using a microcontroller to read GPS coordinates and sending the coordinates to the phone through SMS messages. The main challenge of the project was in the SMS handling at the microcontroller. SMS messages were sent and received by carefully following the steps defined by the SIM900 AT command manual.
 +
 
 +
Overall, this project taught how to divide a project into smaller components so that the components could be integrated later. Communication and synchronization between the tasks in FreeRTOS was also practiced. Information had to be passed between FreeRTOS tasks and sent to the Android app, which then had to be processed and displayed in a manner that is useful to the user. A map with the path to the object, along with the timestamp, distance, and name were displayed such that the user of the app could track and locate the object.
  
 
=== Project Video ===
 
=== Project Video ===
Upload a video of your project and post the link here.
+
TODO
  
 
=== Project Source Code ===
 
=== Project Source Code ===
Send me your zipped source code and I will upload this to SourceForge and link it for you.
+
*  [https://sourceforge.net/projects/sjsu/files/CmpE244_SJSU_S2014/ Sourceforge source code link]
  
 
== References ==
 
== References ==
 
=== Acknowledgement ===
 
=== Acknowledgement ===
Any acknowledgement that you may wish to provide can be included here.
+
We would like to thank Preet for teaching us about different serial communication protocols, how to write drivers, and about FreeRTOS.
  
 
=== References Used ===
 
=== References Used ===
List any references used in project.
+
Android Developer: [https://developer.android.com/index.html]
 +
 
 +
SJ One Board: [http://www.socialledge.com/sjsu/index.php?title=SJ_One_Board]
 +
 
 +
SIM900 AT Command Manual [ftp://imall.iteadstudio.com/IM120417009_IComSat/DOC_SIM900_AT%20Command%20Manual_V1.03.pdf]
  
=== Appendix ===
+
Google Direction and Place Library [https://github.com/akexorcist/Android-GoogleDirectionAndPlaceLibrary]
You can list the references you used.
 

Latest revision as of 23:42, 6 August 2014

Location Tracker

Abstract

The location tracker is designed to help you keep on eye on where someone—like your kid—is. An Android application communicates with the locator beacon to determine the location of the target and how to get there.

Objectives & Introduction

Two nodes shall be designed to communicate over GPRS/GSM network. Node Android requests data from node target. The Android application pinpoints the target and finds the fastest path to the target based on the received location. A SMS message is sent by the app to trigger the beacon to start sending its coordinates back. A GPRS/GSM module controlled by the SJ One Board on the beacon receives the SMS message, and triggers a new GPS coordinate reading from a GPS module. The GPS coordinates are sent back periodically through SMS messages for the app to map.


The project required the following objectives to be accomplished:

  • Read GPS coordinates from GPS module
  • Receive and send SMS messages from GPRS/GSM module
  • Send and receive SMS messages from within Android app
  • Map location of Android phone and target
  • Retrieve and draw driving/walking path from source to target

Team Members & Responsibilities

  • Arpit Amin
    • GPS: Communication and data parsing
  • Caleb Chow
    • Android application: SMS message handling, Google Maps API, and UI
  • Sin Yu Ho
    • SMS: Multitasking design to handle SIM900 and GPS modules
  • Abraham Ruiz
    • Android application: Source to destination path algorithms and Google Maps API

Schedule

Week# Date Task Actual
1 3/6
  • System design
  • Order parts
  • Ordered GSM/GPRS module
  • Obtained GPS module from previous project
2 3/13
  • Android app UI design
  • Decided UI requirements
3 3/20
  • Interface GPS module
  • Parse GPS coordinates
  • Test GPS parsing
  • Begin interfacing GPS and GSM/GPRS modules
4 3/27
  • Interface GSM/GPRS module
  • Test sending SMS messages
  • GPS data parsing complete
5 4/3
  • Make Android app recognize and parse SMS message
  • SJ One board sends SMS messages
  • Begin work on Android app
6 4/10
  • Integrate Google Map into app
  • Continue trying to get app to send and receive SMS
7 4/17
  • Improve app UI
  • Testing
  • Android app sends and receive SMS messages
  • Locations are displayed on map
8 4/24
  • Testing indoor and outdoor
  • Find recommendations for future improvement
  • Integrate GPS portion with SMS portion
9 5/1
  • Final touches
  • Package locator module
10 5/8
  • Finish report
  • Add path between self and target
11 5/15
  • Prepare for demo
  • Finish report
  • Demo

Parts List & Cost

Part Name and Link Price
SIM900 GPRS/GSM module $48
Ublox NEO-6M GPS Module $23
EasyAcc USB Power Bank DC 5V 2.1A, Output $23
Mini SIM card $20 ($10 card + $10 T-Mobile prepaid service)
SJ One Board $80
Total $194

Design & Implementation

Hardware Design

The Android app communicates with the SJ One board using the GSM network. Since the SJ One Board does not have an integrated GSM module, the SIM900 module was chosen to provide communication between the Android App and the SJ One Board. The SIM900 was interfaced to the SJ One Board via UART. A GPS module is required to connect with satellites to provide a triangulation area for the SJ One Board; Moreover, this GPS module must provide latitude and longitude data as fast as possible. It must also contain a footprint (including antenna). For this reason, we choose the Ublox NEO-6M GPS Module. This module weights 0.63 oz with the following dimensions: 1.22 in. x 0.91 in. x 0.16 in. (L X W X H). This GPS module was interfaced to the SJ One Board via UART. This module have four pin named power vcc, Ground gnd, transmitter tx and receiver rx. This module default baud rate is 9600 bps. This module can be programmed for different baud rate depending on requirement. Figure 1 shows the block diagram for this project and Figure 2 shows the locator beacon components.

Figure 1. System Block Diagram


Figure 2. Locator Beacon

Hardware Interface

The GPS module communicates using UART. The following table shows the hardware interface between the GPS module and SJ One board:

SJ One Board GPS Module

VCC(3.3V)

VCC (P1)

Ground (GND)

Ground (P4)

UART2 RX (P2.9)

UART TX (P3)

The SIM900 GPRS/GMS module also communicates using UART. The following table shows the pin connections:

SJ One Board SIM900 GPRS/GSM Module External 5V Power Bank

VCC (P2)

5V

Ground (GND)

Ground (P1)

Ground

UART3 RX (P4.29)

UART TX (P3)

UART3 TX (P4.28)

UART RX (P4)

GPIO Output (P2.0)

Power (P5)

GPIO Output (P2.1)

Reset (P6)

Since the SIM900 and the GPS modules communicate via UART, There is only one device driver required for the SJ One Board: UART. UART 2 and UART3 drivers were reused from the provided base project.

Figure 3 shows a schematic containing the pin connections of the GPS and GPRS/GSM module.

Figure 3. Locator Beacon Schematic

Software Design and Implementation

Locator Beacon

The locator beacon is composed of four parts: a SJ One board, GPS and GPRS/GSM modules, and 5V 2.1A battery pack. On the SJ One board, the processor communicates with GPS and GPRS modules. Both modules have their own task. The following explains the features of each task and introduces a few main functions.

  1. GPS Task - GPS task gets the data from the GPS module and parses the GPS data. The data is retrieved from the module in NMEA format. With the use of some computations, this NMEA format can be used to find coordinates that can be used by Google Maps. UART2 on the SJ One board is initialized at a baud rate of 9600 bps to communicate with the GPS module.
    1. init() - This task get the UART instance and initialize the UART bus at 9600 bps for GPS module to transmit the NMEA Data
    2. run()- As GPS output various lines of data, this task checks if the data is available or not. Then it locates the line that start with “$GPGLL”, as this line contains all the usefull data for this project. The second segment on this line is the latitude in NMEA format, and third segment is the direction N or S, indicating northern or southern hemisphere. In the same way, the fourth segment is longitude and fifth is E or W, indicating Eastern or Western. This task takes the NMEA format longitude and multiplies it with -1 if it indicates E, and multiplies latitude with -1 if it indicate S
    3. calculate()- This function take the value from the run task and converts the NMEA data to the coordinates value so that Google Maps can understand the coordinates and display the location on the maps

Figure 4 shows the flowchart for the GPS task.

Figure 4. GPS Task Flowchart
  1. GPRS/GSM Task - This task manages receiving and sending SMS messages. It sends a signal to the GPS task to obtain the current location, which is passed between the tasks using a queue. To communicate with GPRS module, UART 3 is used and its baud rate is set to 115200 bps. Then, the GPRS module is confirmed to be on by setting AT commands and getting a response. If GPRS module is not on, a reset signal and power signal are sent from SJSU One board.Then, SJSU One board turn off GPRS echo feature, and also setup the sending and receiving feature.
    1. init() - set baud rate, create binary semaphore and a queue to store message
    2. taskEntry() - Check if GPRS module is on, turn off the echo, set receive and send message format
    3. run() - This schedules SMS send and receive activities
    4. checkNetworkRegAndSendSMS() - This checks if the SIM card is registered with the Network. If it is, call pass the number and message to sendSMS(). If there is no message in the message queue, it sends a semaphore to GPS module to obtain a new coordinate
    5. sendSms(const char * number, char * message) - This gets the phone number and message and build a AT command and send it to GPRS module
    6. recvSms() - This checks the received buffer in GPRS if there is any message is arrived. If there is, go to readSMS()
    7. readSms(char * recvStr, int ) - This obtains the whole message from received buffer and uses smsDecoder() to get sender number and sender request. Then send it to userRequest
    8. userRequest(char *senderNum, char * msg) - This checks the phone number with the authorized phone number. If it is an authorized phone number, it starts sending SMS or stop sending SMS according to the request

Figure 5 shows the flowchart for the GPRS task.

Figure 5. GPRS Task Flowchart


Figure 6 shows the local variable that are used.

Figure 6. GPRS Task Local Variables

The local variable, gprs, is a pointer to uart to communicate with SIM900 module. The smsSendMsg_f is to indicate if the SMS should keep sending or not, and countDisplay is the number that is display on LED on SJ One board to indicate number of SMS is sent.

Android App

There are three main components/Java files in the Android application:

  1. MessagingReceiver
    • This module is started when android app starts (from AndroidManifest)
    • It knows when system receives an SMS message and passes the event to the MessagingService
  2. MessagingService
    • This module retrieves the source and body of the SMS message from the event received
    • The source phone number is validated based on the phone number set in the user settings
    • Once validated, the body is validated and parsed to get the GPS coordinates
    • The coordinates are passed to the MainActivity to be displayed
  3. MainActivity
    • This module contains the UI for the app
    • The device location is displayed when the app is started and continually updated
    • Once a valid destination location is received, the location is displayed
    • It chooses between walking path mode or driving path mode based on distance to the destination
    • The fastest route to the destination is retrieved using the API from the Google Direction and Place library
    • A button is used to start and stop receiving GPS coordinates
    • A settings page can be accessed to configure the target name and phone number

Please note that in order to use Google Maps API v2. you need to get the an Android certificate and the Google Maps API key. Directions on how to get this credential can be found here.

Figure 7 shows the software architecture diagram of the Location Tracker android app.

Figure 7. Software Architecture Diagram for the Location Tracker App

Testing & Technical Challenges

Android App

In order to test this system. One student started to run the Android App from Campbell, CA and another student started to run the SJ One board from Sunnyvale. Clearly, the distance between the two student is more than 200 yards. Therefore, the Android will draw the Driving fastest route. When the user presses the “update” button, he/she will receive sms with the current latitude and longitude of the target. These message will never stop unless the user presses the “stop” button. Figure 9 shows the screenshot of the app after pressing the update button; note that the app shows a path using freeway to the destination, and it prints its Latitude and Longitude. To protect the home location of our student, we “blind” the location of the destination. Figure 10 shows the screenshot of the app after pressing the stop button. This test shows that the android app is communicating with the SJ One Board using the GSM network and the SIM900 module. In addition, this test shows that the SJ One Board is communicating with the GPS module by requesting coordinate data.

Figure 8. App Home Screen


Figure 9. App Updating


Figure 10. App Stopped Updating


Figure 11. App Walking Path


Figure 12. App Settings

Please note that if you do not press the “stop” button, the SJ One Board will continuously send sms to the android app. Therefore, surcharge will apply by your cell phone carrier.

Fastest Walking/Driving Path

One of the technical challenge in this project was to find the fastest driving in the android app. Google Maps Android API v2 does not provide any API to draw a path between the source and destination; as a result, the Google Direction and Place library was used. This library is not included in the Android source code, so the documentation is vague.

Locator Beacon

SMS Messaging

This part of the project requires to send and receive SMS message. One of the technical challenge is the GSM network. During this development, a prepaid card is used. A prepaid card is required to activate daily by a normal cell phone. Also, the received buffer in SIM900 module can only store sender information and the first character in SMS message body. Therefore, the locator beacon receives one character ‘Y’ to start sending latitude and longitude data, or character ‘N’ to stop sending coordinate.

GPS

After interfacing the GPS module with SJOne board the data received from the module was zero for both latitude and longitude. As the GPS module schematics showed different baud rate, we tried all the baud rate to check on which baud rate the data is received. After testing multiple time we decided to test in open field. In open field we started getting data at 9600 bps. The problem we faced here was that this GPS module was not for indoor usage. If the building is made of concrete and iron, then this GPS module won’t receive any data. For this GPS module, we had to be outside the building all the time since this GPS module was specifically designed for RC airplanes.

Conclusion

The Location Tracker is designed to keep track of where someone or something is. It brings together a microcontroller, GPS module, GPRS/GSM module, and Android phone to create a system capable of helping locate an object. The main objective of this project was to allow an Android phone to receive GPS coordinates of the object being tracked. This was accomplished by using a microcontroller to read GPS coordinates and sending the coordinates to the phone through SMS messages. The main challenge of the project was in the SMS handling at the microcontroller. SMS messages were sent and received by carefully following the steps defined by the SIM900 AT command manual.

Overall, this project taught how to divide a project into smaller components so that the components could be integrated later. Communication and synchronization between the tasks in FreeRTOS was also practiced. Information had to be passed between FreeRTOS tasks and sent to the Android app, which then had to be processed and displayed in a manner that is useful to the user. A map with the path to the object, along with the timestamp, distance, and name were displayed such that the user of the app could track and locate the object.

Project Video

TODO

Project Source Code

References

Acknowledgement

We would like to thank Preet for teaching us about different serial communication protocols, how to write drivers, and about FreeRTOS.

References Used

Android Developer: [1]

SJ One Board: [2]

SIM900 AT Command Manual [3]

Google Direction and Place Library [4]