[Diao Ye learns programming] Arduino hands-on (193) --- Quectel BC20 NB+GNSS module 8

The reference to 37 sensors and modules has been widely circulated on the Internet. In fact, there must be more than 37 sensor modules compatible with Arduino. In view of the fact that I have accumulated some sensor and actuator modules on hand, in accordance with the concept of true knowledge (must be hands-on), for the purpose of learning and communication, here I am going to try and do more experiments one by one. Whether it is successful or not, it will be recorded ——Small progress or unsolvable problems, I hope to be able to throw bricks and spark jade.

[Arduino] 168 sensor module series experiments (data code + simulation programming + graphics programming)
experiment 193: Gravity: I2C & UART BC20 NB-IoT & GNSS communication module
NB-IoT wide-area low-power wireless communication GPS / Beidou Accurate Positioning Necessary for Outdoor Internet of Things

insert image description here
insert image description here
Knowledge points: Quectel BC20
BC20 is a NB-IoT wireless communication module with high performance, low power consumption, multi-band, and supports GNSS positioning function. Its size is only 18.7 mm × 16.0 mm × 2.1 mm, which can meet the needs of terminal equipment for small-sized module products to the greatest extent, and at the same time effectively help customers reduce product size and optimize product cost.

BC20 is designed to be compatible with Quectel GSM/GPRS/GNSS series MC20 modules, which is convenient for customers to design and upgrade products quickly and flexibly. BC20 provides a wealth of external interfaces and protocol stacks, and supports IoT cloud platforms such as China Mobile OneNET, China Telecom IoT, and Alibaba Cloud IoT, providing great convenience for customers' applications.

Based on advanced GNSS technology, BC20 can support the demodulation algorithm of BeiDou and GPS dual satellite navigation system, making its positioning more accurate and anti-multipath interference stronger, which has more advantages than the traditional single GPS positioning module. In addition, the BC20 module has a built-in LNA and a low-power algorithm: the former ensures higher sensitivity, and the latter ensures lower current consumption in low-power mode.

Compared with the traditional NB-IoT + GNSS solution, the integrated design of BC20 reduces its volume by 40%. With its compact size, ultra-low power consumption and ultra-wide operating temperature range, BC20 has greater advantages in various applications; its main application areas are: bicycle and motorcycle anti-theft, pet tracking, financial property tracking and driving recorder etc.

insert image description here
insert image description here
insert image description here
insert image description here
insert image description here

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
experiment 209: Gravity: I2C & UART BC20 NB-IoT & GNSS communication module
NB-IoT wide-area low-power wireless communication GPS/ Beidou precise positioning is necessary for the outdoor Internet of Things
Project 13: Query the information of the GLL protocol of the global navigation satellite system through the serial port

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二百零九:Gravity: I2C & UART BC20 NB-IoT & GNSS通信模块
  NB-IoT广域低功耗无线通信 GPS/北斗精准定位 户外物联网必备
  项目十三:通过串口查询全球导航卫星系统GLL协议的信息
  实验接线:
  BC20       UNO
  VIN        5V
  GND        GND
  SCL        A5
  SDA        A4
*/

#include "DFRobot_BC20_Gravity.h"

//RGB有7种颜色可供选择
#define  RED 0
#define  BLUE 1
#define  GREEN 2
#define  YELLOW 3
#define  PURPLE 4
#define  CYAN 5
#define  WHITE 6

//IIC通讯
#define USE_IIC

//硬件串口通讯
//#define USE_HSERIAL

//软件串口通讯
//#define USE_SSERIAL

DFRobot_BC20_IIC myBC20(0x33);

void setup() {
    
    
  Serial.begin(115200);
  myBC20.LED_OFF();

  //初始化 BC20
  Serial.print("正在启动BC20,请稍等...... ");
  myBC20.changeColor(RED);
  while (!myBC20.powerOn()) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("BC20 启动成功!");

  //禁用睡眠模式
  myBC20.configSleepMode(eSleepMode_Disable);

  //启动 GNSS
  Serial.print("打开全球导航卫星系统...  ");
  myBC20.setQGNSSC(ON);
  myBC20.changeColor(YELLOW);
  if (myBC20.getQGNSSC() == OFF) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("GNSS 开启");
  myBC20.changeColor(CYAN);
}

