Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GMX_BG96

The GMX-BG96 is a Quectel BG96 based GMX module for the Tuino plaform.



The board has 2 uFL connectors for both the Radio antenna and the GNSS antenna ( passive ), since the BG96 comes with an internal GNSS. Another neat feature is the presence of the USB port so that you can access directly the module ( which is very usefull when debugging AT command sequences).
There 3 led's, the first 2 ( red and green) are drivable via arduino code, while the third led ( blue ) is directly connected to the BG96 and signals the activity of the radio network.
Finally we have also added 2 microswitches to turn on and to reset the module. This can be useful if you want to use the board standalone ( but you need to supply 3.3V to it) and use it connected directly via the on board USB.

USB Drivers and Firmware update.

To install USB drivers to access the BG96 as well as the firmware update tool please refere to the Tuino 096 repository in the BG96_firmware_update directory.

Schematics

These are the schematics of the module: gmx_bg96_rev3.pdf

Simple Tuino Script

Here a first basic example that let you control the BG96 via the Tuino Serial port.

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  
  Serial.println("Starting...");
  
  if(Serial1) {
  Serial1.begin(115200);
  } 
        
  // RESET
  pinMode(GMX_RESET,OUTPUT);
  digitalWrite(GMX_RESET,LOW);

  // Boot
  // LED1
  pinMode(GMX_GPIO1,OUTPUT);
  // LED2
  pinMode(GMX_GPIO2,OUTPUT);
  // BG96 STATUS PIN
  pinMode(GMX_GPIO3,INPUT);
   // BG96 AP_READY
  pinMode(GMX_GPIO4,OUTPUT);
  // BG96 DTR
  pinMode(GMX_GPIO5,OUTPUT);
  //BG96 POWERKEY
  pinMode(GMX_GPIO6,OUTPUT); 

  digitalWrite(GMX_GPIO1,LOW);
  digitalWrite(GMX_GPIO2,LOW);
  digitalWrite(GMX_GPIO4,HIGH);
  digitalWrite(GMX_GPIO5,HIGH);
  digitalWrite(GMX_GPIO6,LOW);


  // Reset
  
  digitalWrite(GMX_RESET,LOW);
  delay(100);
  digitalWrite(GMX_RESET,HIGH);
  delay(200);
  digitalWrite(GMX_RESET,LOW);
  delay(200);
  
 
  // Power On
 
  digitalWrite(GMX_GPIO6,HIGH);
  delay(800);
  digitalWrite(GMX_GPIO6,LOW);
  delay(100);
 
}

void loop() {
  // put your main code here, to run repeatedly:
  byte ch;

  if (Serial1.available()>0) 
  {
    Serial.write(Serial1.read());
  }

  if (Serial.available()>0) 
  {
    ch = Serial.read();
    Serial1.write(ch);
  }
  
}

You can find this script in the gmx-bg96-proxy directory.

Simple Demo

In the bg96_demo directory you can find a simple script that uses a basic gmx_bg96 library for interacting with the BG96.
The demo consists in reading an analog temperature sensor, connected to the A0 port ( GROOVE Connector) and transmitting the data over to the cloud via a simple UDP socket connection.
The demo is configured to send data to our test cloud system ( please send us an email if you want an access ). In addition in the demo we are also using an OLED Display, connected to the I2C port ( always on a GROOVE Connector ) that displays some additional data.
The code also handles simple downlinks that can trigger the LED on the GMX-BG96 module ON and OFF.
The LEDS are mapped onto 2 bytes, setting the byte to 0 turns the led off, setting it to 1 turns the led ON.

Here some exctracts of the code to see how it works:

/* Here an extract to setup the BG96 and connect to the NB1 network */

// Init the BG96
if ( gmxBG96_init(__IP_ADDRESS__,__PORT__) ==  GMX_BG96_OK )
{
    Serial.println("Init Ok!")
}


if ( gmxBG96_setNBIoT("swisscom-test.m2m.ch","80000") == GMX_BG96_OK) 
{
  Serial.println("NBIoT Ok!")
}

/* Setup SWISSCOM as Operator */
if ( gmxBG96_setOperator("22801") == GMX_BG96_OK)
{
  Serial.print("Operator Set!");
}

