## Lab: Serial Communication between UNO R3 and GPS Module
This experiment demonstrates UART serial communication between an Lonely Binary UNO R3 and the GY-NEO6MV2 module to read raw NMEA data.
**Background:** UART (Universal Asynchronous Receiver/Transmitter) is a serial protocol for asynchronous data transmission. Data is sent bit-by-bit over TX/RX lines at a defined baud rate (symbols per second). Mismatched baud rates result in garbled data.
> Common GPS baud rates: 4800 or 9600 bps.
**Required Hardware:**
- GY-NEO6MV2 GPS Module
- Lonely Binary UNO R3
**Wiring:**
| GY-NEO6MV2 | Lonely Binary UNO R3 |
|------------|----------------|
| VCC | 5V |
| GND | GND |
| TX | 2 (Software RX)|
| RX | 3 (Software TX)|
**Note:** UNO R3 UNO has one hardware UART (pins 0/1), used for USB communication. Use SoftwareSerial library for additional ports.
**Code:**
```cpp
#include
#include // Include Software Serial library
#define RX 2 // Connect to GPS TX pin
#define TX 3 // Connect to GPS RX pin
#define GPS_BAUD 9600 // Baud rate
// Create a Software Serial object 'ss'
SoftwareSerial ss(RX, TX);
void setup() {
// Set the baud rate for communication with the UNO R3 IDE
Serial.begin(9600);
// Set the baud rate for communication with GPS via SoftwareSerial
ss.begin(GPS_BAUD);
}
void loop() {
// If there is data in the Software Serial receive buffer
while (ss.available() > 0) {
// Read a byte of data from the buffer
char gpsData = ss.read();
// Send the read data to the UNO R3 IDE serial monitor
Serial.write(gpsData);
}
}
```
**Code Explanation:**
- `#include `: Enables software-emulated UART on digital pins.
- `SoftwareSerial ss(RX, TX)`: Defines RX/TX pins (UNO R3's perspective: RX connects to GPS TX).
- `ss.begin(GPS_BAUD)`: Initializes at 9600 bps.
- `while (ss.available() > 0)`: Checks buffer for data.
- `ss.read()`: Reads one byte; `Serial.write()`: Outputs to monitor.
**Limitations of SoftwareSerial:**
- Cannot transmit/receive simultaneously.
- Only one port active for reception at a time.
- Max baud rate: ~115200 bps (sufficient for GPS).
**Results:**
- Open UNO R3 IDE Serial Monitor at 9600 bps.
- Initial output may be garbled or empty during cold start.

- Once locked, NMEA sentences appear (e.g., $GPGGA for position).

> **Tips:** If garbled, try 4800 bps. Place module outdoors for signal acquisition.
- Choosing a selection results in a full page refresh.