Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Bluetooth GPS
- - Source Code NOT compiled for: ESP32 DevKit V1
- - Source Code created on: 2025-08-08 07:12:51
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* a wanna send my gps location form my mobile to esp */
- /* 32 via Bluetooth using app "nRF connect" */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <BluetoothSerial.h> // Include the BluetoothSerial library for Bluetooth communication
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- /****** GLOBAL OBJECTS *****/
- BluetoothSerial SerialBT; // Create a BluetoothSerial object
- void setup(void)
- {
- // Initialize serial communication for debugging
- Serial.begin(115200);
- Serial.println("ESP32 Bluetooth GPS Receiver");
- // Initialize Bluetooth serial with device name
- if (!SerialBT.begin("ESP32_GPS")) {
- Serial.println("An error occurred initializing Bluetooth");
- } else {
- Serial.println("Bluetooth initialized. Waiting for connections...");
- }
- }
- void loop(void)
- {
- // Check if Bluetooth client is connected
- if (SerialBT.hasClient()) {
- // Check if data is available from Bluetooth
- if (SerialBT.available()) {
- String incomingData = SerialBT.readStringUntil('\n'); // Read incoming data until newline
- Serial.print("Received GPS Data: ");
- Serial.println(incomingData);
- // Here you can add code to process the GPS data
- // For example, parse latitude and longitude if data is formatted accordingly
- }
- }
- delay(20); // Small delay to prevent overwhelming the CPU
- }
Advertisement
Add Comment
Please, Sign In to add comment