Advertisement
microrobotics

DF Robot GPS Receiver & Antenna

Jul 24th, 2023
1,113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The TEL0157 GPS Receiver from DF Robot uses the UART interface to communicate with a microcontroller. It sends data in the form of NMEA 0183 sentences which include information such as latitude, longitude, altitude, speed, and more.
  3.  
  4. This code reads the data from the GPS module and prints the raw NMEA sentences to the Serial Monitor.
  5.  
  6. If you want to parse the NMEA sentences to get useful data (like latitude and longitude), you might want to use a library like TinyGPS++.
  7.  
  8. Remember to connect the GPS module's TX pin to the Arduino's RX pin (in this case pin 2), and the GPS module's RX pin to the Arduino's TX pin (in this case pin 3). Also, make sure to provide the appropriate power supply to the GPS module (usually 3.3V or 5V, check your module's datasheet). Always double-check the datasheet/manual of your GPS module for specific instructions and information.
  9.  
  10. Please adjust the pin numbers and rest of the code according to your exact setup and requirements.
  11.  
  12. Here is a simple Arduino code snippet that reads and prints the raw NMEA sentences from the GPS module:
  13. */
  14.  
  15. #include <SoftwareSerial.h>
  16.  
  17. // Choose two Arduino pins to use for software serial
  18. int rxPin = 2;
  19. int txPin = 3;
  20.  
  21. // Set up the GPS module baud rate (default is 9600 for the TEL0157)
  22. int gpsBaud = 9600;
  23.  
  24. // Create a software serial port
  25. SoftwareSerial gpsSerial(rxPin, txPin);
  26.  
  27. void setup() {
  28.   // Start the hardware serial port for the serial monitor
  29.   Serial.begin(9600);
  30.  
  31.   // Start the software serial port
  32.   gpsSerial.begin(gpsBaud);
  33. }
  34.  
  35. void loop() {
  36.   // Read data from the GPS module
  37.   while (gpsSerial.available() > 0) {
  38.     char c = gpsSerial.read();
  39.    
  40.     // Print data to the serial monitor
  41.     Serial.print(c);
  42.   }
  43. }
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement