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

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

Use DFRobot Easy-IoT to test BC20 module cloud communication

Log in to the Easy-IoT Internet of Things cloud platform, click register/login in the upper right corner
http://iot.dfrobot.com.cn/

insert image description here

After logging in, it will automatically jump to the workshop. First click Add New Device to add a random generated Topic. In addition, notice the left column, click the eye button on the right to regenerate, the platform has automatically assigned the Iot_id and Iot_pwd of the current account to the user.

In order to allow the device to communicate with the platform normally, it is necessary to record the three parameters here and fill them in the code

Iot_id:HJZv1ZFRSQ
Iot_pwd:ByfP1-YABX
Topic:JoUOAg_WR

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 Accurately Positions Outdoor IoT Essentials
Project 18: Devices send messages to the cloud through the Easy-IoT IoT cloud platform

Experimental open source code

/*
  【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
  实验二百零九:Gravity: I2C & UART BC20 NB-IoT & GNSS通信模块
  NB-IoT广域低功耗无线通信 GPS/北斗精准定位 户外物联网必备
  项目十八:设备通过Easy-IoT物联网云平台发送消息到云端
  实验接线:
  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

//配置设备证书信息
char* Iot_id = "qlZ0uezGR";
char* Client_ID  = "BC20 NB-IoT";
char* Iot_pwd    = "3_W0uezGgz";

//配置域名和端口号
char* EasyIot_SERVER = "182.254.130.180";
char* PORT = "1883";

//设置需要发布的设备编号
char* pubTopic = "hJmOvRIng";

//IIC通讯
#define USE_IIC

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

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

DFRobot_BC20_IIC myBC20(0x33);

void ConnectCloud() {
    
    
  Serial.print("尝试MQTT连接...");
  myBC20.changeColor(YELLOW);
  while (!myBC20.connected()) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);

    if (myBC20.connect(Client_ID, Iot_id, Iot_pwd)) {
    
    
      Serial.println("\n连接服务器正常");
    } else {
    
    

      //用于检测设备与服务器的连接
      if (myBC20.getQMTCONN())
        break;
    }
  }
}

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 启动成功!");

  //检查 SIM 卡是否插入
  Serial.println("正在检查SIM卡……");
  myBC20.changeColor(GREEN);
  while (!myBC20.checkNBCard()) {
    
    
    Serial.println("请插入NB SIM卡!");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("SIM 卡检查OK!");

  //打印 IMEI、ICCID 和 IMSI
  myBC20.getGSN(IMEI);
  Serial.print("BC20 IMEI: ");
  Serial.println(sGSN.imei);
  Serial.print("SIM card ICCID:");
  Serial.print(myBC20.getQCCID());
  Serial.print("SIM card IMSI: ");
  Serial.println((char *)myBC20.getIMI());

  /* 
     模块将自动尝试连接到网络(移动站)。
     检查它是否已连接到网络。
  */
  Serial.println("正在连接网络...");
  myBC20.changeColor(BLUE);
  while (myBC20.getGATT() == 0) {
    
    
    Serial.print(".");
    myBC20.LED_ON();
    delay(500);
    myBC20.LED_OFF();
    delay(500);
  }
  Serial.println("网络已连接!");

  Serial.println("连接到DFRobot Easy-IoT!");

  //Configure IoT Server
  myBC20.setServer(EasyIot_SERVER, PORT);
  Serial.println("服务器可用!");
  ConnectCloud();
}

void loop() {
    
    
  delay(10000);
  Serial.println("发送消息到云端...");
  myBC20.publish(pubTopic, "Hello World");
  Serial.println("消息已发送");
}

Experimental serial port return

insert image description here
The device sends messages to the cloud through Easy-IoT. Core settings
1. The module is connected to the main control board according to the connection diagram, connected to the NB-IoT antenna, and inserted into the SIM card.
2. Fill in the recorded values ​​of the three parameters Iot_id, Iot_pwd and Topic into the sample code, and keep other parameters unchanged. (Client_ID is used to distinguish different devices, a value can be configured arbitrarily, here use "BC20 NB-IoT")

//配置设备证书信息
char* Iot_id = "HJZv1ZFRSQ"; //填入Iot_id
char* Client_ID = "BC20 NB-IoT";
char* Iot_pwd = "ByfP1-YABX"; //填入Iot_pwd

//配置域名和端口号(这是固定的)
char* EasyIot_SERVER = "182.254.130.180";
char* PORT = "1883";

//设置需要发布的设备编号
char* pubTopic = "JoUOAg_WR"; //填入Topic

In order to verify whether the cloud platform has indeed received the information "Hello World" sent by the device, go back to the workshop of the Easy-IoT cloud platform, the top line, 6/1000, indicates that 6 pieces of information have been received, for details, click Topic Check the details (in red dot) below.

insert image description here

In the query result column, you can find the messages received by the cloud.

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 Accurately Positions Outdoor IoT Essentials
Project 19: Simple Devices Send Messages to the Cloud

Experiment with open-source graphics programming (Mind+, Mixly, learning by playing)

insert image description here
Experimental serial port return

insert image description here

In the query result column, you can find the messages received by the cloud.

insert image description here

Guess you like

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