void loop() {
    
    
  myBC20.getQGNSSRD(NMEA_GLL);

  /*
    UTC 时间,格式:hhmmss.ss,例如。162436.54 => 16:24:36.54
    h - 小时
    m - 分钟
    s - 秒
  */
  Serial.print("UTC 时间: ");
  Serial.println(sGLL.UTC_Time());

  /*
     纬度,格式:ddmm.mmmmm,例如。3150.7820 => 31 度 50.7820 分钟
     d - 度
     m - 分钟
  */
  Serial.print("纬度: ");
  Serial.print(sGLL.LatitudeVal());

  /*
     北纬或南纬
     N - 北
     S - 北
  */
  Serial.print(" ");
  Serial.println(sGLL.LatitudeDir());

  /*
     经度,格式:dddmm.mmmmm,例如。12135.6794 => 121 度 35.6794 分钟
     d - 度
     m - 分钟
  */
  Serial.print("经度: ");
  Serial.print(sGLL.LongitudeVal());
  Serial.print(" ");

   /*
     经度标识
     E - 东
     W - 西
  */
  Serial.println(sGLL.LongitudeDir());

  /*
     数据状态
     V - 无效
     一个有效的
  */
  Serial.print("数据状态: ");
  Serial.println(sGLL.DataStatus());

 /*
     定位方式
     N - 没有修复
     A - 自主 GPS 定位
     D - 差分 GPS 定位
  */
  Serial.print("定位模式: ");
  Serial.println(sGLL.PositionMode());
  Serial.println();
  Serial.println();
  myBC20.clearGPS();

  myBC20.LED_ON();
  delay(500);
  myBC20.LED_OFF();
#ifndef ARDUINO_ESP32_DEV
  delay(500);
#else
  delay(5000);
#endif
}

Experimental serial port return

insert image description here

The NMEA protocol is to establish a unified BTCM (Maritime Radio Technical Committee) standard in different GPS (Global Positioning System) navigation equipment, a set of communications developed by the National Marine Electronics Association (NMEA-The National Marine Electronics Association-tion) protocol. According to the standard specifications of the NMEA-0183 protocol, the GPS receiver transmits information such as position and speed to PCs, MCUs and other devices through the serial port.

The NMEA-0183 protocol is a standard protocol that GPS receivers should abide by. It is also the most widely used protocol on GPS receivers. Most common GPS receivers, GPS data processing software, and navigation software all comply with or at least be compatible with this protocol.

The communication sentences stipulated in the NMEA communication protocol are already based on ASCII codes. The data format of the NMEA-0183 protocol sentence is as follows: " " is the start symbol of the sentence; "," is the field separator; "∗ " is the checksum And the identifier, the two digits behind it are the checksum, which means that " " is the start mark of the statement; "," is the field separator; "*" is the checksum identifier, and the two digits behind it are checksum, representing the "" is the statement start flag; " , " is the field separator; "" is the checksum identifier, and the two digits behind it are the checksum, representing the bitwise XOR value of all characters between " " and "*" (excluding these two characters).

NMEA0183 standard sentences (commonly used GPS sentences)

GPGLL example: GPGLL example:GPG LL example: GPGLL,4250.5589,S,14718.5084,E,092204.999,A*2D
Field 0: $GPGLL, statement ID, indicating that the statement is Geographic Position (GLL) Geographical Positioning Information
Field 1: latitude ddmm.mmmm, degrees and minutes Format (add 0 if the leading digit is insufficient)
Field 2: Latitude N (northern latitude) or S (southern latitude)
Field 3: longitude dddmm.mmmm, degree format (add 0 if the leading digit is insufficient)
Field 4: Longitude E ( East longitude) or W (west longitude)
Field 5: UTC time, hhmmss.sss format
Field 6: Status, A=located, V=not located
Field 7: Check value

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
experiment 209: Gravity: I2C & UART BC20 NB-IoT & GNSS communication module
NB-IoT wide-area low-power wireless communication GPS/ Beidou precise positioning is necessary for the outdoor Internet of Things
Project 14: Query the information of the global navigation satellite system (GSA) protocol through the serial port

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二百零九:Gravity: I2C & UART BC20 NB-IoT & GNSS通信模块
  NB-IoT广域低功耗无线通信 GPS/北斗精准定位 户外物联网必备
  项目十四:通过串口查询全球导航卫星系统GSA协议的信息
  实验接线:
  BC20       UNO
  VIN        5V
  GND        GND
  SCL        A5
  SDA        A4
*/

#include "DFRobot_BC20_Gravity.h"

//RGB有7种颜色可供选择
#define  RED 0
#define  BLUE 1
#define  GREEN 2
#define  YELLOW 3
#define  PURPLE 4
#define  CYAN 5
#define  WHITE 6

//IIC通讯
#define USE_IIC

//硬件串口通讯
//#define USE_HSERIAL

//软件串口通讯
//#define USE_SSERIAL

DFRobot_BC20_IIC myBC20(0x33);

void setup() {
    
    
  Serial.begin(115200);
  myBC20.LED_OFF();

  //初始化 BC20
  Serial.print("正在启动BC20,请稍等...... ");
  myBC20.changeColor(RED);
  while (!myBC20.powerOn()) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("BC20 启动成功!");

  //禁用睡眠模式
  myBC20.configSleepMode(eSleepMode_Disable);

  //启动 GNSS
  Serial.print("打开全球导航卫星系统...  ");
  myBC20.setQGNSSC(ON);
  myBC20.changeColor(YELLOW);
  if (myBC20.getQGNSSC() == OFF) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("GNSS 开启");
  Serial.println("查询全球导航卫星系统GSA协议");
  myBC20.changeColor(CYAN);
}

