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
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.
[Arduino] 168 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 consumption wireless communication GPS/ Beidou Accurately Positions the Must-Have Outdoor IoT
Project 20: Publishing News through the Easy-IOT 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 = "wGkCJkIng";
char* Client_ID = "BC20 NB-IoT";
char* Iot_pwd = "QMkC1kInRz";
//配置域名和端口号
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 callback(char * topic, uint8_t * payload, unsigned int len) {
Serial.print("接收[主题:");
Serial.print(topic);
Serial.print("] ");
for (int i = 0; i < len; i++) {
Serial.print((char)payload[i]);
}
Serial.println();
//根据接收到的消息控制板载 RGB LED。
char* receivedData = (char*)payload;
if (strcmp(receivedData, "OFF") == 0) {
myBC20.LED_OFF();
Serial.println("LED 灯熄灭");
}
else if (strcmp(receivedData, "RED") == 0) {
myBC20.changeColor(RED);
myBC20.LED_ON();
Serial.println("LED 是红色的");
}
else if (strcmp(receivedData, "GREEN") == 0) {
myBC20.changeColor(GREEN);
myBC20.LED_ON();
Serial.println("LED 为绿色");
}
else if (strcmp(receivedData, "BLUE") == 0) {
myBC20.changeColor(BLUE);
myBC20.LED_ON();
Serial.println("LED 为蓝色");
}
else if (strcmp(receivedData, "YELLOW") == 0) {
myBC20.changeColor(YELLOW);
myBC20.LED_ON();
Serial.println("LED 是黄色的");
}
else if (strcmp(receivedData, "PURPLE") == 0) {
myBC20.changeColor(PURPLE);
myBC20.LED_ON();
Serial.println("LED 是紫色的");
}
else if (strcmp(receivedData, "CYAN") == 0) {
myBC20.changeColor(CYAN);
myBC20.LED_ON();
Serial.println("LED 为青色");
}
else if (strcmp(receivedData, "WHITE") == 0) {
myBC20.changeColor(WHITE);
myBC20.LED_ON();
Serial.println("LED 是白色的");
}
else {
;
}
}
void ConnectCloud() {
Serial.print("尝试MQTT连接......");
while (!myBC20.connected()) {
Serial.print(".");
if (myBC20.connect(Client_ID, Iot_id, Iot_pwd)) {
Serial.println("连接服务器正常");
} else {
//用于检测设备与服务器的连接
if (myBC20.getQMTCONN())
break;
}
}
while (!myBC20.subTopic('0', '1',pubTopic , '0')) {
Serial.print(".");
}
Serial.print("主题:");
Serial.print(pubTopic);
Serial.println(" 订阅了!");
}
void setup() {
Serial.begin(115200);
myBC20.LED_OFF();
/*Initialize 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.print(".");
myBC20.LED_ON();
delay(500);
myBC20.LED_OFF();
delay(500);
}
Serial.println("OK!");
//禁用睡眠模式
myBC20.configSleepMode(eSleepMode_Disable);
//禁用 PSM
myBC20.setPSMMode(ePSM_OFF);
/*
模块将自动尝试连接到网络(移动站)。
检查它是否已连接到网络。
*/
Serial.print("正在连接网络......");
myBC20.changeColor(BLUE);
while (myBC20.getGATT() == 0) {
Serial.print(".");
myBC20.LED_ON();
delay(500);
myBC20.LED_OFF();
delay(500);
}
Serial.println("已连接!");
//设置回调函数
myBC20.setCallback(callback);
Serial.println("连接到DFRobot Easy-IoT");
//配置物联网服务器
myBC20.setServer(EasyIot_SERVER, PORT);
Serial.println("服务器可用!");
//连接DFRobot Easy-IoT
ConnectCloud();
}
void loop() {
myBC20.loop();
}
Open the workbench and click send message
Fill in the message to be sent "everything fine?" in the send box, click send
view information
Experimental serial port return
At the workbench, send "RED"
Experimental serial port return
Experimental scene diagram - LED is red
Send different string commands, the RGB lights on the BC20 module display different colors