NEO-6M GPS Module
The NEO-6M/7M GPS module features high sensitivity, low power consumption, compact size, and high tracking sensitivity, significantly expanding its coverage for positioning. It is capable of high-precision location tracking even in environments where regular GPS modules struggle, such as narrow urban skies or dense jungle areas. The module's high sensitivity, low static drift, low power consumption, and lightweight design make it ideal for applications in automotive, handheld devices like PDAs, vehicle monitoring, smartphones, cameras, and other mobile positioning systems, making it an excellent choice for GPS product applications.
Module Source
Purchase Link:
https://detail.tmall.com/item.htm?_u=52t4uge5db42&id=631125558647&spm=a1z09.2.0.0.47582e8dqqFD4i
Baidu Netdisk Download Link:
https://pan.baidu.com/s/1QvwMg9JbkzFauYmwExWcnQ
Password: 8888
Specifications
Operating Voltage:3.3V-5V
Operating Current:10-26mA
Control Method: Serial Interface
Hardware Connection
NEO-6M Module Development Board
VCC 5V
GND GND
TX D3 (or any other available digital pin, if using SoftwareSerial)
RX D4 (or any other available digital pin, but can remain disconnected unless you need to send commands to the GPS module)
2
3
4
5
Usage Method
Install Library
- You need to install the
TinyGPS
library or any other compatible GPS parsing library to decode GPS data. You can search for and install theTinyGPS
library using the Library Manager in the Arduino IDE.
Enter the code:
Since GPS signals are only available outdoors, the following code includes a 2.8-inch LCD screen for display purposes. For wiring details, refer to the ColorEasyDuino Module Migration Manual.
/******************************************************************************
* Test Hardware: LCSC ColorEasyDuino Development Board
* Version Number: V1.0
* Modified By: www.lckfb.com
* Modification Date: April 11, 2024
* Function Overview:
*****************************************************************************
* Open-source development board hardware and software information and related projects hardware and software information on official website
* Development board official website: www.lckfb.com
* Technical support resident forum, any technical problems are welcome at any time to exchange learning
* LCSC Forum: club.szlcsc.com
* Follow our Bilibili account: [立创开发板], stay toned to our latest news!
* We focus on cultivating Chinese engineers rather than profiting from board sales.
******************************************************************************/
#include <TinyGPS.h>
#include <SoftwareSerial.h>
#include <Adafruit_GFX.h>
#include <Adafruit_ILI9341.h>
#include <XPT2046_Touchscreen.h>
// 为显示屏和触摸屏定义引脚
#define TFT_CS 10
#define TFT_RST 9
#define TFT_DC 8
#define TOUCH_CS 4
// 初始化ILI9341
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC,TFT_RST);
// 定义SoftwareSerial的接收(RX)和发送(TX)引脚
static const int RXPin = 4, TXPin = 3;
// 定义GPS模块的波特率
static const uint32_t GPSBaud = 9600;
// 创建SoftwareSerial对象
SoftwareSerial gpsSerial(RXPin, TXPin);
// 创建TinyGPS++对象
TinyGPS gps;
// 假设这是你希望存储的数据量
const int dataArraySize = 180;
char dataFromSerial[]; // 数据数组
int dataIndex = 0; // 索引,用来跟踪数据在数组中的位置
void setup() {
Serial.begin(9600); // 开始串口通信,与电脑通信
gpsSerial.begin(GPSBaud); // 开始软件串口通信,与GPS模块通信
// 初始化显示屏
tft.begin();
tft.setRotation(1);
// 清屏为白色
tft.fillScreen(ILI9341_BLUE);
}
void loop() {
bool newData = false;
// For one second we parse GPS data and report some key values
for (unsigned long start = millis(); millis() - start < 2000;)
{
while (gpsSerial.available()> 0 && dataIndex < dataArraySize)
{
char c = gpsSerial.read();
dataFromSerial[] = c;
if(dataIndex >= dataArraySize) {
// 数据存满,可以显示
tft.fillRect(0, 0, 320, 80,ILI9341_BLUE);
tft.setCursor(0, 0); // 设置LCD的起始点
// 遍历数组并显示数据
for(int i = 0; i < dataArraySize; i++) {
tft.print(dataFromSerial[]);
}
//清除之前的数据
for(int i = 0; i < dataArraySize; i++)dataFromSerial[]=0;
// 重置索引,准备下一轮数据收集
// 这取决于你是否希望覆盖之前的数据或者只显示一次
dataIndex = 0;
}
if (gps.encode(c)) // 如果内容有变
newData = true;
}
}
// if (newData)
// {
float flat, flon;
unsigned long age;
gps.f_get_position(&flat, &flon, &age);
tft.fillRect(5, 240-60, 150, 60,ILI9341_BLUE);
tft.setCursor(5, 240-60);
tft.print("LAT=");
tft.println(flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6);
tft.print(" LON=");
tft.println(flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6);
tft.print(" SAT=");
tft.println(gps.satellites() == TinyGPS::GPS_INVALID_SATELLITES ? 0 : gps.satellites());
tft.print(" PREC=");
tft.println(gps.hdop() == TinyGPS::GPS_INVALID_HDOP ? 0 : gps.hdop());
//}
}
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
Usage Testing
The upper part shows the raw GPS data sent by the GPS module, while the lower part displays the successfully parsed GPS location data.