if ( gmxBG96_attach() == GMX_BG96_OK)
{
  Serial.println("Attached to Network");
}



/* Here another extract for communicating */

      // Device Address
      for(int i=0;i<8;i++)
       buffering[i]=devAddress[i];

      // This is the payload lenght
      buffering[8]= 3;

      // Here we start the payload
      buffering[9] = 0x01;
      buffering[10] = (temperature_int & 0xff00 ) >> 8;
      buffering[11] = temperature_int & 0x00ff;
  
              
      if ( gmxBG96_SocketOpen()==GMX_BG96_OK)
        Serial.println("Socket Opened");
      else
        Serial.println("Socket Error");
            
                
      if ( gmxBG96_TXData(buffering,12) == GMX_BG96_OK )
        Serial.println("Send Ok!");
      else
        Serial.println("Send KO!");   


       if ( gmxBG96_SocketClose()==GMX_BG96_OK)
        Serial.println("Socket Opened");
      else
        Serial.println("Socket Error");

GMX-BG96 Library

In the Simple Demo you will find also the 'core' libraries that will help you use the BG96 module.
The files needed are:

  • gmx_bg96.cpp
  • gmx_bg96.h
  • at_client.cpp
  • at_client.h


The libraries gives a basic set of functions to setup the BG96 for the different Radio Technologies: 2G, LTE-NB1, LTE-CATM1 it supports. Attach to the network and send and receive data via UDP Sockets.

All function returns success or failure via the values: * GMX_BG96_OK => success * GMX_BG96_KO => failure

Here the Functions present in the library:
int8_t gmxBG96_init(String ip, String port);

Powers up and initializes the BG96. The function expects ip and port as input parameters for the UDP endpoint to which data will be sent.

uint8_t gmxBG96_getIMEI(char *data, uint8_t max_size);

Gets the IMEI of the BG96 returning it in data, max_size is the data buffer len.

uint8_t gmxBG96_getIMSI(char *data, uint8_t max_size);

Gets the IMSI of the SIM returning it in data, max_size is the data buffer len.

uint8_t gmxBG96_setGSM(char *apn);

Setup the BG96 for GSM connection, apn is the APN of the operator that will be selected.

uint8_t gmxBG96_setNBIoT(char *apn, char *band);

Setup the BG96 for NBIOT connection, apn is the APN of the operator that will be selected.
Check in the BG96 for the band parametes to select which NB1 band to use. For example B20 is 80000.

uint8_t gmxBG96_setCatM1(char *apn);

Setup the BG96 for CATM1 connection, apn is the APN of the operator that will be selected.

uint8_t gmxBG96_setOperator( char *op_code);

Sets the operator code op_code.
This command can take some time to finish.

uint8_t gmxBG96_attach();

Attaches to the network.
This command can take some time to finish.

uint8_t gmxBG96_isNetworkAttached(int *attach_status);

Returns in attach_status the state of the network attach.
Possible values are:

  • 0 -> Not trying to register
  • 1 -> Attached Home Network
  • 2 -> Trying to register to network
  • 3 -> Attach denied
  • 5 -> Attached Roaming Network

bool gmxBG96_isNetworkAttachedStatus(void);

This function simply returns true or false if the network is attached.

uint8_t gmxBG96_SocketOpen();

Open the Socket.

uint8_t gmxBG96_SocketClose();

Close the Socket.

uint8_t gmxBG96_TXData(char *data, int data_len);

Transmits the binary buffer data of size data_len via UDP socket.

uint8_t gmxBG96_RXData(char *rx_buffer, int rx_buffer_len, int *rx_received_len );

Checks if data is available in the RX buffer. Parameters are rx_buffer which will store the received Hex string, rx_buffer_len which is the maximum length for rx_buffer and rx_received_len which will return the actual bytes received.

uint8_t gmxBG96_GpsOn(void);

Turns On GPS.

uint8_t gmxBG96_GpsOff(void);

Turns Off GPS.

uint8_t gmxBG96_GpsLoc(char *lat, char *lon, char *alt, char *cog, char *speed, int* hour, int* minute, int* second, int* day, int* month, int* year ); 

Get GPS Fix.

About

Quectel BG96 GMX Module

Resources

Stars

4 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages