Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Set Up Your Quectel BC95-G and Post an Event to Wia

DZone's Guide to

How to Set Up Your Quectel BC95-G and Post an Event to Wia

Want to learn how to post an event to Wia? Check out this tutorial on posting an event in Wia using Quectel BC95-G.

· IoT Zone ·
Free Resource
Quectel BC95-G

In this tutorial, we're going through the initial steps to get setup with an NB-IoT and the Quectel BC95-G to 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

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

Issues Running the Command?

In the rare case that 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 the control of 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

For Linux, you may need to run the two commands below. Once you've completed that, reboot your computer. This will add permissions that 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.

Updating nb-iot.py

Before we interface with our device, there are a few variables that need to be updated in the file nb-iot.py.
In your favorite 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 amount of 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 to see 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 using the chat icon at the bottom right hand side.

Topics:
tutorial ,nb-iot ,learn ,wia cloud ,python ,iot

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}