void loop() {
    
    
  myBC20.getQGNSSRD(NMEA_GSA);

  Serial.print("模式\t\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    /*
       选择 2D 或 3D 修复
       'M'=手动,强制切换2D/3D模式
       'A'=允许自动切换2D/3D模式
    */
    Serial.print(sGSA.data[i].Mode());
    Serial.print("\t\t");
  }
  Serial.println();

  Serial.print("修复状态\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    Serial.print(sGSA.data[i].FixStatus());
    Serial.print("\t\t");
  }
  Serial.println();

  Serial.print("系统ID\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    Serial.print(sGSA.data[i].GNSS_SystemID());
    Serial.print("\t\t");
  }
  Serial.println();

  //每个频道使用的卫星列表
  for (uint8_t i = 0; i < 12; i++) {
    
    
    Serial.print("CH");
    Serial.print(i + 1);
    Serial.print("\t\t");
    for (uint8_t j = 0; j < sGSA.NUM; j++) {
    
    
      Serial.print(sGSA.data[j].Statellite_CH(i));
      Serial.print("\t\t");
    }
    Serial.println();
  }
  //水平精度因子
  Serial.print("水平精度因子\t\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    Serial.print(sGSA.data[i].PDOP());
    Serial.print("\t\t");
  }
  Serial.println();

  //垂直精度因子
  Serial.print("垂直精度因子\t\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    Serial.print(sGSA.data[i].HDOP());
    Serial.print("\t\t");
  }
  Serial.println();

  Serial.print("VDOP\t\t");
  for (uint8_t i = 0; i < sGSA.NUM; i++) {
    
    
    Serial.print(sGSA.data[i].VDOP());
    Serial.print("\t\t");
  }
  Serial.println();

  Serial.println();
  myBC20.clearGPS();

  myBC20.LED_ON();
  delay(500);
  myBC20.LED_OFF();
#ifndef ARDUINO_ESP32_DEV
  delay(500);
#else
  delay(5000);
#endif
}

Experimental serial port return

insert image description here

NMEA0183 standard sentences (commonly used GPS sentences)

GPGSA Example: GPGSA Example:GPGS A example: GPGSA,A,3,01,20,19,13,40.4,24.4,32.2*0A
field 0: $GPGSA, statement ID, indicating that the statement is the current satellite information
field1: positioning mode, A=automatic 2D/3D, M=manual 2D/3D
field 2: positioning type, 1=not positioned, 2=2D positioning, 3=3D positioning
field 3: PRN code (pseudo random noise code), The satellite PRN code number (00) in use on the 1st channel (if the leading digit is insufficient, add 0)
Field 4: PRN code (pseudo random noise code), the satellite PRN code number (00) in use on the 2nd channel (leading digit If the number is insufficient, add 0)
Field 5: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the third channel (00) (if the number of leading digits is insufficient, add 0) Field 6: PRN code (pseudo-random noise
code ), the satellite PRN code number (00) in use on the 4th channel (if the leading digit is insufficient, add 0)
field 7: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the 5th channel ( If the number of leading digits is insufficient, add 0)
Field 8: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the 6th channel (if the leading number is insufficient, add 0) Field 9: PRN
code (pseudo-random Noise code), the satellite PRN code number (00) in use on the 7th channel (00 if the leading number is insufficient) Field 10
: PRN code (pseudo random noise code), the satellite PRN code number in use on the 8th channel (00 ) (fill 0 if the leading digit is insufficient)
Field 11: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the 9th channel (00) (fill 0 if the leading digit is insufficient)
Field 12: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the 10th channel (if the leading digits are insufficient, add 0) Field 13: PRN code (pseudo-random noise code), the 11th channel is being
used The number of the satellite PRN code used (00) (if the leading digit is insufficient, add 0)
Field 14: PRN code (pseudo-random noise code), the satellite PRN code number (00) in use on the 12th channel (if the leading digit is insufficient, add 0)
Field 15: PDOP integrated position precision factor (0.5 - 99.9)
Field 16: HDOP horizontal precision factor (0.5 - 99.9)
Field 17: VDOP vertical precision factor (0.5 - 99.9)
Field 18: check value

