Quectel BG96 topic

Introduction

The Quectel BG96 is another LTE CatM1/NB1 chip. This same constructor should work for most boards based on this chip, including the Dragino and Nimbelink boards.

This is the only cellular module that I have found to function well on only a 500mA power supply - provided the cellular signal is strong and 2G fallback isn't required. To enable 2G fallback, expect power draws of up to 2A.

Connecting a BG96 to a Mayfly

To my knowledge, there are not any Quectel BG96 modules available that can directly connect to a Mayfly. Although both the Dragino and Nimbelink boards linked above would fit the physical XBee footprint on the Mayfly, neither will work without some additional interface or other modifications. The Dragino module comes really close, but it will not actually work because the BG96 requires more power than the Mayfly can provide on its own but cannot be connected directly to a LiPo because it cannot handle a voltage over 3.6V. The Nimbelink module has the same power supply problem, voltage reference problems, and requires 3 extra ground pins that aren't available on the Mayfly.

Manufacturer Documentation

The module datasheet and AT commands are available here: https://www.quectel.com/product/bg96.htm

Modem Constructor

QuectelBG96::QuectelBG96(Stream* modemStream, int8_t powerPin, int8_t statusPin, int8_t modemResetPin, int8_t modemSleepRqPin, const char* apn)

Construct a new Quectel BG96 object.

Parameters
modemStream The Arduino stream instance for serial communication.
powerPin The digital pin number of the mcu pin controlling power to the modem (active HIGH).
statusPin The digital pin number of the mcu pin connected to the modem status output pin.
modemResetPin The digital pin number of the pin on the mcu attached the the hard or panic reset pin of the modem.
modemSleepRqPin The digital pin number of a pin on the mcu used to request the modem enter its lowest possible power state.
apn The Access Point Name (APN) for the SIM card.

The constuctor initializes all of the provided member variables, constructs a loggerModem parent class with the appropriate timing for the module, calls the constructor for a TinyGSM modem on the provided modemStream, and creates a TinyGSM Client linked to the modem.

Should be set to a negative number if the modem should be continuously powered or the power cannot be controlled by the MCU. Should be set to a negative number if the modem status pin cannot be read. This is the pin labeled STATUS in Quectel's integration guide. Should be set to a negative number if the modem reset pin is not connected to the MCU. This is the pin labeled RESET_N in Quectel's integration guide. Should be set to a negative number if there is no pin usable for deep sleep modes or it is not accessible to the MCU. This is the pin labeled PWRKEY in Quectel's integration guide.



Example Code

The Quectel BG96 is used in the menu a la carte.

1// For the Dragino, Nimbelink or other boards based on the Quectel BG96
2#include <modems/QuectelBG96.h>
3
4// NOTE: Extra hardware and software serial ports are created in the "Settings
5// for Additional Serial Ports" section
6const int32_t modemBaud = 115200; // Communication speed of the modem
7// NOTE: This baud rate too fast for an 8MHz board, like the Mayfly! The
8// module should be programmed to a slower baud rate or set to auto-baud using
9// the AT+IPR=9600 command.
10
11// Modem Pins - Describe the physical pin connection of your modem to your board
12// NOTE: Use -1 for pins that do not apply
13// Example pins here are for a Mayfly 1.x and a Dragino IoT Bee
14const int8_t modemVccPin = 18; // MCU pin controlling modem power
15const int8_t modemStatusPin = -1; // MCU pin used to read modem status
16const int8_t modemResetPin = A5; // MCU pin connected to modem reset pin
17const int8_t modemSleepRqPin = -1; // MCU pin for modem sleep/wake request
18const int8_t modemLEDPin = redLED; // MCU pin connected an LED to show modem
19 // status
20
21// Network connection information
22const char* apn = "xxxxx"; // APN for GPRS connection
23
24// Create the modem object
25QuectelBG96 modemBG96(&modemSerial, modemVccPin, modemStatusPin, modemResetPin,
26 modemSleepRqPin, apn);
27// Create an extra reference to the modem by a generic name
28QuectelBG96 modem = modemBG96;

Classes

class QuectelBG96
The loggerModem subclass for Dragino, Nimbelink, or any other module based on the Quectel BG96.

Modem Pin Settings and Timing

The timing and pin level settings for a Quectel BG96

#define BG96_STATUS_LEVEL = HIGH
The loggerModem::_statusLevel.
#define BG96_STATUS_TIME_MS = 5000L
The loggerModem::_statusTime_ms.
#define BG96_RESET_LEVEL = LOW
The loggerModem::_resetLevel.
#define BG96_RESET_PULSE_MS = 300
The loggerModem::_resetPulse_ms.
#define BG96_WAKE_LEVEL = LOW
The loggerModem::_wakeLevel.
#define BG96_WAKE_PULSE_MS = 110
The loggerModem::_wakePulse_ms.
#define BG96_WAKE_DELAY_MS = 100
The loggerModem::_wakeDelayTime_ms.
#define BG96_ATRESPONSE_TIME_MS = 10000L
The loggerModem::_max_atresponse_time_ms.
#define BG96_DISCONNECT_TIME_MS = 5000L
The loggerModem::_disconnetTime_ms.

Define documentation

#define BG96_STATUS_LEVEL = HIGH

The loggerModem::_statusLevel.

Status of the BG96 can be monitored on the STATUS(D0) pin. Time after end pulse until status pin becomes active is 4.8s.


#define BG96_STATUS_TIME_MS = 5000L

The loggerModem::_statusTime_ms.

Status of the BG96 can be monitored on the STATUS(D0) pin. Time after end pulse until status pin becomes active is 4.8s.


#define BG96_RESET_LEVEL = LOW

The loggerModem::_resetLevel.

BG96 is reset with a 150-460ms low pulse on the RESET_N pin


#define BG96_RESET_PULSE_MS = 300

The loggerModem::_resetPulse_ms.

BG96 is reset with a 150-460ms low pulse on the RESET_N pin


#define BG96_WAKE_LEVEL = LOW

The loggerModem::_wakeLevel.

Module is switched on by a >100 millisecond LOW pulse on the PWRKEY pin. Module is switched on by a >650 millisecond LOW pulse on the PWRKEY pin. Using something between those times for wake and using AT commands for sleep, we should keep in the proper state.


#define BG96_WAKE_PULSE_MS = 110

The loggerModem::_wakePulse_ms.

Module is switched on by a >100 millisecond LOW pulse on the PWRKEY pin. Module is switched on by a >650 millisecond LOW pulse on the PWRKEY pin. Using something between those times for wake and using AT commands for sleep, we should keep in the proper state.


#define BG96_WAKE_DELAY_MS = 100

The loggerModem::_wakeDelayTime_ms.

Time after VBAT is stable before PWRKEY can be used on BG96 is >30ms


#define BG96_ATRESPONSE_TIME_MS = 10000L

The loggerModem::_max_atresponse_time_ms.

The BG96 has USB active at >4.2 sec, status at >4.8 sec, URAT at >4.9


#define BG96_DISCONNECT_TIME_MS = 5000L

The loggerModem::_disconnetTime_ms.

Documentation for the BG96 says to allow >2s for clean shutdown.