top of page
Writer's pictureSanskruti Ashtikar

GPS Tracker Using 8051 Microcontroller

Updated: 4 days ago

Introduction


A GPS tracker is a device that uses the Global Positioning System to determine and track its precise location. In this project, we will design a GPS tracker using the 8051 microcontroller. The system will interface with a GPS module to receive location data and display it on an LCD. This project demonstrates how to integrate GPS technology with microcontrollers for applications in navigation, tracking, and location-based services.





Components Required


  • 8051 Microcontroller (e.g., AT89S52)

  • GPS Module (e.g., NEO-6M)

  • 16x2 LCD Display

  • MAX232 IC (for serial communication)

  • Resistors (10kΩ, 1kΩ)

  • Capacitors (33pF, 100μF)

  • Crystal Oscillator (11.0592 MHz)

  • Breadboard and Connecting Wires

  • Power Supply (5V)


Circuit Diagram


The GPS module is connected to the 8051 microcontroller through the MAX232 IC, which converts the RS232 voltage levels to TTL levels suitable for the microcontroller. The LCD is used to display the GPS coordinates.


+5V ----- +5V
          |
          |
         NEO-6M
         +---+
   +5V --|VCC| 
         |    |
         |TX  |------- R1IN (MAX232)
         |    |
   GND --|GND | 
         +---+
MAX232
+---+   
|   |--- T1OUT ------- RXD (P3.0 of 8051)
|   |
+---+
8051
+---+
|   |--- TXD (P3.1)
|   |
+---+
LCD
RS (P3.6)
RW (Ground)
E  (P3.7)
D4-D7 (P2.4-P2.7)

Pin Connections


  • GPS Module:

  • VCC to +5V

  • GND to Ground

  • TX to R1IN of MAX232

  • MAX232 IC:

  • T1OUT to RXD (P3.0 of 8051)

  • Connect other pins as per standard MAX232 configuration with capacitors

  • 8051 Microcontroller:

  • RXD (P3.0) to T1OUT of MAX232

  • TXD (P3.1) to T1IN of MAX232 (optional for bidirectional communication)

  • Connect crystal oscillator and capacitors for clock generation

  • LCD Display:

  • RS to P3.6

  • RW to Ground

  • E to P3.7

  • D4-D7 to P2.4-P2.7





Software Implementation


The code is written in C using Keil uVision IDE. It involves initializing the UART for serial communication, receiving GPS data, and extracting and displaying the coordinates.


#include <reg51.h>
#include "lcd.h"
sbit RS = P3^6; // RS pin for LCD
sbit E = P3^7; // E pin for LCD
void delay(unsigned int count) {
    int i, j;
    for(i=0; i<count; i++)
        for(j=0; j<1275; j++);
}
void uart_init(void) {
    TMOD = 0x20; // Timer1 in mode 2
    TH1 = 0xFD; // Baud rate 9600
    SCON = 0x50; // 8-bit data, 1 stop bit, REN enabled
    TR1 = 1; // Start Timer1
}
char uart_receive(void) {
    while(RI == 0); // Wait for reception to complete
    RI = 0; // Clear reception interrupt flag
    return SBUF; // Return received character
}
void uart_send(char data) {
    SBUF = data; // Load data to transmit buffer
    while(TI == 0); // Wait for transmission to complete
    TI = 0; // Clear transmission interrupt flag
}
void lcd_init() {
    lcd_cmd(0x02); // Initialize LCD in 4-bit mode
    lcd_cmd(0x28); // 4-bit mode, 2 lines, 5x7 font
    lcd_cmd(0x0C); // Display ON, Cursor OFF
    lcd_cmd(0x06); // Increment cursor
    lcd_cmd(0x01); // Clear display
}


void lcd_cmd(char cmd) {
    RS = 0; // Select command register
    P2 = (P2 & 0x0F) | (cmd & 0xF0); // Send higher nibble
    E = 1; E = 0;
    P2 = (P2 & 0x0F) | (cmd << 4); // Send lower nibble
    E = 1; E = 0;
    delay(2);
}
void lcd_data(char data) {
    RS = 1; // Select data register
    P2 = (P2 & 0x0F) | (data & 0xF0); // Send higher nibble
    E = 1; E = 0;
    P2 = (P2 & 0x0F) | (data << 4); // Send lower nibble
    E = 1; E = 0;
    delay(2);
}
void lcd_write_string(char *str) {
    while(*str) {
        lcd_data(*str++);
    }
}
void lcd_write_char(char c) {
    lcd_data(c);
}
void lcd_write_number(int num) {
    char buf[16];
    sprintf(buf, "%d", num);
    lcd_write_string(buf);
}
void main() {
    char gps_data;
    char buffer[16];
    int i = 0;
    lcd_init(); // Initialize LCD
    uart_init(); // Initialize UART
    lcd_cmd(0x80); // Move cursor to first line
    lcd_write_string("GPS Tracker");
    
    while(1) {
        gps_data = uart_receive(); // Receive GPS data
        
        if(gps_data == '$') { // Start of GPS data sentence
            i = 0;
            while(i < 16) { // Read GPS sentence
                gps_data = uart_receive();
                buffer[i++] = gps_data;
            }
            buffer[i] = '\0'; // Null-terminate string
            
            // Display GPS data on LCD
            lcd_cmd(0xC0); // Move cursor to second line
            lcd_write_string(buffer);
        }
    }
}





  1. Initialization:

  2. LCD Initialization: The lcd_init() function sets up the LCD.

  3. UART Initialization: The uart_init() function configures the UART for serial communication at a baud rate of 9600.

  4. Receiving GPS Data:

  5. The uart_receive() function waits for and reads a character from the GPS module via UART.

  6. Displaying GPS Data:

  7. The main loop continuously receives GPS data. When a sentence starts (indicated by $), it reads the next 16 characters into a buffer and displays them on the LCD.


Conclusion


This project demonstrates the use of the 8051 microcontroller to create a GPS tracker. The system is capable of receiving location data from a GPS module and displaying it on an LCD. This project is a great way to learn about serial communication, GPS technology, and using microcontrollers for navigation and tracking applications.


Want us to guide you through your project or make the project for you ?







Create Various Projects

Check out our Free Arduino Projects Playlist - Arduino Projects 

Check out our Free Raspberry Pi Projects Playlist - Raspberry Pi Projects 

Check out our Free TinkerCAD Projects Playlist - TinkerCAD Projects 

Check out our Free IoT Projects Playlist - IoT Projects 

Check out our Free Home Automation Projects Playlist - Home Automation Projects 

Check out our Free NodeMCu Projects Playlist - NodeMCu Projects 



5 views0 comments

Related Posts

See All

Comments


bottom of page