Difference between revisions of "S14: Location Tracker"
Proj user5 (talk | contribs) (→Schedule) |
(→Project Source Code) |
||
(16 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
− | == | + | == Location Tracker == |
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Abstract == | == 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 == | == 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 === | === Team Members & Responsibilities === | ||
* Arpit Amin | * Arpit Amin | ||
− | ** | + | ** GPS: Communication and data parsing |
* Caleb Chow | * 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 | * Abraham Ruiz | ||
− | ** | + | ** 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 44: | Line 39: | ||
*System design | *System design | ||
*Order parts | *Order parts | ||
− | |Ordered GSM/GPRS | + | | |
+ | *Ordered GSM/GPRS module | ||
+ | *Obtained GPS module from previous project | ||
|- | |- | ||
! scope="row"| 2 | ! scope="row"| 2 | ||
Line 51: | Line 48: | ||
*Android app UI design | *Android app UI design | ||
| | | | ||
+ | *Decided UI requirements | ||
|- | |- | ||
! scope="row"| 3 | ! scope="row"| 3 | ||
Line 59: | Line 57: | ||
*Test GPS parsing | *Test GPS parsing | ||
| | | | ||
+ | *Begin interfacing GPS and GSM/GPRS modules | ||
|- | |- | ||
! scope="row"| 4 | ! scope="row"| 4 | ||
Line 66: | Line 65: | ||
*Test sending SMS messages | *Test sending SMS messages | ||
| | | | ||
+ | *GPS data parsing complete | ||
|- | |- | ||
! scope="row"| 5 | ! scope="row"| 5 | ||
Line 72: | Line 72: | ||
*Make Android app recognize and parse SMS message | *Make Android app recognize and parse SMS message | ||
| | | | ||
+ | *SJ One board sends SMS messages | ||
+ | *Begin work on Android app | ||
|- | |- | ||
! scope="row"| 6 | ! scope="row"| 6 | ||
Line 78: | Line 80: | ||
*Integrate Google Map into app | *Integrate Google Map into app | ||
| | | | ||
+ | *Continue trying to get app to send and receive SMS | ||
|- | |- | ||
! scope="row"| 7 | ! scope="row"| 7 | ||
Line 85: | Line 88: | ||
*Testing | *Testing | ||
| | | | ||
+ | *Android app sends and receive SMS messages | ||
+ | *Locations are displayed on map | ||
|- | |- | ||
! scope="row"| 8 | ! scope="row"| 8 | ||
Line 92: | Line 97: | ||
*Find recommendations for future improvement | *Find recommendations for future improvement | ||
| | | | ||
+ | *Integrate GPS portion with SMS portion | ||
|- | |- | ||
! scope="row"| 9 | ! scope="row"| 9 | ||
| 5/1 | | 5/1 | ||
| | | | ||
− | * | + | *Final touches |
| | | | ||
+ | *Package locator module | ||
|- | |- | ||
! scope="row"| 10 | ! scope="row"| 10 | ||
| 5/8 | | 5/8 | ||
| | | | ||
+ | *Finish report | ||
+ | | | ||
+ | *Add path between self and target | ||
+ | |- | ||
+ | |- | ||
+ | ! scope="row"| 11 | ||
+ | | 5/15 | ||
+ | | | ||
+ | *Prepare for demo | ||
+ | | | ||
+ | *Finish report | ||
*Demo | *Demo | ||
− | |||
|- | |- | ||
|} | |} | ||
== Parts List & Cost == | == Parts List & Cost == | ||
− | + | {| class="wikitable" style="margin: 1em auto 1em auto;" | |
+ | |- | ||
+ | ! scope="col"| Part Name and Link | ||
+ | ! scope="col"| Price | ||
+ | |- | ||
+ | |align="center" |[http://www.elecfreaks.com/store/gprsgsm-moduleefcom-pro-p-450.html SIM900 GPRS/GSM module] | ||
+ | |align="center" |$48 | ||
+ | |- | ||
+ | |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] | ||
+ | |align="center" |$23 | ||
+ | |- | ||
+ | |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] | ||
+ | |align="center" |$23 | ||
+ | |- | ||
+ | |align="center" |[http://prepaid-phones.t-mobile.com/sim-card Mini SIM card] | ||
+ | |align="center" |$20 ($10 card + $10 T-Mobile prepaid service) | ||
+ | |- | ||
+ | |align="center" |SJ One Board | ||
+ | |align="center" |$80 | ||
+ | |- | ||
+ | |- | ||
+ | !scope="row" |Total | ||
+ | !scope="row" |$194 | ||
+ | |- | ||
+ | |} | ||
== Design & Implementation == | == Design & Implementation == | ||
− | The | + | === 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. | ||
+ | |||
+ | <center> | ||
+ | [[File:CmpE244_S14_T5_System_Block_Diagram.png|center|thumb|650px|Figure 1. System Block Diagram]] | ||
+ | </center> | ||
+ | |||
− | + | <center> | |
− | + | [[File:CmpE244_S14_T5_Locator_Beacon.png|center|thumb|600px|Figure 2. Locator Beacon]] | |
+ | </center> | ||
=== Hardware Interface === | === Hardware Interface === | ||
− | In | + | The GPS module communicates using UART. The following table shows the hardware interface between the GPS module and SJ One board: |
+ | {| class="wikitable" style="margin: 1em auto 1em auto;" | ||
+ | |- | ||
+ | ! SJ One Board | ||
+ | ! GPS Module | ||
+ | |- | ||
+ | |align="center" | | ||
+ | VCC(3.3V) | ||
+ | |align="center" | | ||
+ | VCC (P1) | ||
+ | |- | ||
+ | |align="center" | | ||
+ | Ground (GND) | ||
+ | |align="center" | | ||
+ | Ground (P4) | ||
+ | |- | ||
+ | |align="center" | | ||
+ | UART2 RX (P2.9) | ||
+ | |align="center" | | ||
+ | UART TX (P3) | ||
+ | |} | ||
+ | |||
+ | The SIM900 GPRS/GMS module also communicates using UART. The following table shows the pin connections: | ||
+ | {| class="wikitable" style="margin: 1em auto 1em auto;" | ||
+ | |- | ||
+ | ! SJ One Board | ||
+ | ! SIM900 GPRS/GSM Module | ||
+ | ! External 5V Power Bank | ||
+ | |- | ||
+ | | | ||
+ | |||
+ | |align="center" | | ||
+ | VCC (P2) | ||
+ | |align="center" | | ||
+ | 5V | ||
+ | |- | ||
+ | |align="center" | | ||
+ | Ground (GND) | ||
+ | |align="center" | | ||
+ | Ground (P1) | ||
+ | |align="center" | | ||
+ | Ground | ||
+ | |- | ||
+ | |align="center" | | ||
+ | UART3 RX (P4.29) | ||
+ | |align="center" | | ||
+ | UART TX (P3) | ||
+ | | | ||
+ | |- | ||
+ | |align="center" | | ||
+ | UART3 TX (P4.28) | ||
+ | |align="center" | | ||
+ | UART RX (P4) | ||
+ | | | ||
+ | |- | ||
+ | |align="center" | | ||
+ | GPIO Output (P2.0) | ||
+ | |align="center" | | ||
+ | Power (P5) | ||
+ | | | ||
+ | |- | ||
+ | |align="center" | | ||
+ | GPIO Output (P2.1) | ||
+ | |align="center" | | ||
+ | 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. | ||
+ | <center> | ||
+ | [[File:CmpE244_S14_T5_Locator_Beacon_Schematic.png|center|thumb|500px|Figure 3. Locator Beacon Schematic]] | ||
+ | </center> | ||
+ | |||
+ | === 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. | ||
+ | #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. | ||
+ | ##init() - This task get the UART instance and initialize the UART bus at 9600 bps for GPS module to transmit the NMEA Data | ||
+ | ##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 | ||
+ | ##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. | ||
+ | ##init() - set baud rate, create binary semaphore and a queue to store message | ||
+ | ##taskEntry() - Check if GPRS module is on, turn off the echo, set receive and send message format | ||
+ | ##run() - This schedules SMS send and receive activities | ||
+ | ##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 | ||
+ | ##sendSms(const char * number, char * message) - This gets the phone number and message and build a AT command and send it to GPRS module | ||
+ | ##recvSms() - This checks the received buffer in GPRS if there is any message is arrived. If there is, go to readSMS() | ||
+ | ##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 | ||
+ | ##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. | ||
+ | <center> | ||
+ | [[File:CmpE244_S14_T5_GPRS_Task_Flowchart.png|center|thumb|650px|Figure 5. GPRS Task Flowchart]] | ||
+ | </center> | ||
− | |||
− | |||
− | === | + | Figure 6 shows the local variable that are used. |
− | This | + | <center> |
+ | [[File:CmpE244_S14_T5_GPRS_Task_Local_Variables.png|center|thumb|225px|Figure 6. GPRS Task Local Variables]] | ||
+ | </center> | ||
+ | |||
+ | 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: | ||
+ | #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 | ||
+ | #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 | ||
+ | #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 [https://github.com/akexorcist/Android-GoogleDirectionAndPlaceLibrary 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 [https://developers.google.com/maps/documentation/android/start#get_an_android_certificate_and_the_google_maps_api_key: here]. | ||
+ | |||
+ | Figure 7 shows the software architecture diagram of the Location Tracker android app. | ||
+ | <center> | ||
+ | [[File:CmpE244_S14_T5_Location_Tracker_App_Architecture.png|center|thumb|800px|Figure 7. Software Architecture Diagram for the Location Tracker App]] | ||
+ | </center> | ||
== Testing & Technical Challenges == | == 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. | |
+ | |||
+ | <center> | ||
+ | [[File:CmpE244_S14_T5_App_Home.png|center|thumb|400px|Figure 8. App Home Screen]] | ||
+ | </center> | ||
+ | |||
+ | |||
+ | <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. | ||
− | === | + | ==== 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 == | == 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 === | === Project Video === | ||
− | + | TODO | |
=== Project Source Code === | === Project Source Code === | ||
− | + | * [https://sourceforge.net/projects/sjsu/files/CmpE244_SJSU_S2014/ Sourceforge source code link] | |
== References == | == References == | ||
=== Acknowledgement === | === Acknowledgement === | ||
− | + | 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 === | ||
− | + | 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] | ||
− | + | Google Direction and Place Library [https://github.com/akexorcist/Android-GoogleDirectionAndPlaceLibrary] | |
− |
Latest revision as of 23:42, 6 August 2014
Contents
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 |
|
|
2 | 3/13 |
|
|
3 | 3/20 |
|
|
4 | 3/27 |
|
|
5 | 4/3 |
|
|
6 | 4/10 |
|
|
7 | 4/17 |
|
|
8 | 4/24 |
|
|
9 | 5/1 |
|
|
10 | 5/8 |
|
|
11 | 5/15 |
|
|
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.
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.
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.
- 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.
- init() - This task get the UART instance and initialize the UART bus at 9600 bps for GPS module to transmit the NMEA Data
- 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
- 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.
- 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
- taskEntry() - Check if GPRS module is on, turn off the echo, set receive and send message format
- run() - This schedules SMS send and receive activities
- 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
- sendSms(const char * number, char * message) - This gets the phone number and message and build a AT command and send it to GPRS module
- recvSms() - This checks the received buffer in GPRS if there is any message is arrived. If there is, go to readSMS()
- 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
- 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 6 shows the local variable that are used.
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:
- 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
- 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
- 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.
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.
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]