Quectel BC66

This guide will tell you how to connect your Quectel BC66 to our network and how you can communicate with the IoT Creators Portal via Lightweight M2M.
It might be useful to start with our UDP guide for the BC66 if you have no experience with the device or our network yet.

1. Attaching to the DT network

Before we can start to use the LwM2M client on the Quectel BC66 we need to configure the module and attach/register to the NB-IoT network of Deutsche Telekom. First (out of convenience, not mandatory) disable the AT command echo

ATE0
OK

Now, disable sleep lock so that the module doesn’t go into sleep mode and doesn’t shut off the UART communication to minimize the power consumption

AT+QSCLK=0
OK

These setting are not persistent so please make sure to execute the commands after each reboot.
Check if you have the newest firmware BC66NBR01A10 installed on the module.

ATI
Quectel_Ltd
Quectel_BC66
Revision: BC66NBR01A10
OK

🚧

Update firmware

Your firmware should be at least A10

Next, turn off the radio. Depending on the state the module is currently in, this can take a couple of
seconds until you get an OK.

AT+CFUN=0
OK

Next, we need to set the band to band 8 (900 MHz) as this is the band where Deutsche Telekom has deployed NB-IoT in Germany. By setting the band we optimize the time it takes for the module to attach to the network as it doesn’t have to scan all supported bands

AT+QBAND=1,8
OK

Now we set the APN in NVDM so that we can successfully connect to a Packet Data Network (PDN) later.

AT+QCGDEFCONT="IP","cdp.iot.t-mobile.nl"
OK

Turn on the radio module again

AT+CFUN=1

Restart the module as some configurations only take place after a reboot.

AT+QRST=1
OK

You only need to set the APN and band when you first use the module. The settings are stored in NVDM and are therefore persistent. Remember to deactivate echo with ATE0 and AT sleep lock with AT+QSCLK=0 after rebooting.
The module will start to attach to the network automatically after rebooting. If this is your first time using the module, the attach can take a long time. To see in which state the module is, you can activate certain URCs (unsolicited result codes) with the following two commands.

Wait a couple of minutes until you receive the +CEREG: 5,5,… URC and/or the +IP: <IP_address> URC.
You can also attach to the DT network manually, if you run into any problems.
For that you need to set the network operator with the AT command below. "26201" is the PLMN ID for Germany. You can find a list with different countries here.

AT+COPS=1,2,"26201"
OK

The SIM cards you received from us for the PoC also have public internet access. To check that you successfully connected you can try to ping a server that is publicly available like the Google DNS server with the IP address 8.8.8.8.

AT+PING=8.8.8.8
OK
+ping: begin, 8.8.8.8, data size= 64
+ping: finish, Packets: Sent = 1, Received =1, Lost = 0 (0% loss)
+ping: RTT statistics: Minimum = 950, Maximum =950, Average = 950

2. Register your device

To add your device to the IoT Creators Portal, use the following Northbound API

URL

https://api.scs.iot.telekom.com:443/m2m/endpoints

Method

POST

Header

{
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': 'Basic <YOUR BASE64 STRING>
}

Body

{'serialNumber': '<YOUR IMEI>',
'groupName': '<YOUR GROUP NAME>',
'protocol': 'LWM2M',
'additionalParams': {},
'address': '',
'identifier': '<YOUR IMEI>'}

You can find the required information in the IoT Creators Portal.

For the authentication you need to encode your credentials to base64 format. Therefor you can use this website https://www.base64encode.org/. Just enter (your) USERNAME:PASSWORD and copy your generated String.

You can ask your device for its IMEI with the following AT command:

AT+CGSN=1
+CGSN: <IMEI>
OK

3. Configuring the BC66 LwM2M Client

In this Chapter you will learn how to connect your device to our LWM2M server and you can add manually support objects on your BC66

3.1 Connecting to a LwM2M server

After you have successfully attached to the network and got a valid IP address (Chapter 1) you are ready to configure the BC66 to connect to the IoT Creators Portal using LwM2M. Before you can connect to the IoT Creators Portal you should add the device to the platform as explained above in Chapter 2.

Also, before we start to connect to the platform, we have to set the pre-configured Manufacturer of the Device Object 3/0/0 in the Quectel BC66 to avoid certain problems with the way the data is encoded into JSON format. To do so, run the following command in your serial terminal:

AT+QLWCFG="CR",3,0,0,"Quectel"
OK

I also recommend to do a lifecycle subscription so you can see all your device activities. To do that, you can use the following API with your IMEI and group name:

URL

https://api.scs.iot.telekom.com/m2m/subscriptions?type=lifecycleEvents

Method

POST

Header

{
'Content-Type': 'application/json',
'Accept': 'application/json'
}

Body

{
"criteria": {
"serialNumbers": [
"<YOUR IMEI>"
]
},
"deletionPolicy": 0,
"groupName": "<YOUR GROUPNAME>",
"events": [
"registration",
"deregistration",
"update",
"expiration"
],
"subscriptionType": "lifecycleEvents"
}

Now you can connect your device to the IoT Creators platform with these AT commands:

AT+QLWCONFIG=0,172.27.130.11,5683,<YOUR IMEI>,300,3
OK

AT+QLWREG
OK
+QLWREG: 0

🚧

URC

If everything works fine the BC66 shows the URC +QLWREG: 0. If anything went wrong during the register, the BC66 shows the URC +QLWREG: 1.

3.2 Manually support Objects on Quectel BC66

