用户工具

站点工具


ocrobot:sensor_suite:gps:main

差别

这里会显示出您选择的修订版和当前版本之间的差别。

到此差别页面的链接

两侧同时换到之前的修订记录前一修订版
ocrobot:sensor_suite:gps:main [2019/12/23 03:56] – [主要硬件] 董凯萍ocrobot:sensor_suite:gps:main [2023/06/07 04:23] (当前版本) – 外部编辑 127.0.0.1
行 1: 行 1:
 +====== GPS实时定位仪 ======
 +OCROBOT GPS实时定位仪采用OCROBOT ALPHA系列模块堆叠而成。
 +本模型可以在户外露天的状态下,实时显示当前所属位置的日期、经度、纬度、定位状态与有效卫星、水平定位精度与椭球高度(单位:米)、航向(单位:度)与速度(单位:千米/小时)、海平面高度(单位米)。
  
 +
 +=====图片展示=====
 +{{:ocrobot:sensor_suite:gps:gps435.png?400|}}
 +=====主要硬件=====
 +  - OCROBOT ALPHA 8F32P-U主控板
 +  - OCROBOT ALPHA GPS定位/授时 模块
 +  - OCROBOT ALPHA LCD1602显示屏
 +  - OCROBOT ALPHA 双路锂电池扩展板
 +===== 示例程序 =====
 +需要OCROBOT_APLHA_GPS_Module 库
 +
 +github:https://github.com/534659123/OCROBOT_APLHA_GPS_Module
 +
 +{{ :ocrobot:alpha:gps:ocrobot_aplha_gps_module.zip |下载GPS库}}
 +
 +
 +<code cpp>
 +#include <Wire.h>
 +#include <LiquidCrystal_I2C.h>
 +#include <OCROBOT_I2C_GPS.h>                                                                                                                                                                                    
 +GPS GPS(0x02);
 +LiquidCrystal_I2C lcd(0x20,16,2);
 +
 +byte hh,mm,ss,ms;
 +byte y,m,d;
 +uint16_t delayTime = 3000;
 +void setup() {
 +  Wire.begin();
 +  lcd.init();  
 +  lcd.backlight();
 +}
 +void loop() {
 +  /*显示时间*/
 +  GPS.UtcDate(y,m,d);
 +  GPS.UtcTime(hh,mm,ss,ms);
 +  lcd.setCursor(0, 0);
 +  lcd.print("DATE:");
 +  lcd.print("20");
 +  lcd.print(y);
 +  lcd.print("/");
 +  lcd.print(m);
 +  lcd.print("/");
 +  lcd.print(d);
 +  lcd.setCursor(0, 1);
 +  lcd.print("Time:");
 +  lcd.print(hh);
 +  lcd.print(":");
 +  lcd.print(mm);
 +  lcd.print(":");
 +  lcd.print(ss);
 +  lcd.print(":");
 +  lcd.print(ms);
 +  delay(delayTime);
 +  lcd.clear();
 +  /*显示纬度经度*/  
 +  lcd.setCursor(0, 0);
 +  lcd.print(GPS.LatitudeDirection());  //纬度 WGS84坐标系
 +  lcd.print(":");
 +  lcd.print(GPS.Latitude(),4);
 +
 +  lcd.setCursor(0, 1);
 +  lcd.print(GPS.LongitudeDirection()); //经度 WGS84坐标系
 +  lcd.print(":");
 +  lcd.print(GPS.Longitude(),4);
 +  delay(delayTime);
 +  lcd.clear();
 +  /*定位状态与有效卫星*/
 +  lcd.setCursor(0, 0);
 +  lcd.print("Pos:");
 +  lcd.print(GPS.Positioning()); //定位状态 0:无定位  1:SPS 模式定位  2:差分、SPS模式定位 3 :PPS 模式定位
 +  lcd.setCursor(0, 1);
 +  lcd.print("Sat:");
 +  lcd.print(GPS.Satellite()); //有效卫星数量
 +  delay(delayTime);
 +  lcd.clear();
 +  /*水平定位精度与椭球高度*/
 +  lcd.setCursor(0, 0);
 +  lcd.print("HDOP:");
 +  lcd.print(GPS.HDOP()); //水平精度 单位米
 +  lcd.setCursor(0, 1);
 +  lcd.print("MSL:");
 +  lcd.print(GPS.MSL()); //椭球高,单位米
 +  delay(delayTime);
 +  lcd.clear();
 +  /*航向与速度*/
 +  lcd.setCursor(0, 0);
 +  lcd.print("Course:");
 +  lcd.print(GPS.Course()); // 航向 单位度
 +  lcd.setCursor(0, 1);
 +  lcd.print("Speed:");
 +  lcd.print(GPS.Speed()); //速度,单位千米/小时
 +  lcd.print("km/h");
 +  delay(delayTime);                    
 +  lcd.clear();
 +  /*海平面高*/
 +  lcd.setCursor(0, 0);
 +  lcd.print("SeaLevel:");
 +  lcd.print(GPS.SeaLevel()); // 海平面高,单位米
 +  delay(delayTime);
 +  lcd.clear();
 +}
 +</code>
 +
 +
 +
 +=====修改设备地址=====
 +本设备默认地址为**2** 十六进制:**0x02**,如需自定义I2C地址,首先准备如下程序 【在默认地址模式下,使用下面的程序更新自定义地址】
 +
 +<code cpp>
 +#include <Wire.h>
 +/***********/
 +byte I2CAddr = 10;   //需要修改的地址,请自行修改 (取值范围1-127)
 +/***********/
 +void setup() {
 +  Wire.begin();        // 初始化I2C接口
 +  Serial.begin(9600);
 +
 +  Wire.beginTransmission(2); //设备默认地址 本设备GPS模块 = 2
 +  Wire.write(200);              // 修改地址的操作码
 +  Wire.write(I2CAddr);     //向I2C设备写入新地址
 +  Wire.endTransmission();    // stop transmitting
 +  
 +Serial.println("OK");    //串口显示OK则完成写入,拨动模块开关并重新上电即可
 +}
 +
 +void loop() {
 +}
 +</code>
 +
 +自行修改程序中需要写入的地址,程序显示OK后,拨动开关,断电后即可。
 +==== 拨动开关示意图 ====
 +{{:ocrobot:alpha:gps:拨动开关435默认地址.png?nolink|}}
 +{{:ocrobot:alpha:gps:拨动开关435更改地址.png?nolink|}}
ocrobot/sensor_suite/gps/main.txt · 最后更改: 2023/06/07 04:23 由 127.0.0.1