I have been seeing a recent surge in projects that use GSM modules to connect various things to the Internet. GSM is a versatile medium as it is definitely long range, supports video/audio transmission and provides ample bandwidth to transmit large volume of data. There are quite a few GSM modules out there but none as versatile as the Quectel BG96.Rak wireless recently released a version of their BG96 module name WisLTE and I thought ill take it for a spin in the world of IoT.RAK has a bold claim:
WisLTE — The first BG96 LTE "Arduino" friendly Board
And yes that quite true !!! This is the only board currently in the market that supports the Arduino form factor with a BG96 module on board.
Well, is there anything different, this is just another GSM board right. We'll then your quite wrong. This little puppy has a lot to offer:BG96 is an embedded IoT (LTE Cat M1 and LTE Cat NB1) wireless communication module without receive diversity. It supports LTE-TDD and Half-Duplex LTE-FDD wireless communication, which provides data connectivity on LTE-TDD/FDD networks. It also provides GNSS1) and voice2) functionalities to meet customers’ specific application demands.BG96 is a series of LTE Cat M1 and Cat NB1 module offering a maximum data rate of 375kbps downlink and uplink. It features ultra-low power consumption, and provides pin-to-pin compatibility with Quectel LTE module EG91, Cat NB1 (NB-IoT) module BC95, UMTS/HSPA modules UG95/UG96 and GSM/GPRS module M95.
Characteristics- Compatible with Arduino control, supports external MCU control
- Supports USB serial, USB CDC ACM driver and provides Windows XP, Windows 7/8/10, Linux 2.6 / 3.0, Android 2.3 / 4.0 / 4.2 / 4.4 / 5.0 / 5.1 / 6.0 platform driver.
- Supports I2C communication.
- Supports USB upgrade, serial upgrade, DFOTA upgrade
On the board itself, there are the following pins exposed:
That is a whole bunch of cool debug/dev features that one can dream of on a LTE module. But how do we use the board to its full potential.
Enter Hologram:According to Hologram:
Global cellular connectivity for IoT devices - scale your deployments in 196 countries with over 550 carriers.
Hologram provides flexible tools for securely connecting IoT devices. Whether you're deploying at scale or building your first connected product, Hologram's products handle all your connectivity infrastructure needs.Their Service features:
- Hologram's Data Engine messaging, device management APIs, and Global IoT Network enable scaling large deployments without increasing your engineering costs.
- Avoid sourcing and designing connectivity hardware or negotiating with telecoms when building your IoT device. We abstract connectivity so your enterprise can deliver product easier.
- Their network was designed from the ground up for machines, and includes advanced security features such as automatic device fire-walling and advanced session authentication.
- Visit the official website of Hologram. Click on "DASHBOARD" in the upper right corner @ Hologram.io and create your account.
- Then click on "sign up" at the bottom of the page. Enter the registration interface. Follow the prompts to fill in the information to register.
- After successful registration, log into your Hologram account and enter your Dashboard interface.Next you need to activate your purchased Hologram SIM card. Click on "Activate you first SIM" in the upper right corner of the page.
- Enter the activation interface, according to the given prompts, fill in the information, you can complete the activation of the SIM card. After successful registration, enter the SIM card information interface. After waiting for a period of time, you will see the “Live” status.
Hurrrrray !!!!! your sim is now activated. You can start using your sim to now send and receive data. you can also use it for SMS send and receive as well. Make sure you check out the FUP for your plans and use the features accordingly to avoid additional costs.Now insert the sim into your WISLTE board an power it on:Wislte can talk to any master peripheral microcontroller or a linux/windows PC through a serial connection. Connect Pin5 to pin 8 and pin 6 to pin 7 on the boardThe yellow border shows the jumper connection.
When the module powers on, press the PWRKEY to power on the module. You will on the serial program (you can use Putty or CommUart assistant) that you will get a RDY output meaning the module is "READY".
TO ensure that you can use the Quectel module to it full potential, I would suggest learning the QNavigator software. It provided a easy to use UI to send AT commands to the Quectel module connected to serial port. How to use the Qnavigator Module:
- Download the module from the Quectel website. You may have to register for the download section to open up. After installing the screen would look like this.
- Next Choose GSM/GPRS and then click next.
- Next select the UART baudrate as 115200 by clicking on the button marked with the red arrow in the picture above.
- Next click the connect module button shown in the picture below:
- The module will try to connect automatically to the carrier presented by the surrounding networks, If it doesn't connect don't worry, I have given the detailed steps below for NB IoT network connections.
Now your ready to send commands via the text box just below the messages scroll view section. Always remember to add a /r/n to the end of the command
Send Data via Hologram services.Now that the device is working fine, lets move on to sending data Insert the SIM card into the WisLTE slot if you haven't by now, and then connect the WisLTE device to the computer through the connection cable.( Please note that the LTE antenna needs to be connected). Open us Qnavigator as explained above and get ready to enter some AT commands.Then send the following AT command.( For AT command details, see the AT command manual provided by Quectel)
AT+COPS=? // Find nearby network informationAT+COPS=1,0,”VodafoneIN”,0 // Manually set up a connected networkAT+CREG? // Check whether the device is registered on the networkAT+QNWINFO // Query connected network informationAT+COPS? // Query the connected web server informationAT+QICSGP=1,1,"hologram","","",1 // Set APN network to hologramAT+QIACT=1 // Activate the APN networkAT+QIACT? // Query the APN assigned IP addressAT+QIOPEN=1,0,"TCP","23.253.146.203",9999,0,1 // Create a TCP, connection hologram test serverAT+QISEND=0,48 // Send data, send data length is 48{"k":"bZmmdbAg","d":"Hello,World!","t":"TOPIC1"} //Send Packets.The data format is a hologram-definedformat.( For details, please see: https://hologram.io/docs/reference/cloud/embedded/ )AT+QISEND=0,0 // Query data is sent successfully
After the device is sent successfully, you can see the sent information on your interface of theHologram Dashboard
Receiving data is similar to sending data, except that the established socket is different. The receiving data is established as a TCP server. The AT commands sent are shown below:
AT+COPS=? // Find nearby network informationAT+COPS=1,0,”VodafoneIN”,0 // Manually set up a connected networkAT+CREG? // Check whether the device is registered on the networkAT+QNWINFO // Query connected network informationAT+COPS? // Query the connected web server informationAT+QICSGP=1,1,"hologram","","",1 // Set APN network to hologramAT+QIACT=1 // Activate the APN networkAT+QIACT? // Query the APN assigned IP addressAT+QIOPEN=1,1,"TCP LISTENER","127.0.0.1",0,2020,0 // Create a TCP server, use local IP, port 2020AT+QIRD=11,1500 // Read the received data, 11 is the returned Socket identifier
After creating a successful TCP server, the user needs to return to the Hologram Dashboard interface, click on the "send to device" button, and then fill in the data to be sent. PORT is the TCP server port of the device. Fill in and click "Send data message".
After the Hologram Dashboard is sent, the device will receive a message of “recv, 11” indicating that the device received the data. At this time, the AT+QIRD=11, 1500 command is sent to obtain the received data.
Readers can look forward to a simple Arduino library that batches this all up into a easy to use library. AN Android things driver is already in the works here:
https://github.com/narioinc/AndroidThingsWisLTE
An Initial support from Tiny GSM is available here:https://github.com/vshymanskyy/TinyGSM/issues/157
/**************************************************************
*
* This sketch connects to a website and downloads a page.
* It can be used to perform HTTP/RESTful API calls.
*
* For this example, you need to install ArduinoHttpClient library:
* https://github.com/arduino-libraries/ArduinoHttpClient
* or from http://librarymanager/all#ArduinoHttpClient
*
* TinyGSM Getting Started guide:
* http://tiny.cc/tiny-gsm-readme
*
* For more HTTP API examples, see ArduinoHttpClient library
*
**************************************************************/
// Select your modem:
//#define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590
// #define TINY_GSM_MODEM_ESP8266
#define TINY_GSM_MODEM_BG96
// Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512
#include <TinyGsmClient.h>
#include <ArduinoHttpClient.h>
// Uncomment this if you want to see all AT commands
#define DUMP_AT_COMMANDS
// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial
// Use Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1
// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX
// Your GPRS credentials
// Leave empty, if missing user or pass
const char apn[] = "YourAPN";
const char user[] = "";
const char pass[] = "";
// Server details
const char server[] = "vsh.pp.ua";
const char resource[] = "/TinyGSM/logo.txt";
const int port = 80;
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
TinyGsmClient client(modem);
HttpClient http(client, server, port);
void setup() {
// Set console baud rate
SerialMon.begin(115200);
delay(10);
// Set GSM module baud rate
SerialAT.begin(115200);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(F("Initializing modem..."));
modem.restart();
String modemInfo = modem.getModemInfo();
SerialMon.print(F("Modem: "));
SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
}
void loop() {
SerialMon.print(F("Waiting for network..."));
if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
SerialMon.print(F("Performing HTTP GET request... "));
int err = http.get(resource);
if (err != 0) {
SerialMon.println(F("failed to connect"));
delay(10000);
return;
}
int status = http.responseStatusCode();
SerialMon.println(status);
if (!status) {
delay(10000);
return;
}
while (http.headerAvailable()) {
String headerName = http.readHeaderName();
String headerValue = http.readHeaderValue();
//SerialMon.println(headerName + " : " + headerValue);
}
int length = http.contentLength();
if (length >= 0) {
SerialMon.print(F("Content length is: "));
SerialMon.println(length);
}
if (http.isResponseChunked()) {
SerialMon.println(F("The response is chunked"));
}
String body = http.responseBody();
SerialMon.println(F("Response:"));
SerialMon.println(body);
SerialMon.print(F("Body length is: "));
SerialMon.println(body.length());
// Shutdown
http.stop();
SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
// Do nothing forevermore
while (true) {
delay(1000);
}
}
Web Client code:
/**************************************************************
*
* This sketch connects to a website and downloads a page.
* It can be used to perform HTTP/RESTful API calls.
*
* TinyGSM Getting Started guide:
* http://tiny.cc/tiny-gsm-readme
*
**************************************************************/
// Select your modem:
#define TINY_GSM_MODEM_SIM800
// #define TINY_GSM_MODEM_SIM808
// #define TINY_GSM_MODEM_SIM900
// #define TINY_GSM_MODEM_A6
// #define TINY_GSM_MODEM_A7
// #define TINY_GSM_MODEM_M590
// #define TINY_GSM_MODEM_ESP8266
#define TINY_GSM_MODEM_BG96
// Increase RX buffer if needed
//#define TINY_GSM_RX_BUFFER 512
#include <TinyGsmClient.h>
// Uncomment this if you want to see all AT commands
//#define DUMP_AT_COMMANDS
// Uncomment this if you want to use SSL
//#define USE_SSL
// Set serial for debug console (to the Serial Monitor, default speed 115200)
#define SerialMon Serial
// Use Hardware Serial on Mega, Leonardo, Micro
#define SerialAT Serial1
// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
//SoftwareSerial SerialAT(2, 3); // RX, TX
// Your GPRS credentials
// Leave empty, if missing user or pass
const char apn[] = "YourAPN";
const char user[] = "";
const char pass[] = "";
// Server details
const char server[] = "vsh.pp.ua";
const char resource[] = "/TinyGSM/logo.txt";
#ifdef DUMP_AT_COMMANDS
#include <StreamDebugger.h>
StreamDebugger debugger(SerialAT, SerialMon);
TinyGsm modem(debugger);
#else
TinyGsm modem(SerialAT);
#endif
#ifdef USE_SSL
TinyGsmClientSecure client(modem);
const int port = 443;
#else
TinyGsmClient client(modem);
const int port = 80;
#endif
void setup() {
// Set console baud rate
SerialMon.begin(115200);
delay(10);
// Set GSM module baud rate
SerialAT.begin(115200);
delay(3000);
// Restart takes quite some time
// To skip it, call init() instead of restart()
SerialMon.println(F("Initializing modem..."));
modem.restart();
String modemInfo = modem.getModemInfo();
SerialMon.print(F("Modem: "));
SerialMon.println(modemInfo);
// Unlock your SIM card with a PIN
//modem.simUnlock("1234");
}
void loop() {
SerialMon.print(F("Waiting for network..."));
if (!modem.waitForNetwork()) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(apn);
if (!modem.gprsConnect(apn, user, pass)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
SerialMon.print(F("Connecting to "));
SerialMon.print(server);
if (!client.connect(server, port)) {
SerialMon.println(" fail");
delay(10000);
return;
}
SerialMon.println(" OK");
// Make a HTTP GET request:
client.print(String("GET ") + resource + " HTTP/1.0\r\n");
client.print(String("Host: ") + server + "\r\n");
client.print("Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.connected() && millis() - timeout < 10000L) {
// Print available data
while (client.available()) {
char c = client.read();
SerialMon.print(c);
timeout = millis();
}
}
SerialMon.println();
// Shutdown
client.stop();
SerialMon.println(F("Server disconnected"));
modem.gprsDisconnect();
SerialMon.println(F("GPRS disconnected"));
// Do nothing forevermore
while (true) {
delay(1000);
}
}
Comments