The Quectel BC66 supports certain Objects out-of-the-box. Three noteworthy Objects are the Device Object (Object 3), the Connectivity Monitoring Object (Object 4) and the LWM2M Cellular Connectivity Object (Object 10). With the Device Object you can read parameters of the device, like the Manufacturer, the Model, the Serial Number or you can execute a reboot. The Connectivity Monitoring Object provides you with information regarding your connectivity, e.g. the Cell-ID, Radio Signal Strength and the IP-Address. The LWM2M Cellular Connectivity Object can be helpful if you want to change eDRX and PSM settings. All those Objects are specific to the module itself. Because of that, they are pre-implemented on the Quectel BC66 and the module performs actions automatically without user interaction. E.g. if the IoT Creators Portal sends a request to the device to reboot, the module will automatically reboot. If you ask the device to provide the Device Object, it will send all available information automatically without user interaction. Of course there are also multiple Objects, that the cellular module can not support automatically because it simply has no access to e.g. external sensors.
The Quectel BC66 provides a very simple and flexible way to add support for every other object that is not pre-integrated. With the command AT+QLWADDOBJ we can add "support" for Objects and Resources. The syntax of the command is

AT+QLWADDOBJ=<obj_id>,<ins_id>, <res_num>,<res_id>[,…]
<obj_id>: Object ID
<ins_id>: Instance ID
<res_num>: Number of Resources
<res_id>: Resource IDs

Example: Let’s say we have a device that comes equipped with a temperature sensor and the ability to control Power. Our device should be able to report the temperature sensor value and the unit of the value to the IoT Creators Portal and it should be possible to tell the device to dim a certain power outlet.
We would then configure the Quectel BC66 to "support" the Temperature Object 3303 and the Resources for Sensor Value (5700) and Sensor Units (5701). To do this we use the command as follows

AT+QLWADDOBJ=3303,0,2,5700,5701
OK

We also want the device to support the Power Control (Object 3312) and the Resource for Dimmer (5851). To do this we use the command as follows

AT+QLWADDOBJ=3312,0,1,5851
OK

We can now check the supported Objects

AT+QLWADDOBJ?
+QLWADDOBJ: 3303,0,2,5700,5701
+QLWADDOBJ: 3312,0,1,5851
OK

4 Responding to requests on manually added Objects

If you added any Objects manually with AT+QLWADDOBJ you will get a notification on the Quectel BC66 that the IoT Creators Portal wants to either read, write, execute or observe on a resource. Your application on the MCU has to answer to that request with certain commands that are well documented in the AT commands manual.

4.1 Read Request

Register your device on the IoT Creators Portal and make sure the device is connected (QLWREG: 0). Read the Temperature Sensor Value with the resource path 3303/0/5700 on the IoT Creators Portal via the following Northbound API.

URL

https://api.scs.iot.telekom.com/m2m/endpoints/<YOUR IMEI>/3303/0/5700

Method

GET

Header

{
'Content-Type': 'application/json',
'Authorization': 'Basic <YOUR BASE64 STRING>
}

On the Quectel BC66 you will automatically receive the following message:

+QLWURC: "read",54143,3303,0,5700

This message tells you that the SCS wanted to read the value of 3303/0/5700 and provides you the Message ID 54143 of the request. Now the MCU can read the actual value of the temperature sensor attached to the device and respond to the request with the following command including the Message ID.

AT+QLWRDRSP=54143,1,3303,0,5700,4,4,34.5,0
OK

With this command we told the IoT Creators Portal that the answer to the read request with Message ID 54143 on path 3303/0/5700 is a float value and 4 characters long. The value itself is 34.5.
To understand the syntax of this command please check the AT Commands Manual.

4.2 Write Request

Write the Temperature Sensor Value 1 with the resource path 3303/0/5700 on the IoT Creators Portal by via the following Northbound API with the value 10.0.

URL

https://api.scs.iot.telekom.com/m2m/endpoints/<YOUR IMEI>/3303/0/5700

Method

PUT

Header

{
'Content-Type': 'application/json',
'Authorization': 'Basic <YOUR BASE64 STRING>
}

Body

{
"resourceValue":"10.0"
}

On the Quectel BC66 you will automatically receive the following message:

+QLWURC: "write",45140,3303,0,5700,1,4,"10.0",0

This message tells you that the IoT Creators Portal wants to write the value 10.0 to the path 3303/0/5700 and provides you with the Message ID 54144 of the request. Copy this ID and use it for the following command to write the actual value into the internal memory on application level and respond with a SUCCESS.

AT+QLWWRRSP=45140,2
OK

The status code 2 stands for success. There are also different status codes documented in the AT
Commands Manual
.

4.3 Observe Request

Observe/Subscribe on the Temperature Sensor Value with the resource path 3303/0/5700 via
the following Northbound API:

URL

https://api.scs.iot.telekom.com/m2m/subscriptions?type=resources

Method

POST

Header

{
'Content-Type': 'application/json',
'Accept': 'application/json'
}

Body

{
"criteria": {
"serialNumbers": [
"<YOUR IMEI>"
]
},
"deletionPolicy": 0,
"groupName": "<YOUR GROUP NAME>",
"resources": [
{"resourcePath":"3303/0/5700"},
{"resourcePath":"3/0/0"}
],
"subscriptionType": "resources"
}

You should automatically receive the following message on your BC66:

+QLWURC: "observe",54142,0,3303,0,5700

This message tells you that the IoT Creators Portal wants to observe the path 3303/0/5700 and provides you with the Message ID 54142 of the request. Now the MCU can acknowledge the request and provide an initial value to the IoT Creators Portal with the following command

AT+QLWOBSRSP=54142,1,3303,0,5700,4,4,34.5,0
OK

After successfully acknowledging the request, the BC66 can notify the IoT Creators Portal whenever the value of the Temperature changes by using the following command:

AT+QLWNOTIFY=3303,0,5700,4,4,18.5,0,1

Did this page help you?