Quectel BC95-G-TE-B
Learn how to setup and integrate dev-kit Quectel BV95-G-TE-B with IoT Creators NB-IoT network and Data Provisioning Service (SCS)
Links
Links to the AT command samples:
- Query device information
- Setup network configuration and verification
- Send "Hallo World" via UDP
- Receive "Hallo Device" via UDP
Setup the Device
In the following I will describe you how to setup your devkit so that you are able to send AT commands directly from your computer to the Quectel modem.
Connect your devkit with your computer
Your devkit will be connected with your compute by using mini USB and can be accessed with a terminal program such as "putty" on Windows or "screen" or "minicom" on Linux.
In case you are working with Linux your are lucky. The USB/Serial drivers should be already available on your system and you don't need to install anything else.
After you connected your devkit via USB with your computer you should find the device file
/dev/ttyXRUSB0 (or /dev/ttyACM0). It is automatically created when you connect your devkit with your computer and if you disconnects it your devkit disappears again.
Unfortunately I can not tell you how to enable the serial terminal connection via USB on Window or Mac because I am only working with Linux. Sorry 😥.
Execute AT commands on your devkit the first time.
To execute AT commands on your devkit you need start on your computer a terminal program such as putty on Windows or minicom or screen on Linux and connect it with your devkit via the serial USB line. After this you can send AT commands to the modem of your devkit.
In the following I will explain to you how to do this stuff on Linux by using the minicom and to send those AT commands to the modem to query device product and IMEI information.
I tryed to use screen as terminal progam instead of minicom. But for any reason I couldn't activate the local echo of my input on the terminal window. Out of this reason I use minicom for some QUECTEL devices.
If you can activate the local echo of your input with screen please let me know, I am highly interested in it.
Connect your devkit with your Linux computer via terminal program minicom
In case minicom is not already installed on your computer you can install it with
$ sudo apt-get install minicom
After that you can configure minicom by executing
$ sudo minicom -s
It is important that you run the configuration of minicom as root because the resulting configuration file will be stored in the directory /etc/minicom to which root has only write permissions.
In the minicom configuration menu change the following settings:
- Enter Serial port setup
- Set Serial Device to /dev/ttyXRUSB0
- Set the baudrate (Bps/Par/Bits) to 9600 8N1
- Enter Screen and keyboard
- Set Local echo to Yes
- Enter Save setup as
- Give bc95-g as the name to save the configuration
- Enter Exit from Minicom
After configuring minicom for your Quectel devkit you can start minicom with the configuration *bc95-g'* which just created before.
$ minicom bc95-g
In case you have any problems to access the device file /dev/ttyXRUSB0 because you don't have enough access privilages for this file execute the following command
$ sudo usermod -a -G dialout YOUR-USER-NAME
As very first AT command you should input the command AT. This command shall always return OK. If not, there is something wrong.
AT
AT
OK
Afterwards you should input the command ATE0 to deactivate the device echo.
ATE0
ATE0
OK
Congratulations
If you reached this point you equipt your QUECTEL BC95-G with the capabiltiy to pass your AT commands from the serial USB terminal interface directly through to the ublox modem.
Now the fun begins! 😃 😃
AT Commands to get IMEI, IMSI and other product information from your devkit
In the following various AT commands are shown to query the IMEI and other product information from your devkit.
# Request IMEI
AT+CGSN=1
+CGSN: 357518080495450
OK
# Request IMSI of the SIM card
AT+CIMI
901405700009293
OK
# Request SIM card identification number
AT+NCCID
+NCCID: 89882280000001294327
OK
# Device statistics
AT+NUESTATS
Signal power:-32768
Total power:-32768
TX power:-32768
TX time:0
RX time:0
Cell ID:4294967295
ECL:255
SNR:-32768
EARFCN:4294967295
PCI:65535
RSRQ:-32768
OPERATOR MODE:0
CURRENT BAND:255
OK
# Request manufacturer identification
AT+CGMI
Quectel
OK
# Rquest model identification
AT+CGMM
BC95GJB-02-STD
OK
# Request firmware version identification
AT+CGMR
SB,V150R100C10B200SP1
SECURITY_A,V150R100C20B300SP7
PROTOCOL_A,V150R100C20B300SP7
APPLICATION_A,V150R100C20B300SP7
SECURITY_B,V150R100C20B300SP7
RADIO,Hi2115_RF0
OK
# Request prodct type number
ATI
Quectel
BC95-G
Revision:BC95GJBR01A07
OK
Attach to the NB-IoT Network
This chapter explains how you can attach your QUECTEL BC95-G devkit to the NB-IoT network. I recommend to read the chapter "Setup QUECTEL BC95-G" first.
If you are only interested in the conclusion of the AT commands to configure the network setup go to chapter "'AT Commands Only"
Before you send any UDP or COAP message to IoT Creators make sure you registered the device IMEI before.
If you forget, you will have problems to register your device afterwards. In this case please get in contact with IoT Creators support team.
A few assumptions and notes before starting with this manual
- You should be able to send AT commands to your devkit with a terminal program such as putty, screen, minicom, etc.
- Your device is on the latest firmware
- Be gentle to your device and have some patience. After each AT command he/she/it needs a few seconds to execute the command and respond
In the following we will walk through together the AT commands with which you can perform the following actions:
- Setup network configuration of you devkit.
- Attach to the network and verify your network configuration.
- Ping an IP address.
Setup Network Configuration
After switching on your devkit deactivate the radio functionality with +CFUN
. You should do this to make sure no miss-configured automatic dial-in action make your setup difficult.
AT+CFUN=0
Switch on some basic configuration parameters of the modem with +NCONFIG
such as autoconnect, scambling.
AT+NCONFIG="AUTOCONNECT","TRUE"
AT+NCONFIG="CR_0354_0338_SCRAMBLING","TRUE"
AT+NCONFIG="CR_0859_SI_AVOID","TRUE"
Roaming via Vodafone in UK
In case of romaing via Vodafone in UK you probably need to use
AT+NCONFIG="CR_0859_SI_AVOID","FALSE"
.
Set the APN of IoT Creators with +CGDCONT
AT+CGDCONT=0,"IP","cdp.iot.t-mobile.nl"
Sometimes you get an ERROR response of the +CGDCONT
command. Reason for this can be that the radio is not deactivated with +CFUN=0
and the modem already attached to the network. In this case just deactivat the radio and try it again.
Set the bands with +NBAND
command.
AT+NBAND=8,20
Set the EPS network registration status with +CEREG
command.
AT+CEREG=5
Select the network operator of your choice with +COPS
command manually (1) by given the numeric identification (2) of the operator ("26201", "20416", "26002", etc.) (https://docs.iotcreators.com/docs/telekom-iot-networks-in-europe)
AT+COPS=1,2,"20416"
AT+COPS=1,2,"26201"
AT+COPS=1,2,"26002"
👍 Great! Your setup of network configuration is complete now.
The next step is it to test if it is correct and if your devkit is able to attach the network with it.
Good Luck 😏
The setup of the network configuration is complete. Because we deactivated the radio in the
beginning with +CFUN=0
nothing should happen so far.
To see your configuration in action you can trigger a reboot of your devkit with the +NRB
command.
AT+NRB
After you triggered the reboot with ```+NRB you should see the following on your terminal and your devkit should attach to the network automatically.
REBOOTING
�"�
Boot: Unsigned
Security B.. Verified
Protocol A.. Verified
Apps A...... Verified
REBOOT_CAUSE_APPLICATION_AT
Neul
OK
As next we will verify if your devkit is actually attached to the network and verify the network configuration with some more AT commands.
Attach to the Network and verify your Network Configuration
After you have rebooted your devkit the most interesting question is if your devkit got an IP address assigned by the network.
You can query the assigned IP address from your devkit with the +CGPADDR
command.
AT+CGPADDR
+CGPADDR: 0,"10.128.1.157"
OK
As the result your devkit returns the current IP address. In this sample it is 10.128.1.157
😠 What to do if it doesn't work 👿
If you are not able to get established a network attachment double check the following
- Did you configure the correct APN?
- Did you configure the correct mobile network operator in your country?
- Did you make sure your SIM card has active roaming in case you are not in the home country of your network operator?
AT Commands to query Network Information
In the following I show you some more AT commands with which you can query other information regarding mobile connection status.
# Query if the devkit is attached to the network
AT+CGATT?
+CGATT: 1
OK
# Query the configured MNO (Mobile Network Operator)
AT+COPS?
+COPS: 0,2,"26201"
OK
# Query the configured APN
AT+CGDCONT?
+CGDCONT: 0,"IP","cdp.iot.t-mobile.nl",,0,0,,,,,0
OK
# Query the configuration
AT+NCONFIG?
+NCONFIG:AUTOCONNECT,TRUE
+NCONFIG:CR_0354_0338_SCRAMBLING,TRUE
+NCONFIG:CR_0859_SI_AVOID,TRUE
+NCONFIG:COMBINE_ATTACH,FALSE
+NCONFIG:CELL_RESELECTION,FALSE
+NCONFIG:ENABLE_BIP,FALSE
+NCONFIG:MULTITONE,TRUE
+NCONFIG:NAS_SIM_POWER_SAVING_ENABLE,TRUE
+NCONFIG:BARRING_RELEASE_DELAY,64
+NCONFIG:RELEASE_VERSION,13
+NCONFIG:RPM,FALSE
+NCONFIG:SYNC_TIME_PERIOD,0
+NCONFIG:IPV6_GET_PREFIX_TIME,15
+NCONFIG:NB_CATEGORY,1
+NCONFIG:RAI,FALSE
+NCONFIG:HEAD_COMPRESS,FALSE
+NCONFIG:RLF_UPDATE,FALSE
+NCONFIG:CONNECTION_REESTABLISHMENT,FALSE
+NCONFIG:PCO_IE_TYPE,EPCO
OK
# Query signal power and quality
# Power should be between 0-31 and NOT 99. 99 means "no network detactable"
# Quality should be between 0-9. 99 means not know or not detactable.
AT+CSQ
+CSQ: 99,99
OK
Ping the first IP address
With the AT+CGPADDR
command you could query the current IP address of your devkit. But you still not know if your devkit is able communicate in the IP network correctly.
To test this you should ping the UDP server of IoT Creators platform with th +NPING
command.
AT+NPING=172.27.131.100
OK
+NPING: "172.27.131.100",253,7478
In case your devkit could ping the given IP address response will be
´´´
+NPINGERR: 1
´´´
👍 Congratulations 👍
If you reached this point and if you were able to ping successfully the IoT Creators' UDP server you reached a very important milestone.
Experience has shown that most of the problems arise during the devkit commissioning and the first attachment with the network.
The rest journey the next steps of the tutorial will be easy 😏
AT Commands Only
#######################################################################
# Network attach
#######################################################################
# Switch off radio
AT+CFUN=0
# Switch autoconnect and scrambling on:
AT+NCONFIG="AUTOCONNECT","TRUE"
AT+NCONFIG="CR_0354_0338_SCRAMBLING","TRUE"
AT+NCONFIG="CR_0859_SI_AVOID","TRUE"
# Set the APN
AT+CGDCONT=0,"IP","cdp.iot.t-mobile.nl"
# Set the bands
AT+NBAND=8
# EPS network registration status
AT+CEREG=2
# select an operator DE:"26201", NL:"20416"
AT+COPS=1,2,"26201"
# Reboot the device
AT+NRB
#######################################################################
# Network attach verification
#######################################################################
# Check IP address
AT+CGPADDR
# Check if attached to network
AT+CGATT?
# Check MNO
AT+COPS?
# Check APN
AT+CGDCONT?
# Check the configuration
AT+NCONFIG?
# Check signal strength and qualitay
AT+CSQ
# Device statistics
AT+NUESTATS
# Extended error report
AT+CEER
#######################################################################
# Ping UDP server of IoT Creators
#######################################################################
AT+NPING=172.27.131.100
Send and Receive via UDP
In the following chapters I will explain to you how you can send a "Hello World" message from the device to the IoT Creators SCS and how you can receive a a "Hello Device" message on your devkit from IoT Creators SCS.
Send "Hello World"
Register your device first!
Make sure that you have registered your device with its IMEI at the IoT Creators portal BEFORE you send your first message to the UDP or CoAP server of IoT Creators.
If you forget, you will have problems to register your device afterwards. In this case please get in contact with IoT Creators support team.
Welcome to this step of tutorial. You probably ended up here because you could successfully connect your devkit to the network.
Before you continue make sure your device has an IP address assigned and you can ping the UDP server of IoT Creators. You test both with the +CGPADDR
and the +NPING
command.
AT+CGPADDR
+CGPADDR: 0,"10.128.4.109"
OK
AT+NPING=172.27.131.100
OK
+NPING: "172.27.131.100",253,2396
In the next steps you will
- Open local UDP socket to send UDP messages.
- Create a hex coded "Hello World" message.
- Send the hex coded "Hello World" message to the UDP server of IoT Creators.
- Verify if the messages has been arrived at the IoT Creators platform.
Open local UDP Socket to send message
To send UDP messages to a UDP server you need to open a local UDP socket. For this you can use the +NSOCR
command. The returned value of this command ("0" in the sample below) represents the identifier of the opened socket.
AT+NSOCR="DGRAM",17,7000,1
0
OK
The +NSOCR
command opens a UDP socket with the following parameters:
Parameter | Description |
---|---|
type | Type of the socket. Currently only "DGRAM" is supported. |
protocol | Protocol id which shall be used. Currently only 17 for UDP is supported. |
listen_port | Local port which is included in the sent message and on which messages can be received from the IoT Creators UDP server. |
receive_control | 0 := incomming messages are ignored 1 := incomming messages will trigger a +NSONMI event. |
To close the UDP socket you can use the command +NSOCL
later. The "0" as command parameter references the socket identifier as it has been returned by the +NSOCR
command before.
AT+NSOCL=0
OK
Create a HEX coded "Hello World" Message
I recommand not to send plain text or binary data from the device to your backend applications or vice versa. You can use a hex or a base64 encoding format of data. In our sample we send Hello World as a hex converted string to the IoT Creators.
To convert Hello World you can use online tool http://string-functions.com/string-hex.aspx
The hex string for Hello World is 48656c6c6f20576f726c64.
Sending HEX coded "Hello World" Message to UDP Server
To let your device sent this message via UDP to the UDP server of IoT Creators you can use the +NSOST
command as shown in the following.
The +NSOST
command returns the socket identification as a first digiti and the length of successfully sent data as second digit.
AT+NSOST=0,"172.27.131.100",15683,11,"48656c6c6f20576f726c64"
0,11
OK
The +NSOST
command sends a UDP message with the following parameters:
Parameter | Description |
---|---|
socket | Socket identifier as it has been returned from the +NSOCR command. |
remote_ip_address | IP address of the UDP server to which the the message shall be sent. |
remote_port | Port on which the UDP server listens for messages. |
length | Length of the original data to be sent, not of the hex converted data. The max. length is 512 bytes. |
data | Data to be sent in hex format. |
CONGRATULATIONS 👏 🍰
If you see OK on the device console CONGRATULATIONS! you just send your first UDP message from your device to an UDP server of IoT Creators.
The data length which is assigned to the command
AT+NSOST
describes the length of the original data. It does NOT desribes the length of the data in hex format which has a length of 22 bytes in the "Hello World" case.
View the received Messages in IoT Creators Portal
For each device the IoT Creators Portal makes the laste received message available by showing it in the Payload column. In case of our Hello World message
If you click on the payload the value of it is copied to the clipboard.
As already mentioned above it is a nice behaviour to transfer strings and binary data not as they are. It is better to encode them to hex or base64 for the transfer.
We sent our Hello World as hex encoded string on its way. Out if this reason we see in the IoT Creators Portal the string 48656c6c6f20576f726c64.
To decode the received message back from hex to a readable string we can use the online tool http://string-functions.com/hex-string.aspx.
👏 CONGRATULATIONS 👏 🍰
If you can decode your received message to Hello World **CONGRATULATIONS**! You just sent your first UDP message from your device via NB-IoT to IoT Creators platform.
Maybe you have to send the first message twice. The first message will be considered as a registration message, so the it will not be forwarded to the GUI.
AT Commands to send Hello World
# Open local UDP socket on port 7000
AT+NSOCR="DGRAM",17,7000,1
0
OK
# Send UDP message to UDP server via socket=0
AT+NSOST=0,"172.27.131.100",15683,11,"48656c6c6f20576f726c64"
0,11
OK
# Close socket=0
AT+NSOCL=0
OK
Receive "Hello Device"
Welcome back to the tutorial 👍.
In this step I will explain you how you can receive the "Hello Device" downlink message 48656c6c6f20446576696365 via UDP which you have posted before to the IoT Creators platform.
The downlink message which you posted to IoT Creators API before is queued by the IoT Creators platform. The queued downlink message is sent to the device after IoT Creators platform received the uplink message from the device.
In this tutorial you will perform the following steps:
- Open local UDP socket.
- Send a "i am alive" heartbeat message via UDP to the UDP server of IoT Creators.
- Receive the previous queued "Hello Device" message from the IoT Creators platform.
Open local UDP socket and send "i am alive" heartbeat
You can open the UDP socket and send a UDP message with the commands +NSOCR
and NSOST
.
Before you open the UDP socket you can verify your IP address and if you are able to heartbeat the UDP server of IoT Creators.
AT+CGPADDR
+CGPADDR: 0,"10.128.5.88"
OK
AT+NPING=172.27.131.100
OK
+NPING: "172.27.131.100",253,4934
Send "i am alive" heartbeat message and receive downlink message
After you verified the network attach of your device you can open the UDP socket on your device and send a "i am alive" heartbeat message to the UDP server of IoT Creators. The message should be in hex format.
AT+NSOCR="DGRAM",17,7000,1
0
OK
AT+NSOST=0,"172.27.131.100",15683,10,"6920616d20616c697665"
0,10
OK
The "i am alive" message causes the UDP server of the IoT Creator portal to send out the previous queued "Hallo Device" message to the device.
Because you used as last parameter "1" in the +NSOCR
command to open the socket the device notifiers you with an URC (Unsolicited Result Code) code as soon data has been been received by the modem of the device.
+NSONMI: 0,12
AT+NSORF=0,12
0,"172.27.131.100",15683,12,"48616C6C6F20446576696365",0
OK
The +NSONMI
in the sample above indicats that 12 bytes of data have been received on socket 0.
To retrieve the 12 bytes of the received data from socket 0 you can use the +NSORF`=0,12`` command.
+NSORF``` returns the following elements:
Value | Description |
---|---|
0 | Id of the socket on which the data has been received. |
172.27.131.100 | IP address of the remote host (UDP server) which sent the data. |
15683 | Remote port the messages were sent from. |
12 | Amount of data returned as a decimal byte length |
"48616C6C6F20446576696365" | Data received in hexadecimal format. |
0 | Amount of data still to be read |
To decode the hex data 48616C6C6F20446576696365 into a readable string you can use the online tool http://string-functions.com/hex-string.aspx.
Downlink only possible after uplink
If you try to send a downlink message to a device that has not send any uplink messages you will receive the error : Serial number not found.
After sending an uplink message the device registration is completed and downlinking will work.
AT Commands to receive Hello Device
# Test if device has an IP address asigned
AT+CGPADDR
+CGPADDR: 0,"10.0.5.112"
OK
# Ping UDP server of IoT Creators
AT+NPING=172.27.131.100
OK
+NPING: "172.27.131.100",253,4135
# Open local UDP socket
AT+NSOCR="DGRAM",17,7000,1
0
OK
# Send "i am alive" message to UDP server
AT+NSOST=0,"172.27.131.100",15683,10,"6920616d20616c697665"
0,10
OK
# URC about received data
+NSONMI: 0,12
# Retrieve the received data
AT+NSORF=0,12
0,"172.27.131.100",15683,12,"48616C6C6F20446576696365",0
OK
Updated almost 3 years ago