Setup Your Quectel BC95-G and Post any Event to Wia
Austin Spivey
Posted on June 21, 2018
In this tutorial, we're going through the initial steps to get setup with NB-IoT and the Quectel BC95-G and publish an Event to Wia.
Components
- Quectel BC95-G
- NB-IoT Compatible Antenna
- NB-IoT Compatible SIM Card (speak to your network operator about this)
Installing Python and Pyserial
If you haven’t already, you need to install Python on your computer to complete this tutorial.
- Python
- Version 2.7.x
- Follow the download instructions for your operating system
Note: Python Environment Variable
When using Windows, you'll need to add python to your path to make use of it anywhere in your OS. More on that here.
Now to install the pyserial
library:
- For Windows, open PowerShell (or Command Prompt) and run the command
pip install pyserial
- For Mac/Linux open Terminal and run the command
pip install pyserial
Note: Issues running the command?
In the rare case if pip install pyserial
doesn't work, try the following instead:
python -m pip install pyserial
Download the code
- For Windows, open PowerShell in the location of your choosing and run
git clone
git@github.com:wiaio/nb-iot-utilities.git
in the PowerShell terminal - For Mac/Linux open a terminal in the location of your choosing and run
git clone
git@github.com:wiaio/nb-iot-utilities.git
in the terminal
Alternatively, you can download the zip file here.
- Extract the zip in the location of your choosing
Find the Quectel
folder and inside there is another folder for the BC95-G
, go into it and there is the Python script that contains the commands to control the module.
Finding your device's serial port
Linux and Mac OS X
- Download and install the USB to UART bridge drivers from here. Select the appropriate version for your operating system and architecture
- Open a terminal window and run the command
ls /dev/tty*
- Look for a device with the name that begins with
/dev/tty
e.g./dev/tty.usbmodemPy343431
on Mac or/dev/ttyUSB0/dev/ttyACM0
on Linux
Note: For Linux, you may need to run the two commands below. Once you've completed that, reboot your computer. This will add permissions that will allow you to upload a sketch to the board.
sudo usermod -a -G tty ${USER}
sudo usermod -a -G dialout ${USER}
Windows
- Download and install the USB to UART bridge drivers from here. Select the appropriate version for your operating system and architecture.
- Open the Windows start menu and search for
Device Manager
- The COM port for the device will be listed as
USB Serial Device
or something similar - Keep note of the COM port (e.g. COM4)
- Now copy and paste the
initial_config.ino
code into the Arduino IDE - Click
Upload
to flash the board Now you should be ready to communicate to your module.
- Now copy and paste the
Updating nb-iot.py
Before we interface with our device, there are a few variables that need to be updated the file nb-iot.py
.
In your favourite text editor, open nb-iot.py
and follow these steps:
- Find and replace the
serial_name
with the port obtained earlier in the tutorial - Find and replace the
accessToken
with your device's secret key found in your Wia dashboard - Find and replace the
apn
with your operators APN (Default: Vodafone Ireland) - Find and replace the
network_operator
with your operators ID (Default: Vodafone Ireland)
Wia CoAP API Endpoint Details
52.17.209.228
is the IP address of the Wia CoAP API and 5683
is the port.
For the BC95-G
, there are a number of supported bands so to reduce the time searching the PLMN for all the bands, it's very useful to restrict the band dictated by the region and your network operator.
- Find and replace the
NBAND
(Default: 20 (Europe))
Interfacing with the Device
- For Windows, in PowerShell, run
python nb-iot.py -a
in the PowerShell terminal - For Mac/Linux open a terminal and run
python nb-iot.py -a
in the terminal This command checks if the device is working with our code by running the simplest command on the device (AT).
For a full list of commands available:
- For Windows, in PowerShell, run
python nb-iot.py -h
in the PowerShell terminal - For Mac/Linux open a terminal and run
python nb-iot.py -h
in the terminal
Publishing an Event to Wia
To publish an Event to Wia with your NB-IoT device, run the following:
- For Windows, in PowerShell, run the command python
nb-iot.py -aknt
- For Mac/Linux open Terminal and run the command
python nb-iot.py -aknt
This script does the following:
- Checks if the code can interface with the Device
- Resets the Device
- Attaches the Device to the network
- Opens a socket and sends a message via UDP to Wia The output should look like the image below:
Common errors
Some Devices might be on older firmware that's not compatible with the network you are trying to connect with. You'll need to contact your distributor to get the latest firmware and updater software.
For the BC95-G
if you haven't updated the firmware, the module will do a deep search across in the PLMN in the foreground, this means that it can take a couple of hours to finish this scan and attach to the network. This deep search takes place in the background with firmware version 1.9+.
If you are still having trouble connecting drop us a note.
Posted on June 21, 2018
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.