ModularSensors > Modules > Supported Modems and Communication Modules > Quectel BG96

Quectel BG96 module

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(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). Should be set to a negative number if the modem should be continuously powered or the power cannot be controlled by the MCU.
statusPin The digital pin number of the mcu pin connected to the modem status output pin. 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.
modemResetPin The digital pin number of the pin on the mcu attached the the hard or panic reset pin of the modem. 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.
modemSleepRqPin The digital pin number of a pin on the mcu used to request the modem enter its lowest possible power state. 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.
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.



Example Code

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

// For the Dragino, Nimbelink or other boards based on the Quectel BG96
#include <modems/QuectelBG96.h>

// NOTE: Extra hardware and software serial ports are created in the "Settings
// for Additional Serial Ports" section
const int32_t modemBaud = 115200;  // Communication speed of the modem
// NOTE:  This baud rate too fast for an 8MHz board, like the Mayfly!  The
// module should be programmed to a slower baud rate or set to auto-baud using
// the AT+IPR=9600 command.

// Modem Pins - Describe the physical pin connection of your modem to your board
// NOTE:  Use -1 for pins that do not apply
// Example pins here are for a modified Mayfly and a Dragino IoT Bee
const int8_t modemVccPin     = -1;  // MCU pin controlling modem power
const int8_t modemStatusPin  = -1;  // MCU pin used to read modem status
const int8_t modemResetPin   = A4;  // MCU pin connected to modem reset pin
const int8_t modemSleepRqPin = A3;  // MCU pin for modem sleep/wake request
const int8_t modemLEDPin = redLED;  // MCU pin connected an LED to show modem
                                    // status

// Network connection information
const char* apn = "xxxxx";  // APN for GPRS connection

// Create the modem object
QuectelBG96 modemBG96(&modemSerial, modemVccPin, modemStatusPin, modemResetPin,
                      modemSleepRqPin, apn);
// Create an extra reference to the modem by a generic name
QuectelBG96 modem = modemBG96;

Classes

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

Defines

#define TINY_GSM_MODEM_BG96
The modem type for the underlying TinyGSM library.
#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.