[Arduino] 168 kinds of sensor module series experiments (data code + simulation programming + graphics programming)
experiment 209: Gravity: I2C & UART BC20 NB-IoT & GNSS communication module
NB-IoT wide-area low-power wireless communication GPS/ Beidou precise positioning is necessary for the outdoor Internet of Things
Project 15: Query the information of the GSV protocol of the global navigation satellite system through the serial port

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二百零九:Gravity: I2C & UART BC20 NB-IoT & GNSS通信模块
  NB-IoT广域低功耗无线通信 GPS/北斗精准定位 户外物联网必备
  项目十五:通过串口查询全球导航卫星系统GSV协议的信息
  实验接线:
  BC20       UNO
  VIN        5V
  GND        GND
  SCL        A5
  SDA        A4
*/

#include "DFRobot_BC20_Gravity.h"

//RGB有7种颜色可供选择
#define  RED 0
#define  BLUE 1
#define  GREEN 2
#define  YELLOW 3
#define  PURPLE 4
#define  CYAN 5
#define  WHITE 6

//IIC通讯
#define USE_IIC

//硬件串口通讯
//#define USE_HSERIAL

//软件串口通讯
//#define USE_SSERIAL

DFRobot_BC20_IIC myBC20(0x33);

void Display_Satellite_Information() {
    
    
  Serial.print(sSAT.NUM);
  Serial.println(" 颗卫星在视图中");

  //卫星 PRN 号码
  Serial.print("卫星编号\t");
  
  //仰角,单位为度
  Serial.print("仰角(度)\t");
  
  //方位角,单位度
  Serial.print("方位角(度)\t");
  
  //信噪比,单位 dBHz
  Serial.print("信噪比(dBHz)\t");
  Serial.println("系统");
  for (uint8_t i = 0; i < sSAT.NUM; i++) {
    
    
    Serial.print(sSAT.data[i].PRN());
    Serial.print("\t");
    Serial.print(sSAT.data[i].Elev());
    Serial.print("\t\t");
    Serial.print(sSAT.data[i].Azim());
    Serial.print("\t\t");
    Serial.print(sSAT.data[i].SNR());
    Serial.print("\t\t");
    Serial.println(sSAT.data[i].SYS());
  }
  Serial.println();
}

void setup() {
    
    
  Serial.begin(115200);
  myBC20.LED_OFF();

  //初始化 BC20
  Serial.print("正在启动BC20,请稍等...... ");
  myBC20.changeColor(RED);
  while (!myBC20.powerOn()) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("BC20 启动成功!");

  //禁用睡眠模式
  myBC20.configSleepMode(eSleepMode_Disable);

  //启动 GNSS
  Serial.print("打开全球导航卫星系统...");
  myBC20.setQGNSSC(ON);
  myBC20.changeColor(YELLOW);
  if (myBC20.getQGNSSC() == OFF) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("GNSS 开启");
  myBC20.changeColor(CYAN);
}

void loop() {
    
    
  myBC20.getQGNSSRD(NMEA_GSV);
  Display_Satellite_Information();
  myBC20.clearGPS();

  myBC20.LED_ON();
  delay(500);
  myBC20.LED_OFF();
#ifndef ARDUINO_ESP32_DEV
  delay(500);
#else
  delay(5000);
#endif
}

Experimental serial port return

insert image description here

NMEA0183 standard sentences (commonly used GPS sentences)

GPGSV example: GPGSV example:Example of GPGS V : GPGSV,3,1,10,20,78,331,45,01,59,235,47,22,41,069,13,32,252,45*70
Field 0: $GPGSV, sentence ID, indicating that the sentence is GPS Satellites in View (GSV) visible satellite information
Field 1: The total number of this GSV statement (1 - 3)
Field 2: This GSV statement is the number of this GSV statement (1 - 3)
Field 3: The total number of currently visible satellites (00 - 12) (fill 0 if the leading digit is insufficient)
Field 4: PRN code (pseudo-random noise code) (01 - 32) (fill 0 if the leading digit is insufficient)
Field 5: Satellite elevation angle (00 - 90) degrees (If the leading digits are insufficient, fill in 0)
Field 6: Satellite azimuth (00-359) degrees (If the leading digits are insufficient, fill in 0)
Field 7: Signal-to-noise ratio (00-99) dbHz
Field 8: PRN code (pseudo-random Noise code) (01 - 32) (if the leading digit is insufficient, add 0)
Field 9: Satellite elevation angle (00 - 90) degrees (if the leading digit is insufficient, add 0)
Field 10: Satellite azimuth (00 - 359) degree ( If the number of leading digits is insufficient, add 0)
Field 11: Signal-to-noise ratio (00-99) dbHz
Field 12: PRN code (pseudo-random noise code) (01-32) (if the leading number is insufficient, add 0)
Field 13: Satellite elevation angle (00 - 90) degrees (if the leading digits are insufficient, add 0)
field 14: satellite azimuth angle (00 - 359) degrees (if the leading digits are insufficient, add 0)
field 15: signal-to-noise ratio (00-99) dbHz
field 16 : check value

Guess you like

Origin blog.csdn.net/weixin_41659040/article/details/132138591