我是靠谱客的博主 如意路人,最近开发中收集的这篇文章主要介绍Arduino——野火GPS模块GPS模块前言一、Arduino代码,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

GPS模块

文章目录

  • GPS模块
  • 前言
  • 一、Arduino代码


前言

手上还有一个GPS,用arduino做模块很方便,打算和短信模块结合,短信模块上次已经使用完成了,这次学习一下GPS模块
在这里插入图片描述
看模块很容易知道,这个模块用的是串口通信,只需要注意设置相应的波特率即可,GPS模块的波特率是115200。使用的时候一定要注意,在室内是无法获取经纬度的,一定要去室外测试。下面看一下这个模块如何使用。

一、Arduino代码

你随便写一个串口然后打印内容,就能看到GPS输出的一大片内容,但是我们使用的时候往往只需要经纬度,在arduino中提供了一个TinyGPS++解析库,可以解析出经纬度。库不会安装的可以看之前的博客,这里直接给出代码。

/*
richowe
*/
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
TinyGPSPlus gps;
SoftwareSerial ss(6, 7);
float latitude;
float longitude;
int incomedate=0;
void setup()
{
Serial.begin(9600); //set the baud rate of serial port to 9600;
ss.begin(115200); //set the GPS baud rate to 9600;
}
void loop()
{
while (ss.available() > 0)
{
gps.encode(ss.read()); //The encode() method encodes the string in the encoding format specified by encoding.
if (gps.location.isUpdated())
{
latitude = gps.location.lat(); //gps.location.lat() can export latitude
longitude = gps.location.lng();//gps.location.lng() can export latitude
Serial.print("Latitude=");
Serial.print(latitude, 6);
//Stable after the fifth position
Serial.print(" Longitude=");
Serial.println(longitude, 6);
delay(500);
}
}
}

可以通过串口打印相关的信息。
在这里插入图片描述

最后

以上就是如意路人为你收集整理的Arduino——野火GPS模块GPS模块前言一、Arduino代码的全部内容,希望文章能够帮你解决Arduino——野火GPS模块GPS模块前言一、Arduino代码所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(72)

评论列表共有 0 条评论

立即
投稿
返回
顶部