极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 11356|回复: 7

求问GPS问题。。。求大神讲解。。。

[复制链接]
发表于 2015-4-8 08:54:56 | 显示全部楼层 |阅读模式
我购买了这个GPS模块
http://item.taobao.com/item.htm?spm=a1z0k.7385961.1997985097.d4918997.XjdXA1&id=13198221647&_u=8p7dcnj6ecc
没用示例中的GSM模块,想直接把GPS数据从串口监视器上显示出来,根据他示例的代码改了一下。。但是没反应。。求教。。
Q526970969



#include <SoftwareSerial.h>
//#include "inetGSM.h"

#include <string.h>

#include <TinyGPS.h>

/* This sample code demonstrates the normal use of a TinyGPS object.
   It requires the use of SoftwareSerial, and assumes that you have a
   4800-baud serial GPS device hooked up on pins 3(rx) and 4(tx).
*/

TinyGPS gps;

#define ledpin 13
#define pwrkey 27



int error;
boolean started=false;
bool newData = false;

char gps_year[8];
char gps_mon[3];
char gps_day[3];
char gps_hour[3];
char gps_min[3];
char gps_sec[3];


char gps_lon[20];
char gps_lat[20];

char gps_sms[100];


void setup()
{

//software power sim900 up

  Serial.begin(115200);
  Serial2.begin(9600);

  delay(10000);
  
}

void loop()
{

check_gps();

}




char check_gps()
{
  newData=false;
  unsigned long chars;
  unsigned short sentences, failed;

  // For one second we parse GPS data and report some key values
  for (unsigned long start = millis(); millis() - start < 1000;)
  {
    while (Serial2.available())
    {
      char c = Serial2.read();
      Serial.write(c); // uncomment this line if you want to see the GPS data flowing
      if (gps.encode(c)) // Did a new valid sentence come in?
        newData = true;
        Serial.println("GPS READY!");
    }
  }

  if (newData)
  {
    float flat, flon;
    unsigned long age;
    int _year;
    byte _month, _day,_hour,_minute,_second,_hundredths;
    gps.f_get_position(&flat, &flon, &age);
    gps.crack_datetime(&_year,&_month,&_day,&_hour,&_minute,&_second,&_hundredths,&age);
    flat == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flat, 6;
    flon == TinyGPS::GPS_INVALID_F_ANGLE ? 0.0 : flon, 6;
    dtostrf(flat, 11, 6, gps_lat);
    dtostrf(flon, 10, 6, gps_lon);
    Serial.println("lat:"); //latitude
    Serial.println(gps_lat);
    Serial.println("lon:");
    Serial.println(gps_lon);//longitude
   }
}
回复

使用道具 举报

发表于 2015-4-8 09:57:04 | 显示全部楼层
这个模块没研究过。但是好像 gps天线的4个线 就是 vcc gnd rx tx 直接就输出文字来的,读出来就ok了。
回复 支持 反对

使用道具 举报

发表于 2015-4-8 10:36:36 | 显示全部楼层
   模块的名字是什么?
回复 支持 反对

使用道具 举报

发表于 2015-4-8 10:36:56 | 显示全部楼层
         看一下接线图?
回复 支持 反对

使用道具 举报

发表于 2015-4-8 10:37:51 | 显示全部楼层
我也做过,遇到过同样问题,用这个ATK-NEO-6M GPS模块
回复 支持 反对

使用道具 举报

 楼主| 发表于 2015-4-13 09:14:58 | 显示全部楼层
shihaipeng04 发表于 2015-4-8 09:57
这个模块没研究过。但是好像 gps天线的4个线 就是 vcc gnd rx tx 直接就输出文字来的,读出来就ok了。

我就是这么写的代码。。为神马串口监视器什么都没有?。。
回复 支持 反对

使用道具 举报

发表于 2015-4-13 10:45:00 | 显示全部楼层
不用SoftwareSerial库,直接连到arduino的RX/TX试试看,有没有输出。

遇到多次这样的问题,要么是自己线接错了,RX/TX反了,要么就是模块供电有问题。多试试看呢,
回复 支持 反对

使用道具 举报

发表于 2015-4-13 12:21:10 | 显示全部楼层
可能主要是跳线问题,你仔细核对下跳线,多尝试
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-18 22:36 , Processed in 0.037790 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表