Advertisement
microrobotics

MKS ATGM332D 5N31 GPS with Antenna

Jul 24th, 2023
2,325
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. The ATGM332D GPS module, like many GPS modules, uses UART (serial communication) to transmit data. It sends NMEA 0183 sentences which include information about location, speed, time, and more.
  3.  
  4. This script will read the data from the GPS module and print 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). 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. Below is a simple Arduino code to read and print the 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 ATGM332D)
  22. int gpsBaud = 9600;
  23.  
  24. // Create a software serial port
  25. SoftwareSerial gpsSerial(rxPin, txPin);
  26.  
  27. void setup()
  28. {
  29.   // Start the hardware serial port for the serial monitor
  30.   Serial.begin(9600);
  31.  
  32.   // Start the software serial port
  33.   gpsSerial.begin(gpsBaud);
  34. }
  35.  
  36. void loop()
  37. {
  38.   // Read the data from the GPS module
  39.   while (gpsSerial.available() > 0) {
  40.     char c = gpsSerial.read();
  41.    
  42.     // Print the data to the serial monitor
  43.     Serial.print(c);
  44.   }
  45. }
  46.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement